Skip to content

Commit a2837a3

Browse files
committed
test(playwright): ensure tests run on a base path and custom port
1 parent 9b32151 commit a2837a3

File tree

1 file changed

+15
-27
lines changed

1 file changed

+15
-27
lines changed

tests/navigation.browser.ts

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,13 @@ import { test } from "@playwright/test";
22

33
import { login } from "./login";
44

5-
const { BASE_URL, BASE_PATH = "" } = process.env;
6-
7-
test.describe("home page", () => {
8-
test("loads", async ({ baseURL, page }) => {
9-
await page.goto(baseURL + "/");
10-
await page.getByRole("heading", { name: "Documentation" }).waitFor();
11-
});
5+
test("loads", async ({ baseURL, page }) => {
6+
await page.goto(baseURL as string);
7+
await page.getByRole("heading", { name: "Documentation" }).waitFor();
128
});
139

14-
test("do login via results page", async ({ page }) => {
15-
const baseURL = "" + BASE_URL + BASE_PATH;
16-
17-
await page.goto(baseURL);
10+
test("do login via results page", async ({ page, baseURL }) => {
11+
await page.goto(baseURL as string);
1812
await page
1913
.getByRole("navigation", { name: "Main" })
2014
.getByRole("link", { name: "Results" })
@@ -24,14 +18,12 @@ test("do login via results page", async ({ page }) => {
2418
await login(page);
2519

2620
// We should return to the page we clicked on
27-
await page.waitForURL(BASE_URL + "/results");
21+
await page.waitForURL("**/results");
2822
await page.locator("label").filter({ hasText: "Filter Results" }).waitFor();
2923
});
3024

31-
test("do login via datasets page", async ({ page }) => {
32-
const baseURL = "" + BASE_URL + BASE_PATH;
33-
34-
await page.goto(baseURL);
25+
test("do login via datasets page", async ({ page, baseURL }) => {
26+
await page.goto(baseURL as string);
3527
await page
3628
.getByRole("navigation", { name: "Main" })
3729
.getByRole("link", { name: "Datasets" })
@@ -41,14 +33,12 @@ test("do login via datasets page", async ({ page }) => {
4133
await login(page);
4234

4335
// We should return to the page we clicked on
44-
await page.waitForURL(BASE_URL + "/datasets");
36+
await page.waitForURL("**/datasets");
4537
await page.getByRole("heading", { name: "Datasets" }).waitFor();
4638
});
4739

48-
test("do login via executions page", async ({ page }) => {
49-
const baseURL = "" + BASE_URL + BASE_PATH;
50-
51-
await page.goto(baseURL);
40+
test("do login via executions page", async ({ page, baseURL }) => {
41+
await page.goto(baseURL as string);
5242
await page
5343
.getByRole("navigation", { name: "Main" })
5444
.getByRole("link", { name: "Executions" })
@@ -58,14 +48,12 @@ test("do login via executions page", async ({ page }) => {
5848
await login(page);
5949

6050
// We should return to the page we clicked on
61-
await page.waitForURL(BASE_URL + "/executions");
51+
await page.waitForURL("**/executions");
6252
await page.locator("label").filter({ hasText: "Filter Executions" }).waitFor();
6353
});
6454

65-
test("do login via project page", async ({ page }) => {
66-
const baseURL = "" + BASE_URL + BASE_PATH;
67-
68-
await page.goto(baseURL);
55+
test("do login via project page", async ({ page, baseURL }) => {
56+
await page.goto(baseURL as string);
6957
await page
7058
.getByRole("navigation", { name: "Main" })
7159
.getByRole("link", { name: "Project" })
@@ -75,6 +63,6 @@ test("do login via project page", async ({ page }) => {
7563
await login(page);
7664

7765
// We should return to the page we clicked on
78-
await page.waitForURL(BASE_URL + "/project");
66+
await page.waitForURL("**/project");
7967
await page.getByRole("heading", { name: "Select a project to view" }).waitFor();
8068
});

0 commit comments

Comments
 (0)