integration-test: Create authentication setup

This commit is contained in:
Elian Doran 2024-08-09 00:41:55 +03:00
parent 6a459427fb
commit a98f01d924
No known key found for this signature in database
6 changed files with 31 additions and 12 deletions

1
.gitignore vendored
View File

@ -25,3 +25,4 @@ images/app-icons/mac/*.png
/playwright-report/
/blob-report/
/playwright/.cache/
/playwright/.auth/

View File

@ -0,0 +1,17 @@
import { test as setup, expect } from '@playwright/test';
const authFile = 'playwright/.auth/user.json';
const ROOT_URL = "http://localhost:8080";
const LOGIN_PASSWORD = "eliandoran";
// Reference: https://playwright.dev/docs/auth#basic-shared-account-in-all-tests
setup("authenticate", async ({ page }) => {
await page.goto(ROOT_URL);
await expect(page).toHaveURL(`${ROOT_URL}/login`);
await page.getByRole("textbox", { name: "Password" }).fill(LOGIN_PASSWORD);
await page.getByRole("button", { name: "Login"}).click();
await page.context().storageState({ path: authFile });
});

View File

@ -7,14 +7,6 @@ test("Can insert equations", async ({ page }) => {
await page.setDefaultTimeout(60_000);
await page.setDefaultNavigationTimeout(60_000);
await page.goto(ROOT_URL);
await expect(page).toHaveURL(`${ROOT_URL}/login`);
// Log in
await page.getByRole("textbox", { name: "Password" }).fill(LOGIN_PASSWORD);
await page.getByRole("button", { name: "Login"}).click();
await page.waitForURL(/\/#root\//);
// Create a new note
// await page.locator("button.button-widget.bx-file-blank")
// .click();

View File

@ -0,0 +1,5 @@
import { test, expect } from '@playwright/test';
test("Displays update badge when there is a version available", async ({ page }) => {
await page.goto("http://localhost:8080");
});

View File

@ -34,13 +34,17 @@ export default defineConfig({
/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
name: "setup",
testMatch: /.*\.setup\.ts/
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
name: "firefox",
use: {
...devices[ "Desktop Firefox" ],
storageState: "playwright/.auth/user.json"
},
dependencies: [ "setup" ]
},
/* Test against mobile viewports. */