|
1 | | -import {expect, test} from "@playwright/test"; |
| 1 | +import {expect, Page, test} from "@playwright/test"; |
2 | 2 | import {appendQueryParams, goToNewPad} from "../helper/padHelper"; |
3 | 3 |
|
4 | 4 | test.beforeEach(async ({page}) => { |
@@ -26,19 +26,26 @@ test.describe('showMenuRight URL parameter', function () { |
26 | 26 | await expect(page.locator('#editbar .menu_right')).toBeVisible(); |
27 | 27 | }); |
28 | 28 |
|
29 | | - test('readonly pad hides .menu_right by default', async function ({page}) { |
30 | | - // Find the share link which exposes the readonly r.* id, then navigate. |
| 29 | + // Helper: open the Share popup, flip it to read-only, read the r.* URL |
| 30 | + // back out of #linkinput. The readonly toggle is a checkbox |
| 31 | + // (`#readonlyinput`) that rewrites #linkinput's value live. |
| 32 | + const getReadonlyUrl = async (page: Page) => { |
31 | 33 | await page.locator('.buttonicon-embed').click(); |
32 | | - const readonlyUrl = await page.locator('#readonlyInput').inputValue(); |
33 | | - expect(readonlyUrl).toMatch(/\/p\/r\./); |
| 34 | + await page.locator('#readonlyinput').check(); |
| 35 | + const url = await page.locator('#linkinput').inputValue(); |
| 36 | + expect(url).toMatch(/\/p\/r\./); |
| 37 | + return url; |
| 38 | + }; |
| 39 | + |
| 40 | + test('readonly pad hides .menu_right by default', async function ({page}) { |
| 41 | + const readonlyUrl = await getReadonlyUrl(page); |
34 | 42 | await page.goto(readonlyUrl); |
35 | 43 | await page.waitForSelector('#editorcontainer.initialized'); |
36 | 44 | await expect(page.locator('#editbar .menu_right')).toBeHidden(); |
37 | 45 | }); |
38 | 46 |
|
39 | 47 | test('readonly pad with showMenuRight=true keeps the menu visible', async function ({page}) { |
40 | | - await page.locator('.buttonicon-embed').click(); |
41 | | - const readonlyUrl = await page.locator('#readonlyInput').inputValue(); |
| 48 | + const readonlyUrl = await getReadonlyUrl(page); |
42 | 49 | await page.goto(`${readonlyUrl}?showMenuRight=true`); |
43 | 50 | await page.waitForSelector('#editorcontainer.initialized'); |
44 | 51 | await expect(page.locator('#editbar .menu_right')).toBeVisible(); |
|
0 commit comments