Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: added auth as pre-requisite for the other tests #4031

Merged
merged 4 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ e2e/node_modules/
e2e/test-results/
e2e/playwright-report/
e2e/blob-report/
e2e/playwright/.cache/
e2e/playwright/.cache/
e2e/.auth
13 changes: 13 additions & 0 deletions e2e/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
},
],
});
4 changes: 4 additions & 0 deletions e2e/tests/#.spec.ts → e2e/tests/auth.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")]);

Expand All @@ -30,4 +32,6 @@ test("E2E Login Test", async ({ page }) => {
await page.locator('button[data-attr="#"]').click();

await expect(page).toHaveURL(ROUTES.APPLICATION);

await page.context().storageState({ path: authFile });
});
10 changes: 10 additions & 0 deletions e2e/tests/contants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const SERVICE_TABLE_HEADERS = {
APPLICATION: "Applicaton",
P99LATENCY: "P99 latency (in ms)",
ERROR_RATE: "Error Rate (% of total)",
OPS_PER_SECOND: "Operations Per Second",
};

export const DATA_TEST_IDS = {
NEW_DASHBOARD_BTN: "create-new-dashboard",
};
40 changes: 40 additions & 0 deletions e2e/tests/navigation.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { test, expect } from "@playwright/test";
import ROUTES from "../../frontend/src/constants/routes";
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"),
]);

const p99Latency = page.locator(
`th:has-text("${SERVICE_TABLE_HEADERS.P99LATENCY}")`
);

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.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();
});