Skip to content

Commit f22b9da

Browse files
committed
5453: add tests of data fetch and fixtures, inject slides into loginTest
1 parent 5f16856 commit f22b9da

File tree

3 files changed

+1229
-3
lines changed

3 files changed

+1229
-3
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import { test, expect } from "@playwright/test";
2+
import {
3+
fulfillDataRoute,
4+
fulfillEmptyRoutes,
5+
beforeEachTest,
6+
loginTest,
7+
} from "./test-helper.js";
8+
import {
9+
imageTextTemplate,
10+
onlyImageTextListJson,
11+
slidesJson1,
12+
slideJson,
13+
slidesPlaylist,
14+
} from "./data-fixtures.js";
15+
16+
test.describe("Test of admin fetch data hook", () => {
17+
test.beforeEach(async ({ page }) => {
18+
await beforeEachTest(page);
19+
});
20+
21+
test.beforeEach(async ({ page }) => {
22+
page.setViewportSize({ width: 600, height: 2600 });
23+
await fulfillDataRoute(
24+
page,
25+
"**/templates?itemsPerPage*",
26+
onlyImageTextListJson,
27+
);
28+
29+
await page.route(
30+
"**/templates/000YR9PMQC0GMC1TP90V9N07WX",
31+
async (route) => {
32+
await route.fulfill(imageTextTemplate);
33+
},
34+
);
35+
36+
await fulfillDataRoute(
37+
page,
38+
"**/templates/01FGC8EXSE1KCC1PTR0NHB0H3R",
39+
imageTextTemplate,
40+
);
41+
42+
await fulfillDataRoute(
43+
page,
44+
"**/templates/002BAP34VD1EHG0E4J0D2Y00JW",
45+
imageTextTemplate,
46+
);
47+
48+
await fulfillDataRoute(
49+
page,
50+
"**/templates/017BG9P0E0103F0TFS17FM016M",
51+
imageTextTemplate,
52+
);
53+
54+
await fulfillDataRoute(
55+
page,
56+
"**/templates/016MHSNKCH1PQW1VY615JC19Y3",
57+
imageTextTemplate,
58+
);
59+
await fulfillDataRoute(
60+
page,
61+
"**/templates/000BGWFMBS15N807E60HP91JCX",
62+
imageTextTemplate,
63+
);
64+
65+
await loginTest(page, slidesJson1);
66+
67+
await fulfillDataRoute(
68+
page,
69+
"**/templates/01FP2SNGFN0BZQH03KCBXHKYHG",
70+
imageTextTemplate,
71+
);
72+
73+
await fulfillDataRoute(
74+
page,
75+
"**/v2/slides/00015Y0ZVC18N407JD07SM0YCF",
76+
slideJson,
77+
);
78+
79+
await fulfillEmptyRoutes(page, ["**/playlists*", "**/themes*"]);
80+
await fulfillDataRoute(
81+
page,
82+
"**/slides/00015Y0ZVC18N407JD07SM0YCF/playlists?*",
83+
slidesPlaylist,
84+
);
85+
86+
await Promise.all([
87+
page.waitForURL("**/slide/edit/*"),
88+
await page.locator("#edit_button").first().click({ force: true }),
89+
]);
90+
91+
const title = page.getByText("Rediger slide:");
92+
await title.waitFor();
93+
94+
await expect(title).toBeVisible();
95+
});
96+
97+
test("Test of admin fetch data hook", async ({ page }) => {
98+
const title = page.locator("#add-slide-to-playlist-section tr");
99+
// The max items per page is 30: https://github.com/os2display/display-api-service/blob/develop/config/packages/api_platform.yaml#L11
100+
// And the header is also a <tr
101+
await expect(title).toHaveCount(32);
102+
});
103+
});

0 commit comments

Comments
 (0)