|
1 | 1 | import { test, expect } from "@playwright/test"; |
2 | 2 | import { accessConfigJson, adminConfigJson, emptyJson } from "./data-fixtures.js"; |
| 3 | +import { abortUnhandledRoutes } from "./admin-helper.js"; |
3 | 4 |
|
4 | 5 | test.describe("Login works", () => { |
| 6 | + test.beforeEach(async ({ page }) => { |
| 7 | + await abortUnhandledRoutes(page); |
| 8 | + }); |
| 9 | + |
5 | 10 | test.beforeEach(async ({ page }) => { |
6 | 11 | await page.route("**/access-config.json", async (route) => { |
7 | 12 | await route.fulfill({ json: accessConfigJson }); |
8 | 13 | }); |
9 | 14 |
|
10 | | - await page.route('**/config/admin', async (route) => { |
| 15 | + await page.route("**/config/admin", async (route) => { |
11 | 16 | await route.fulfill({ json: adminConfigJson }); |
12 | | - }) |
| 17 | + }); |
13 | 18 | }); |
14 | 19 |
|
15 | 20 | test("Login one tenant works", async ({ page }) => { |
@@ -111,33 +116,32 @@ test.describe("Login works", () => { |
111 | 116 | ); |
112 | 117 | }); |
113 | 118 |
|
114 | | - test("Role editor should not be able to visit restricted route", async ({ |
115 | | - page |
116 | | - }) => { |
117 | | - await page.goto("/admin/playlist/list"); |
118 | | - await page.route("**/token", async (route) => { |
119 | | - const json = { |
120 | | - token: "1", |
121 | | - refresh_token: "2", |
122 | | - tenants: [ |
123 | | - { |
124 | | - tenantKey: "ABC", |
125 | | - title: "ABC Tenant", |
126 | | - description: "Description", |
127 | | - roles: ["ROLE_EDITOR"] |
| 119 | + test("Role editor should not be able to visit restricted route", |
| 120 | + async ({ page }) => { |
| 121 | + await page.goto("/admin/playlist/list"); |
| 122 | + await page.route("**/token", async (route) => { |
| 123 | + const json = { |
| 124 | + token: "1", |
| 125 | + refresh_token: "2", |
| 126 | + tenants: [ |
| 127 | + { |
| 128 | + tenantKey: "ABC", |
| 129 | + title: "ABC Tenant", |
| 130 | + description: "Description", |
| 131 | + roles: ["ROLE_EDITOR"] |
| 132 | + } |
| 133 | + ], |
| 134 | + user: { |
| 135 | + fullname: "John Doe", |
| 136 | + email: "johndoe@example.com" |
128 | 137 | } |
129 | | - ], |
130 | | - user: { |
131 | | - fullname: "John Doe", |
132 | | - email: "johndoe@example.com" |
133 | | - } |
134 | | - }; |
135 | | - await route.fulfill({ json }); |
| 138 | + }; |
| 139 | + await route.fulfill({ json }); |
| 140 | + }); |
| 141 | + await page.goto("/admin/shared/list"); |
| 142 | + await page.locator("#login").click(); |
| 143 | + await expect(page.locator("main").locator("div")).toHaveText( |
| 144 | + "Du har ikke adgang til denne side" |
| 145 | + ); |
136 | 146 | }); |
137 | | - await page.goto("/admin/shared/list"); |
138 | | - await page.locator("#login").click(); |
139 | | - await expect(page.locator("main").locator("div")).toHaveText( |
140 | | - "Du har ikke adgang til denne side" |
141 | | - ); |
142 | | - }); |
143 | 147 | }); |
0 commit comments