|
1 | 1 | 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"; |
3 | 4 |
|
4 | 5 | test.describe("media list tests", () => { |
5 | 6 | test.beforeEach(async ({ page }) => { |
6 | 7 | await beforeEachTest(page); |
7 | 8 | }); |
8 | 9 |
|
9 | 10 | 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 }); |
87 | 12 |
|
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(); |
93 | 16 | }); |
94 | 17 |
|
95 | 18 | test("It loads media list", async ({ page }) => { |
|
0 commit comments