Skip to content

Commit 5357ad4

Browse files
authored
Playwright test (#320)
Tests the fix for this issue: #292
1 parent a2e87bd commit 5357ad4

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

test/e2e/tests/delete.spec.js

+44-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
import { test, expect } from '@playwright/test';
1313
import ENV from '../utils/env.js';
14-
import { getTestResourceAge } from '../utils/page.js';
14+
import { getTestPageURL, getTestResourceAge } from '../utils/page.js';
1515

1616
// Files are deleted after 2 hours by default
1717
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) => {
8181
// Wait for the delete button to disappear which is when we're done
8282
await expect(page.getByRole('button', { name: 'Delete' })).not.toBeVisible({ timeout: 600000 });
8383
});
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

Comments
 (0)