|
11 | 11 | */
|
12 | 12 | import { test, expect } from '@playwright/test';
|
13 | 13 | import ENV from '../utils/env.js';
|
14 |
| -import { getTestResourceAge } from '../utils/page.js'; |
| 14 | +import { getTestPageURL, getTestResourceAge } from '../utils/page.js'; |
15 | 15 |
|
16 | 16 | // Files are deleted after 2 hours by default
|
17 | 17 | const MIN_HOURS = process.env.PW_DELETE_HOURS ? Number(process.env.PW_DELETE_HOURS) : 2;
|
@@ -81,3 +81,46 @@ test('Delete multiple old pages', async ({ page }, workerInfo) => {
|
81 | 81 | // Wait for the delete button to disappear which is when we're done
|
82 | 82 | await expect(page.getByRole('button', { name: 'Delete' })).not.toBeVisible({ timeout: 600000 });
|
83 | 83 | });
|
| 84 | + |
| 85 | +test('Empty out open editors on deleted documents', async ({ browser, page }, workerInfo) => { |
| 86 | + test.setTimeout(30000); |
| 87 | + |
| 88 | + const url = getTestPageURL('delete', workerInfo); |
| 89 | + const pageName = url.split('/').pop(); |
| 90 | + |
| 91 | + await page.goto(url); |
| 92 | + await expect(page.locator('div.ProseMirror')).toBeVisible(); |
| 93 | + |
| 94 | + const enteredText = `Some content entered at ${new Date()}`; |
| 95 | + await page.locator('div.ProseMirror').fill(enteredText); |
| 96 | + |
| 97 | + // Create a second window on the same document |
| 98 | + const page2 = await browser.newPage(); |
| 99 | + await page2.goto(url); |
| 100 | + await page2.waitForTimeout(3000); |
| 101 | + await expect(page2.locator('div.ProseMirror')).toContainText(enteredText); |
| 102 | + |
| 103 | + // Close the first window |
| 104 | + await page.close(); |
| 105 | + |
| 106 | + const list = await browser.newPage(); |
| 107 | + await list.goto(`${ENV}/#/da-sites/da-status/tests`); |
| 108 | + |
| 109 | + await list.waitForTimeout(3000); |
| 110 | + await list.reload(); |
| 111 | + |
| 112 | + // Now delete the document |
| 113 | + await expect(list.locator(`a[href="/edit#/da-sites/da-status/tests/${pageName}"]`)).toBeVisible(); |
| 114 | + await list.locator(`a[href="/edit#/da-sites/da-status/tests/${pageName}"]`).focus(); |
| 115 | + // Note this currently does not work on webkit as the checkbox isn't keyboard focusable there |
| 116 | + await list.keyboard.press('Shift+Tab'); |
| 117 | + await list.keyboard.press(' '); |
| 118 | + await list.waitForTimeout(500); |
| 119 | + await list.locator('button.delete-button').locator('visible=true').click(); |
| 120 | + |
| 121 | + // Give the second window a chance to update itself |
| 122 | + await list.waitForTimeout(3000); |
| 123 | + |
| 124 | + // The open window should be cleared out now |
| 125 | + await expect(page2.locator('div.ProseMirror')).not.toContainText(enteredText); |
| 126 | +}); |
0 commit comments