Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
integration-test: Create authentication setup
Elian Dorana98f01d92414
diff --git a/.gitignore b/.gitignoreindex 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 filediff --git a/integration-tests/auth.setup.ts b/integration-tests/auth.setup.tsnew file mode 100644index 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 filediff --git a/integration-tests/example.spec.ts b/integration-tests/example.disabled.tssimilarity index 100%rename from integration-tests/example.spec.tsrename to integration-tests/example.disabled.tsdiff --git a/integration-tests/katex.spec.ts b/integration-tests/katex.disabled.tssimilarity index 67%rename from integration-tests/katex.spec.tsrename to integration-tests/katex.disabled.tsindex 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.tsnew file mode 100644index 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 filediff --git a/playwright.config.ts b/playwright.config.tsindex 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. */