From 075dc8bb5fe0370f4ac8ca35163cac974ec5f257 Mon Sep 17 00:00:00 2001 From: Vikrant Gupta Date: Thu, 23 Nov 2023 02:03:10 +0530 Subject: [PATCH 1/3] feat: added auth as pre-requisite for the other tests --- .gitignore | 3 ++- e2e/playwright.config.ts | 13 +++++++++++++ e2e/tests/{login.spec.ts => auth.setup.ts} | 4 ++++ e2e/tests/navigation.spec.ts | 8 ++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) rename e2e/tests/{login.spec.ts => auth.setup.ts} (90%) create mode 100644 e2e/tests/navigation.spec.ts diff --git a/.gitignore b/.gitignore index 14176321bf7..3f1834e9fa1 100644 --- a/.gitignore +++ b/.gitignore @@ -60,4 +60,5 @@ e2e/node_modules/ e2e/test-results/ e2e/playwright-report/ e2e/blob-report/ -e2e/playwright/.cache/ \ No newline at end of file +e2e/playwright/.cache/ +e2e/.auth \ No newline at end of file diff --git a/e2e/playwright.config.ts b/e2e/playwright.config.ts index f6a780717f3..b1a0f30a9f0 100644 --- a/e2e/playwright.config.ts +++ b/e2e/playwright.config.ts @@ -30,4 +30,17 @@ export default defineConfig({ baseURL: process.env.PLAYWRIGHT_TEST_BASE_URL || "https://stagingapp.signoz.io/", }, + + projects: [ + { name: "setup", testMatch: /.*\.setup\.ts/ }, + { + name: "chromium", + use: { + ...devices["Desktop Chrome"], + // Use prepared auth state. + storageState: ".auth/user.json", + }, + dependencies: ["setup"], + }, + ], }); diff --git a/e2e/tests/login.spec.ts b/e2e/tests/auth.setup.ts similarity index 90% rename from e2e/tests/login.spec.ts rename to e2e/tests/auth.setup.ts index 8bdd7754467..9ca817337f6 100644 --- a/e2e/tests/login.spec.ts +++ b/e2e/tests/auth.setup.ts @@ -4,6 +4,8 @@ import dotenv from "dotenv"; dotenv.config(); +const authFile = ".auth/user.json"; + test("E2E Login Test", async ({ page }) => { await Promise.all([page.goto("/"), page.waitForRequest("**/version")]); @@ -30,4 +32,6 @@ test("E2E Login Test", async ({ page }) => { await page.locator('button[data-attr="signup"]').click(); await expect(page).toHaveURL(ROUTES.APPLICATION); + + await page.context().storageState({ path: authFile }); }); diff --git a/e2e/tests/navigation.spec.ts b/e2e/tests/navigation.spec.ts new file mode 100644 index 00000000000..68acb229bd8 --- /dev/null +++ b/e2e/tests/navigation.spec.ts @@ -0,0 +1,8 @@ +import { test } from "@playwright/test"; +import ROUTES from "../../frontend/src/constants/routes"; + +test("Basic Navigation Check across different resources", async ({ page }) => { + await page.goto(ROUTES.APPLICATION); + + await page.pause(); +}); From e9dde3bedbf07ce3e32e954c2fc64c6f927413b2 Mon Sep 17 00:00:00 2001 From: Vikrant Gupta Date: Thu, 23 Nov 2023 02:25:50 +0530 Subject: [PATCH 2/3] feat: added navigation checks --- e2e/tests/contants.ts | 6 ++++++ e2e/tests/navigation.spec.ts | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 e2e/tests/contants.ts diff --git a/e2e/tests/contants.ts b/e2e/tests/contants.ts new file mode 100644 index 00000000000..9254bc5d557 --- /dev/null +++ b/e2e/tests/contants.ts @@ -0,0 +1,6 @@ +export const SERVICE_TABLE_HEADERS = { + APPLICATION: "Applicaton", + P99LATENCY: "P99 latency (in ms)", + ERROR_RATE: "Error Rate (% of total)", + OPS_PER_SECOND: "Operations Per Second", +}; diff --git a/e2e/tests/navigation.spec.ts b/e2e/tests/navigation.spec.ts index 68acb229bd8..6050292b32e 100644 --- a/e2e/tests/navigation.spec.ts +++ b/e2e/tests/navigation.spec.ts @@ -1,8 +1,20 @@ -import { test } from "@playwright/test"; +import { test, expect } from "@playwright/test"; import ROUTES from "../../frontend/src/constants/routes"; +import { SERVICE_TABLE_HEADERS } from "./contants"; test("Basic Navigation Check across different resources", async ({ page }) => { - await page.goto(ROUTES.APPLICATION); + await Promise.all([ + page.goto(ROUTES.APPLICATION), + page.waitForRequest("**/v1/services"), + ]); + + const p99Latency = page.locator( + `th:has-text("${SERVICE_TABLE_HEADERS.P99LATENCY}")` + ); + + await expect(p99Latency).toBeVisible(); + + await page.goto(ROUTES.TRACES_EXPLORER); await page.pause(); }); From ea3b471112f8de4d1efb8863ac67ed3360bdb88a Mon Sep 17 00:00:00 2001 From: Vikrant Gupta Date: Thu, 23 Nov 2023 02:38:59 +0530 Subject: [PATCH 3/3] feat: added navigation checks --- e2e/tests/contants.ts | 4 ++++ e2e/tests/navigation.spec.ts | 24 ++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/e2e/tests/contants.ts b/e2e/tests/contants.ts index 9254bc5d557..e44f7617f6a 100644 --- a/e2e/tests/contants.ts +++ b/e2e/tests/contants.ts @@ -4,3 +4,7 @@ export const SERVICE_TABLE_HEADERS = { ERROR_RATE: "Error Rate (% of total)", OPS_PER_SECOND: "Operations Per Second", }; + +export const DATA_TEST_IDS = { + NEW_DASHBOARD_BTN: "create-new-dashboard", +}; diff --git a/e2e/tests/navigation.spec.ts b/e2e/tests/navigation.spec.ts index 6050292b32e..6f30b2f5d6a 100644 --- a/e2e/tests/navigation.spec.ts +++ b/e2e/tests/navigation.spec.ts @@ -1,8 +1,9 @@ import { test, expect } from "@playwright/test"; import ROUTES from "../../frontend/src/constants/routes"; -import { SERVICE_TABLE_HEADERS } from "./contants"; +import { DATA_TEST_IDS, SERVICE_TABLE_HEADERS } from "./contants"; test("Basic Navigation Check across different resources", async ({ page }) => { + // route to services page and check if the page renders fine with BE contract await Promise.all([ page.goto(ROUTES.APPLICATION), page.waitForRequest("**/v1/services"), @@ -14,7 +15,26 @@ test("Basic Navigation Check across different resources", async ({ page }) => { await expect(p99Latency).toBeVisible(); + // route to the new trace explorer page and check if the page renders fine await page.goto(ROUTES.TRACES_EXPLORER); - await page.pause(); + await page.waitForLoadState("networkidle"); + + const listViewTable = await page + .locator('div[role="presentation"]') + .isVisible(); + + expect(listViewTable).toBeTruthy(); + + // route to the dashboards page and check if the page renders fine + await Promise.all([ + page.goto(ROUTES.ALL_DASHBOARD), + page.waitForRequest("**/v1/dashboards"), + ]); + + const newDashboardBtn = await page + .locator(`data-testid=${DATA_TEST_IDS.NEW_DASHBOARD_BTN}`) + .isVisible(); + + expect(newDashboardBtn).toBeTruthy(); });