Skip to content

Commit 8bdc736

Browse files
committed
4565: Fixed playlist and media tests
1 parent 9cf6d76 commit 8bdc736

File tree

7 files changed

+198
-282
lines changed

7 files changed

+198
-282
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test, expect } from "@playwright/test";
2-
import { awaitDataRoute, awaitEmptyRoutes, beforeEachTest, loginTest } from "./test-helper.js";
2+
import { fulfillDataRoute, fulfillEmptyRoutes, beforeEachTest, loginTest } from "./test-helper.js";
33
import { slidesJson1 } from "./data-fixtures.js";
44

55
test.describe("Campaign pages work", () => {
@@ -10,7 +10,7 @@ test.describe("Campaign pages work", () => {
1010
test.beforeEach(async ({ page }) => {
1111
await loginTest({ page });
1212

13-
await awaitEmptyRoutes(page, ["**/playlists*", "**/screens*", "**/screen-groups*"]);
13+
await fulfillEmptyRoutes(page, ["**/playlists*", "**/screens*", "**/screen-groups*"]);
1414

1515
await page.locator(".sidebar-nav .nav-link").getByText("Kampagner").click();
1616
await expect(page.locator("h1").getByText("Kampagner")).toBeVisible();
@@ -25,7 +25,7 @@ test.describe("Campaign pages work", () => {
2525

2626
test("It removes slide", async ({ page }) => {
2727
// Intercept slides in dropdown
28-
await awaitDataRoute(page, "**/slides*", slidesJson1);
28+
await fulfillDataRoute(page, "**/slides*", slidesJson1);
2929

3030
// Pick slide
3131
await page

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
feedSourcesJson2,
66
feedSourceSingleJson
77
} from "./data-fixtures.js";
8-
import { awaitDataRoute, awaitEmptyRoutes, beforeEachTest, loginTest } from "./test-helper.js";
8+
import { fulfillDataRoute, fulfillEmptyRoutes, beforeEachTest, loginTest } from "./test-helper.js";
99

1010
test.describe("feed sources", () => {
1111
test.beforeEach(async ({ page }) => {
@@ -15,14 +15,14 @@ test.describe("feed sources", () => {
1515
test.beforeEach(async ({ page }) => {
1616
await loginTest({ page });
1717

18-
await awaitDataRoute(page, "**/feed-sources*", feedSourcesJson);
18+
await fulfillDataRoute(page, "**/feed-sources*", feedSourcesJson);
1919

2020
await page
2121
.locator(".sidebar-nav .nav-link")
2222
.getByText("Datakilder")
2323
.click();
2424

25-
await awaitEmptyRoutes(page, ["**/slides*"]);
25+
await fulfillEmptyRoutes(page, ["**/slides*"]);
2626

2727
await expect(page.locator("h1").getByText("Datakilder")).toBeVisible();
2828
});
@@ -33,7 +33,7 @@ test.describe("feed sources", () => {
3333
});
3434

3535
test("It display error toast on save error", async ({ page }) => {
36-
await awaitDataRoute(page, "**/feed-sources*", errorJson, 500);
36+
await fulfillDataRoute(page, "**/feed-sources*", errorJson, 500);
3737

3838
await page.getByText("Opret ny datakilde").click();
3939

@@ -71,8 +71,8 @@ test.describe("feed sources", () => {
7171
test("It goes to edit", async ({ page }) => {
7272
await expect(page.locator("#feed-sourceTitle")).not.toBeVisible();
7373

74-
await awaitDataRoute(page, "**/feed-sources*", feedSourcesJson2);
75-
await awaitDataRoute(page, "**/feed-sources/01JBBP48CS9CV80XRWRP8CAETJ", feedSourceSingleJson);
74+
await fulfillDataRoute(page, "**/feed-sources*", feedSourcesJson2);
75+
await fulfillDataRoute(page, "**/feed-sources/01JBBP48CS9CV80XRWRP8CAETJ", feedSourceSingleJson);
7676

7777
await page.locator("tbody").locator("tr td a").first().click();
7878
await expect(page.locator("#feed-sourceTitle")).toBeVisible();

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
adminConfigJson,
55
emptyJson, tokenAdminJson, tokenEditorJson, tokenTenantsJson
66
} from "./data-fixtures.js";
7-
import { awaitDataRoute, awaitEmptyRoutes, beforeEachTest } from "./test-helper.js";
7+
import { fulfillDataRoute, fulfillEmptyRoutes, beforeEachTest } from "./test-helper.js";
88

99
test.describe("Login works", () => {
1010
test.beforeEach(async ({ page }) => {
@@ -20,9 +20,9 @@ test.describe("Login works", () => {
2020
test("Login one tenant works", async ({ page }) => {
2121
await page.goto("/admin/playlists/list");
2222

23-
await awaitEmptyRoutes(page, ['"**/playlists*"']);
23+
await fulfillEmptyRoutes(page, ['"**/playlists*"']);
2424

25-
await awaitDataRoute(page, "**/token", tokenAdminJson);
25+
await fulfillDataRoute(page, "**/token", tokenAdminJson);
2626

2727
await page.locator("#login").click();
2828
await expect(page.locator(".name")).toHaveText("John Doe");
@@ -31,7 +31,7 @@ test.describe("Login works", () => {
3131
test("Login three tenant works", async ({ page }) => {
3232
await page.goto("/admin/group/list");
3333

34-
await awaitDataRoute(page, "**/token", tokenTenantsJson);
34+
await fulfillDataRoute(page, "**/token", tokenTenantsJson);
3535

3636
await page.locator("#login").click();
3737

@@ -42,7 +42,7 @@ test.describe("Login works", () => {
4242
test("Login with tenant that has role editor", async ({ page }) => {
4343
await page.goto("/admin/playlists/list");
4444

45-
await awaitDataRoute(page, "**/token", tokenEditorJson);
45+
await fulfillDataRoute(page, "**/token", tokenEditorJson);
4646
await page.locator("#login").click();
4747

4848
await expect(page.locator(".name")).toHaveText("John Doe");
@@ -56,7 +56,7 @@ test.describe("Login works", () => {
5656
}) => {
5757
await page.goto("/admin/shared/list");
5858

59-
await awaitDataRoute(page, "**/token", tokenEditorJson);
59+
await fulfillDataRoute(page, "**/token", tokenEditorJson);
6060
await page.locator("#login").click();
6161

6262
await expect(page.locator("main").locator("div")).toHaveText(

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

Lines changed: 6 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,18 @@
11
import { test, expect } from "@playwright/test";
2-
import { beforeEachTest } from "./test-helper.js";
2+
import { fulfillDataRoute, beforeEachTest, loginTest } from "./test-helper.js";
3+
import { mediaListJson } from "./data-fixtures.js";
34

45
test.describe("media list tests", () => {
56
test.beforeEach(async ({ page }) => {
67
await beforeEachTest(page);
78
});
89

910
test.beforeEach(async ({ page }) => {
10-
await page.goto("/admin/media/list");
11-
await page.route("**/media*", async (route) => {
12-
const json = {
13-
"@context": "/contexts/Media",
14-
"@id": "/v2/media",
15-
"@type": "hydra:Collection",
16-
"hydra:member": [
17-
{
18-
"@type": "Media",
19-
"@id": "/v2/media/001AG48FJC1NVA1EW20TSN13BP",
20-
title: "Laudantium aut exercitationem rerum itaque unde.",
21-
description:
22-
"Quia ut iusto dolores reiciendis animi. Magnam aut ut officiis quae. Nostrum magni et dolore dignissimos in totam qui et.",
23-
license: "Attribution-NonCommercial-NoDerivs License",
24-
created: "1971-06-13T05:21:39+01:00",
25-
modified: "2021-12-09T12:01:34+01:00",
26-
modifiedBy: "",
27-
createdBy: "",
28-
media: [],
29-
assets: {
30-
type: "image/jpeg",
31-
uri: "https://display.local.itkdev.dk/fixtures/template/images/mountain1.jpeg",
32-
dimensions: {
33-
height: 3456,
34-
width: 5184,
35-
},
36-
sha: "5a08dbb7fd3a074ed8659694c09cdb94fdb16cb1",
37-
size: 8945324,
38-
},
39-
},
40-
{
41-
"@type": "Media",
42-
"@id": "/v2/media/001AX5W2S909NW0K5A0NVE0NS6",
43-
title: "Ut eos illum quod.",
44-
description:
45-
"Et id est illum veniam eos quam placeat. Maxime ab aut aut fugit. Occaecati ut ea et occaecati repellendus amet. Quia consequuntur quod vel deserunt maiores.",
46-
license: "Attribution-NoDerivs License",
47-
created: "1971-06-18T06:59:58+01:00",
48-
modified: "2021-12-09T12:01:34+01:00",
49-
modifiedBy: "",
50-
createdBy: "",
51-
media: [],
52-
assets: {
53-
type: "image/jpeg",
54-
uri: "https://display.local.itkdev.dk/fixtures/template/images/mountain2.jpeg",
55-
dimensions: {
56-
height: 2592,
57-
width: 3888,
58-
},
59-
sha: "0654506b260c33544d39e5613716ef112ab38c7c",
60-
size: 4855058,
61-
},
62-
},
63-
],
64-
"hydra:totalItems": 100,
65-
};
66-
await route.fulfill({ json });
67-
});
68-
await page.route("**/token", async (route) => {
69-
const json = {
70-
token: "1",
71-
refresh_token: "2",
72-
tenants: [
73-
{
74-
tenantKey: "ABC",
75-
title: "ABC Tenant",
76-
description: "Description",
77-
roles: ["ROLE_ADMIN"],
78-
},
79-
],
80-
user: {
81-
fullname: "John Doe",
82-
email: "johndoe@example.com",
83-
},
84-
};
85-
await route.fulfill({ json });
86-
});
11+
await loginTest({ page });
8712

88-
await expect(page).toHaveTitle(/OS2Display Admin/);
89-
await page.getByLabel("Email").fill("johndoe@example.com");
90-
await page.getByLabel("Kodeord").fill("password");
91-
await page.locator("#login").click();
92-
await expect(page.locator("h1").getByText("Medier")).toBeVisible();
13+
await fulfillDataRoute(page, "**/media*", mediaListJson);
14+
15+
await page.locator(".sidebar-nav .nav-link").getByText("Medier").click();
9316
});
9417

9518
test("It loads media list", async ({ page }) => {

0 commit comments

Comments
 (0)