test) fixing tests
All checks were successful
PR Checks / lint-test-and-docker-build (pull_request) Successful in 2m15s
All checks were successful
PR Checks / lint-test-and-docker-build (pull_request) Successful in 2m15s
This commit is contained in:
@@ -21,6 +21,12 @@ test.beforeEach(async ({ context }) => {
|
||||
});
|
||||
|
||||
test('admin sees auth source and can set local password', async ({ page }) => {
|
||||
const suffix = Date.now();
|
||||
const username = `e2e_auth_source_${suffix}`;
|
||||
const fullName = `E2E Auth Source ${suffix}`;
|
||||
const email = `e2e_auth_source_${suffix}@test.local`;
|
||||
const password = `InitPass-${suffix}-123`;
|
||||
|
||||
await loginAsLocalUser(page, TEST_USERS.admin.username, TEST_USERS.admin.password);
|
||||
await page.goto(ADMIN_USERS_URL);
|
||||
await expect(page.getByRole('heading', { name: 'Users' })).toBeVisible();
|
||||
@@ -31,7 +37,19 @@ test('admin sees auth source and can set local password', async ({ page }) => {
|
||||
const adminRow = rowForUser(page, TEST_USERS.admin.username);
|
||||
await expect(adminRow.getByText('Local', { exact: true })).toBeVisible();
|
||||
|
||||
await regularRow.getByRole('button', { name: 'Set local password' }).click();
|
||||
await page.getByRole('button', { name: 'Add User' }).click();
|
||||
const addDialog = page.getByRole('dialog', { name: 'Add user' });
|
||||
await expect(addDialog).toBeVisible();
|
||||
await addDialog.locator('input[type="text"]').nth(0).fill(username);
|
||||
await addDialog.locator('input[type="text"]').nth(1).fill(fullName);
|
||||
await addDialog.locator('input[type="email"]').fill(email);
|
||||
await addDialog.locator('input[type="password"]').nth(0).fill(password);
|
||||
await addDialog.locator('input[type="password"]').nth(1).fill(password);
|
||||
await addDialog.getByRole('button', { name: 'Create user' }).click();
|
||||
|
||||
const disposableUserRow = rowForUser(page, username);
|
||||
await expect(disposableUserRow.getByText('Local', { exact: true })).toBeVisible();
|
||||
await disposableUserRow.getByRole('button', { name: 'Set local password' }).click();
|
||||
const dialog = page.getByRole('dialog', { name: 'Set local password' });
|
||||
await expect(dialog).toBeVisible();
|
||||
|
||||
|
||||
@@ -13,15 +13,6 @@ async function loginAsLocalUser(page: Page, username: string, password: string):
|
||||
await page.waitForURL(`**${DASHBOARD_URL}`, { timeout: 15_000 });
|
||||
}
|
||||
|
||||
async function clearSessionState(page: Page): Promise<void> {
|
||||
await page.context().clearCookies();
|
||||
await page.goto('about:blank');
|
||||
await page.evaluate(() => {
|
||||
localStorage.clear();
|
||||
sessionStorage.clear();
|
||||
});
|
||||
}
|
||||
|
||||
test.beforeEach(async ({ context }) => {
|
||||
await context.clearCookies();
|
||||
});
|
||||
@@ -47,9 +38,9 @@ test('admin can create a local user who can sign in', async ({ page }) => {
|
||||
await addDialog.locator('input[type="password"]').nth(1).fill(password);
|
||||
await addDialog.getByRole('button', { name: 'Create user' }).click();
|
||||
|
||||
await expect(page.getByRole('cell', { name: username })).toBeVisible();
|
||||
await expect(page.getByRole('cell', { name: username, exact: true })).toBeVisible();
|
||||
|
||||
await clearSessionState(page);
|
||||
await page.context().clearCookies();
|
||||
await loginAsLocalUser(page, username, password);
|
||||
await expect(page).toHaveURL(/\/trips\/dashboard/);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { test, expect, type Page } from '@playwright/test';
|
||||
import { TEST_USERS } from './setup/test-users.js';
|
||||
|
||||
const LOGIN_URL = '/trips/login';
|
||||
const UPCOMING_URL = '/trips/upcoming';
|
||||
const UPCOMING_URL = '/trips/trips/upcoming';
|
||||
|
||||
async function submitLocalLogin(page: Page, username: string, password: string): Promise<void> {
|
||||
await page.fill('input[name="identifier"]', username);
|
||||
@@ -19,7 +19,7 @@ test('redirects back to protected route after local login', async ({ page }) =>
|
||||
await expect(page).toHaveURL(/\/trips\/login/);
|
||||
|
||||
await submitLocalLogin(page, TEST_USERS.regular.username, TEST_USERS.regular.password);
|
||||
await page.waitForURL(/\/trips\/(upcoming|dashboard)/, { timeout: 15_000 });
|
||||
await page.waitForURL(/\/trips\/(trips\/upcoming|dashboard)/, { timeout: 15_000 });
|
||||
await expect(page).not.toHaveURL(/\/trips\/auth/);
|
||||
await expect(page).not.toHaveURL(/\/trips\/login/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user