Skip to content

Commit 6907751

Browse files
committed
4565: Test adjustments
1 parent 4d55a07 commit 6907751

File tree

7 files changed

+121
-94
lines changed

7 files changed

+121
-94
lines changed

assets/tests/admin/admin-app.spec.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

assets/tests/admin/admin-campaign.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { test, expect } from "@playwright/test";
22
import { loginTest } from "./admin-helper.js";
3-
import { emptySlidesJson, slidesJson1 } from "./data-fixtures.js";
3+
import { emptyJson, slidesJson1 } from "./data-fixtures.js";
44

55
test.describe("Campaign pages work", () => {
66
test.beforeEach(async ({ page }) => {
77
await loginTest({ page });
88

99
await page.route("**/playlists*", async (route) => {
10-
await route.fulfill({ json: emptySlidesJson });
10+
await route.fulfill({ json: emptyJson });
1111
});
1212

1313
await page.locator(".sidebar-nav .nav-link").getByText("Kampagner").click();

assets/tests/admin/admin-feed-sources.spec.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,18 @@ import {
44
feedSourcesJson,
55
feedSourcesJson2,
66
feedSourcesJson3,
7-
tokenJson,
87
} from "./data-fixtures.js";
8+
import { loginTest } from "./admin-helper.js";
99

1010
test.describe("feed sources", () => {
1111
test.beforeEach(async ({ page }) => {
12-
await page.goto("/admin/feed-sources/list");
13-
14-
// Abort all routes that are not registered.
15-
await page.route("**/*", async (route) => {
16-
await route.abort();
17-
});
12+
await loginTest({ page });
1813

1914
await page.route("**/feed-sources*", async (route) => {
2015
await route.fulfill({ json: feedSourcesJson });
2116
});
22-
await page.route("**/token", async (route) => {
23-
await route.fulfill({ json: tokenJson });
24-
});
2517

26-
await expect(page).toHaveTitle(/OS2Display Admin/);
27-
await page.getByLabel("Email").fill("admin@example.com");
28-
await page.getByLabel("Kodeord").fill("password");
29-
await page.locator("#login").click();
18+
await page.locator(".sidebar-nav .nav-link").getByText("Datakilder").click();
3019
await expect(page.locator("h1").getByText("Datakilder")).toBeVisible();
3120
});
3221

assets/tests/admin/admin-helper.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import {
2-
emptySlidesJson,
2+
accessConfigJson,
3+
emptyJson,
34
feedSourcesJson,
4-
tokenJson,
5+
tokenJson
56
} from "./data-fixtures.js";
67
import { expect } from "@playwright/test";
78

@@ -17,8 +18,12 @@ const loginTest = async ({ page }) => {
1718
await route.fulfill({ json: tokenJson });
1819
});
1920

21+
await page.route('**/access-config.json*', async (route) => {
22+
await route.fulfill({ json: accessConfigJson});
23+
})
24+
2025
await page.route("**/slides*", async (route) => {
21-
await route.fulfill({ json: emptySlidesJson });
26+
await route.fulfill({ json: emptyJson });
2227
});
2328

2429
await expect(page).toHaveTitle(/OS2Display Admin/);

assets/tests/admin/admin-login.spec.js

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
import { test, expect } from "@playwright/test";
2+
import { accessConfigJson, emptyJson } from "./data-fixtures.js";
23

34
test.describe("Login works", () => {
5+
test.beforeEach(async ({ page }) => {
6+
await page.route("**/access-config.json", async (route) => {
7+
await route.fulfill({ json: accessConfigJson });
8+
});
9+
});
10+
411
test("Login one tenant works", async ({ page }) => {
12+
await page.route("**/playlists*", async (route) => {
13+
await route.fulfill({ json: emptyJson });
14+
});
15+
516
await page.route("**/token", async (route) => {
617
const json = {
718
token: "1",
@@ -11,13 +22,13 @@ test.describe("Login works", () => {
1122
tenantKey: "ABC",
1223
title: "ABC Tenant",
1324
description: "Description",
14-
roles: ["ROLE_ADMIN"],
15-
},
25+
roles: ["ROLE_ADMIN"]
26+
}
1627
],
1728
user: {
1829
fullname: "John Doe",
19-
email: "johndoe@example.com",
20-
},
30+
email: "johndoe@example.com"
31+
}
2132
};
2233
await route.fulfill({ json });
2334
});
@@ -37,25 +48,25 @@ test.describe("Login works", () => {
3748
tenantKey: "ABC",
3849
title: "ABC Tenant",
3950
description: "Nulla quam ipsam voluptatem cupiditate.",
40-
roles: ["ROLE_ADMIN"],
51+
roles: ["ROLE_ADMIN"]
4152
},
4253
{
4354
tenantKey: "DEF",
4455
title: "DEF Tenant",
4556
description: "Inventore sed libero et.",
46-
roles: ["ROLE_ADMIN"],
57+
roles: ["ROLE_ADMIN"]
4758
},
4859
{
4960
tenantKey: "XYZ",
5061
title: "XYC Tenant",
5162
description: "Itaque quibusdam tempora velit porro ut velit.",
52-
roles: ["ROLE_ADMIN"],
53-
},
63+
roles: ["ROLE_ADMIN"]
64+
}
5465
],
5566
user: {
5667
fullname: "John Doe",
57-
email: "johndoe@example.com",
58-
},
68+
email: "johndoe@example.com"
69+
}
5970
};
6071
await route.fulfill({ json });
6172
});
@@ -76,13 +87,13 @@ test.describe("Login works", () => {
7687
tenantKey: "ABC",
7788
title: "ABC Tenant",
7889
description: "Description",
79-
roles: ["ROLE_EDITOR"],
80-
},
90+
roles: ["ROLE_EDITOR"]
91+
}
8192
],
8293
user: {
8394
fullname: "John Doe",
84-
email: "johndoe@example.com",
85-
},
95+
email: "johndoe@example.com"
96+
}
8697
};
8798
await route.fulfill({ json });
8899
});
@@ -91,13 +102,13 @@ test.describe("Login works", () => {
91102
await page.locator("#login").click();
92103
await expect(page.locator(".name")).toHaveText("John Doe");
93104
await expect(page.locator(".sidebar-nav").locator(".nav-item")).toHaveCount(
94-
4,
105+
4
95106
);
96107
});
97108

98109
test("Role editor should not be able to visit restricted route", async ({
99-
page,
100-
}) => {
110+
page
111+
}) => {
101112
await page.goto("/admin/playlist/list");
102113
await page.route("**/token", async (route) => {
103114
const json = {
@@ -108,20 +119,20 @@ test.describe("Login works", () => {
108119
tenantKey: "ABC",
109120
title: "ABC Tenant",
110121
description: "Description",
111-
roles: ["ROLE_EDITOR"],
112-
},
122+
roles: ["ROLE_EDITOR"]
123+
}
113124
],
114125
user: {
115126
fullname: "John Doe",
116-
email: "johndoe@example.com",
117-
},
127+
email: "johndoe@example.com"
128+
}
118129
};
119130
await route.fulfill({ json });
120131
});
121132
await page.goto("/admin/shared/list");
122133
await page.locator("#login").click();
123134
await expect(page.locator("main").locator("div")).toHaveText(
124-
"Du har ikke adgang til denne side",
135+
"Du har ikke adgang til denne side"
125136
);
126137
});
127138
});

assets/tests/admin/admin-top-bar.spec.js

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,97 @@
11
import { test, expect } from "@playwright/test";
2+
import { loginTest } from "./admin-helper.js";
3+
import { emptyJson } from "./data-fixtures.js";
24

35
test.describe("Nav items loads", () => {
46
test.beforeEach(async ({ page }) => {
5-
await page.goto("/admin/screen/create");
6-
await page.route("**/token", async (route) => {
7-
const json = {
8-
token: "1",
9-
refresh_token: "2",
10-
tenants: [
11-
{
12-
tenantKey: "ABC",
13-
title: "ABC Tenant",
14-
description: "Description",
15-
roles: ["ROLE_ADMIN"],
16-
},
17-
],
18-
user: {
19-
fullname: "John Doe",
20-
email: "johndoe@example.com",
21-
},
22-
};
23-
await route.fulfill({ json });
24-
});
25-
await page.route("**/layouts*", async (route) => {
26-
const json = {
27-
"@id": "/v2/layouts",
28-
"hydra:member": [],
29-
};
30-
await route.fulfill({ json });
31-
});
32-
await expect(page).toHaveTitle(/OS2Display Admin/);
33-
await page.getByLabel("Email").fill("johndoe@example.com");
34-
await page.getByLabel("Kodeord").fill("password");
35-
await page.locator("#login").click();
36-
await expect(page.locator("h1").getByText("Opret ny skærm")).toBeVisible();
7+
await loginTest({ page });
378
});
389

3910
test("It loads", async ({ page }) => {
4011
await expect(page.locator("nav")).toBeVisible();
4112
});
4213

4314
test("It navigates to slides list", async ({ page }) => {
15+
await page.route("**/media*", async (route) => {
16+
await route.fulfill({ json: emptyJson });
17+
});
18+
19+
// Go to media page first, since Slide is the starting page, to allow for link click.
20+
await page.getByRole("link", { name: "Medier" }).click();
21+
4422
await page.getByRole("link", { name: "Slides" }).click();
4523
await expect(page.locator("h1")).toHaveText("Slides");
4624
});
4725

4826
test("It navigates to media list", async ({ page }) => {
27+
await page.route("**/media*", async (route) => {
28+
await route.fulfill({ json: emptyJson });
29+
});
30+
4931
await page.getByRole("link", { name: "Medier" }).click();
5032
await expect(page.locator("h1")).toHaveText("Medier");
5133
});
5234

5335
test("It navigates to screens list", async ({ page }) => {
36+
await page.route("**/screens*", async (route) => {
37+
await route.fulfill({ json: emptyJson });
38+
});
5439
await page.getByRole("link", { name: "Skærme" }).click();
5540
await expect(page.locator("h1")).toHaveText("Skærme");
5641
});
5742

5843
test("It navigates to groups list", async ({ page }) => {
44+
await page.route("**/screen-groups*", async (route) => {
45+
await route.fulfill({ json: emptyJson });
46+
});
47+
5948
await page.getByRole("link", { name: "Grupper" }).click();
6049
await expect(page.locator("h1")).toHaveText("Grupper");
6150
});
6251

6352
test("It navigates to playlists list", async ({ page }) => {
53+
await page.route("**/playlists*", async (route) => {
54+
await route.fulfill({ json: emptyJson });
55+
});
56+
6457
await page.getByRole("link", { name: "Spillelister", exact: true }).click();
6558
await expect(page.locator("h1")).toHaveText("Spillelister");
6659
});
6760

6861
test("It navigates to themes list", async ({ page }) => {
62+
await page.route("**/themes*", async (route) => {
63+
await route.fulfill({ json: emptyJson });
64+
});
65+
6966
await page.getByRole("link", { name: "Temaer" }).click();
7067
await expect(page.locator("h1")).toHaveText("Temaer");
7168
});
7269

73-
test.skip("It navigates to create slide", async ({ page }) => {
74-
await page.goto("/admin/screen/create");
75-
await page.getByRole("button", { name: "Tilføj" }).click();
76-
await page.getByRole("link", { name: "Nyt slide", exact: true }).click();
77-
await expect(page.locator("h1")).toHaveText("Opret nyt slide");
70+
test("It navigates to create slide", async ({ page }) => {
71+
await page.route("**/playlists*", async (route) => {
72+
await route.fulfill({ json: emptyJson });
73+
});
74+
await page.route("**/themes*", async (route) => {
75+
await route.fulfill({ json: emptyJson });
76+
});
77+
await page.route("**/templates*", async (route) => {
78+
await route.fulfill({ json: emptyJson });
79+
});
80+
81+
await page.getByLabel("Tilføj nyt slide").first().click();
82+
await expect(page.locator("h1")).toHaveText("Opret nyt slide:");
7883
});
7984

80-
test.skip("It navigates to create playlist", async ({ page }) => {
81-
await page.getByRole("button", { name: "Tilføj" }).click();
82-
await page.getByRole("link", { name: "Ny spilleliste" }).click();
83-
await expect(page.locator("h1")).toHaveText("Opret nyt spilleliste");
85+
test("It navigates to create playlist", async ({ page }) => {
86+
await page.route("**/tenants*", async (route) => {
87+
await route.fulfill({ json: emptyJson });
88+
});
89+
await page.getByLabel("Tilføj ny spilleliste").first().click();
90+
await expect(page.locator("h1")).toHaveText("Opret ny spilleliste:");
8491
});
8592

86-
test.skip("It navigates to create screen", async ({ page }) => {
87-
await page.getByRole("button", { name: "Tilføj" }).click();
88-
await page.getByRole("link", { name: "Ny skærm" }).click();
93+
test("It navigates to create screen", async ({ page }) => {
94+
await page.getByLabel("Tilføj ny skærm").first().click();
8995
await expect(page.locator("h1")).toHaveText("Opret ny skærm");
9096
});
9197

0 commit comments

Comments
 (0)