Skip to content

Build your personal knowledge base with Trilium Notes

integration-test: Create authentication setup

Elian Dorana98f01d92414
diff --git a/.gitignore b/.gitignore
index a56c971826..7d012a3544 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,3 +25,4 @@ images/app-icons/mac/*.png
/playwright-report/
/blob-report/
/playwright/.cache/
+/playwright/.auth/
\ No newline at end of file
diff --git a/integration-tests/auth.setup.ts b/integration-tests/auth.setup.ts
new file mode 100644
index 0000000000..ba2670006e
--- /dev/null
+++ b/integration-tests/auth.setup.ts
@@ -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 });
+});
\ No newline at end of file
diff --git a/integration-tests/example.spec.ts b/integration-tests/example.disabled.ts
similarity index 100%
rename from integration-tests/example.spec.ts
rename to integration-tests/example.disabled.ts
diff --git a/integration-tests/katex.spec.ts b/integration-tests/katex.disabled.ts
similarity index 67%
rename from integration-tests/katex.spec.ts
rename to integration-tests/katex.disabled.ts
index 1b6be60a59..c1ce0d9d7c 100644
--- a/integration-tests/katex.spec.ts
+++ b/integration-tests/katex.disabled.ts
@@ -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();
diff --git a/integration-tests/update_check.spec.ts b/integration-tests/update_check.spec.ts
new file mode 100644
index 0000000000..be0ee75b0c
--- /dev/null
+++ b/integration-tests/update_check.spec.ts
@@ -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");
+});
\ No newline at end of file
diff --git a/playwright.config.ts b/playwright.config.ts
index 10528c325c..12420d3a58 100644
--- a/playwright.config.ts
+++ b/playwright.config.ts
@@ -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. */