try to fix ci
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { test, expect, Page } from "@playwright/test";
|
import { test, expect, Page } from "@playwright/test";
|
||||||
import { resetDatabase } from "./helpers";
|
import { resetDatabase, login } from "./helpers";
|
||||||
|
|
||||||
test.beforeEach(async () => {
|
test.beforeEach(async () => {
|
||||||
await resetDatabase();
|
await resetDatabase();
|
||||||
@@ -117,24 +117,14 @@ test.describe("cox can edit trips", () => {
|
|||||||
|
|
||||||
// Someone registers...
|
// Someone registers...
|
||||||
await page.goto("/auth/logout");
|
await page.goto("/auth/logout");
|
||||||
await page.goto("/auth");
|
await login(page, "rower", "rower");
|
||||||
await page.getByPlaceholder("Name").click();
|
|
||||||
await page.getByPlaceholder("Name").fill("rower");
|
|
||||||
await page.getByPlaceholder("Name").press("Tab");
|
|
||||||
await page.getByPlaceholder("Passwort").fill("rower");
|
|
||||||
await page.getByPlaceholder("Passwort").press("Enter");
|
|
||||||
|
|
||||||
await page.goto("/planned");
|
await page.goto("/planned");
|
||||||
await page.getByRole('link', { name: 'Mitrudern' }).nth(1).click();
|
await page.getByRole('link', { name: 'Mitrudern' }).nth(1).click();
|
||||||
|
|
||||||
// Login as cox again
|
// Login as cox again
|
||||||
await page.goto("/auth/logout");
|
await page.goto("/auth/logout");
|
||||||
await page.goto("/auth");
|
await login(page, "cox", "cox");
|
||||||
await page.getByPlaceholder("Name").click();
|
|
||||||
await page.getByPlaceholder("Name").fill("cox");
|
|
||||||
await page.getByPlaceholder("Name").press("Tab");
|
|
||||||
await page.getByPlaceholder("Passwort").fill("cox");
|
|
||||||
await page.getByPlaceholder("Passwort").press("Enter");
|
|
||||||
|
|
||||||
await page.goto("/planned");
|
await page.goto("/planned");
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,26 @@
|
|||||||
import { exec } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
import { promisify } from 'util';
|
import { promisify } from 'util';
|
||||||
|
import { Page } from '@playwright/test';
|
||||||
|
|
||||||
const execAsync = promisify(exec);
|
const execAsync = promisify(exec);
|
||||||
|
|
||||||
export async function resetDatabase(): Promise<void> {
|
export async function resetDatabase(): Promise<void> {
|
||||||
await execAsync('cd .. && ./reset_test_data.sh');
|
await execAsync('cd .. && ./reset_test_data.sh');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function login(page: Page, username: string, password: string): Promise<void> {
|
||||||
|
// Clear cookies to ensure clean state
|
||||||
|
await page.context().clearCookies();
|
||||||
|
|
||||||
|
await page.goto("/auth");
|
||||||
|
await page.getByPlaceholder("Name").click();
|
||||||
|
await page.getByPlaceholder("Name").fill(username);
|
||||||
|
await page.getByPlaceholder("Passwort").click();
|
||||||
|
await page.getByPlaceholder("Passwort").fill(password);
|
||||||
|
|
||||||
|
// Wait for navigation after form submission
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForURL(/\/(planned|log|$)/, { timeout: 10000 }),
|
||||||
|
page.getByPlaceholder("Passwort").press("Enter")
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user