Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit a98f01d

Browse files
committed
integration-test: Create authentication setup
1 parent 6a45942 commit a98f01d

File tree

6 files changed

+31
-12
lines changed

6 files changed

+31
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ images/app-icons/mac/*.png
2525
/playwright-report/
2626
/blob-report/
2727
/playwright/.cache/
28+
/playwright/.auth/

integration-tests/auth.setup.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { test as setup, expect } from '@playwright/test';
2+
3+
const authFile = 'playwright/.auth/user.json';
4+
5+
const ROOT_URL = "http://localhost:8080";
6+
const LOGIN_PASSWORD = "eliandoran";
7+
8+
// Reference: https://playwright.dev/docs/auth#basic-shared-account-in-all-tests
9+
10+
setup("authenticate", async ({ page }) => {
11+
await page.goto(ROOT_URL);
12+
await expect(page).toHaveURL(`${ROOT_URL}/login`);
13+
14+
await page.getByRole("textbox", { name: "Password" }).fill(LOGIN_PASSWORD);
15+
await page.getByRole("button", { name: "Login"}).click();
16+
await page.context().storageState({ path: authFile });
17+
});

integration-tests/katex.spec.ts renamed to integration-tests/katex.disabled.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@ test("Can insert equations", async ({ page }) => {
77
await page.setDefaultTimeout(60_000);
88
await page.setDefaultNavigationTimeout(60_000);
99

10-
await page.goto(ROOT_URL);
11-
await expect(page).toHaveURL(`${ROOT_URL}/login`);
12-
13-
// Log in
14-
await page.getByRole("textbox", { name: "Password" }).fill(LOGIN_PASSWORD);
15-
await page.getByRole("button", { name: "Login"}).click();
16-
await page.waitForURL(/\/#root\//);
17-
1810
// Create a new note
1911
// await page.locator("button.button-widget.bx-file-blank")
2012
// .click();
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test("Displays update badge when there is a version available", async ({ page }) => {
4+
await page.goto("http://localhost:8080");
5+
});

playwright.config.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@ export default defineConfig({
3434
/* Configure projects for major browsers */
3535
projects: [
3636
{
37-
name: 'chromium',
38-
use: { ...devices['Desktop Chrome'] },
37+
name: "setup",
38+
testMatch: /.*\.setup\.ts/
3939
},
4040

4141
{
42-
name: 'firefox',
43-
use: { ...devices['Desktop Firefox'] },
42+
name: "firefox",
43+
use: {
44+
...devices[ "Desktop Firefox" ],
45+
storageState: "playwright/.auth/user.json"
46+
},
47+
dependencies: [ "setup" ]
4448
},
4549

4650
/* Test against mobile viewports. */

0 commit comments

Comments
 (0)