Skip to content

Commit

Permalink
Merge branch 'main' into acl
Browse files Browse the repository at this point in the history
  • Loading branch information
bosschaert committed Jan 7, 2025
2 parents 265aa8b + 5357ad4 commit 1d12837
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 27 deletions.
54 changes: 30 additions & 24 deletions test/e2e/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"keywords": ["test"],
"devDependencies": {
"@playwright/test": "^1.42.1",
"@types/node": "^20.11.27"
"@playwright/test": "^1.49.1",
"@types/node": "^22.10.2"
}
}
45 changes: 44 additions & 1 deletion test/e2e/tests/delete.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
import { test, expect } from '@playwright/test';
import ENV from '../utils/env.js';
import { getTestResourceAge } from '../utils/page.js';
import { getTestPageURL, getTestResourceAge } from '../utils/page.js';

// Files are deleted after 2 hours by default
const MIN_HOURS = process.env.PW_DELETE_HOURS ? Number(process.env.PW_DELETE_HOURS) : 2;
Expand Down Expand Up @@ -81,3 +81,46 @@ test('Delete multiple old pages', async ({ page }, workerInfo) => {
// Wait for the delete button to disappear which is when we're done
await expect(page.getByRole('button', { name: 'Delete' })).not.toBeVisible({ timeout: 600000 });
});

test('Empty out open editors on deleted documents', async ({ browser, page }, workerInfo) => {
test.setTimeout(30000);

const url = getTestPageURL('delete', workerInfo);
const pageName = url.split('/').pop();

await page.goto(url);
await expect(page.locator('div.ProseMirror')).toBeVisible();

const enteredText = `Some content entered at ${new Date()}`;
await page.locator('div.ProseMirror').fill(enteredText);

// Create a second window on the same document
const page2 = await browser.newPage();
await page2.goto(url);
await page2.waitForTimeout(3000);
await expect(page2.locator('div.ProseMirror')).toContainText(enteredText);

// Close the first window
await page.close();

const list = await browser.newPage();
await list.goto(`${ENV}/#/da-sites/da-status/tests`);

await list.waitForTimeout(3000);
await list.reload();

// Now delete the document
await expect(list.locator(`a[href="/edit#/da-sites/da-status/tests/${pageName}"]`)).toBeVisible();
await list.locator(`a[href="/edit#/da-sites/da-status/tests/${pageName}"]`).focus();
// Note this currently does not work on webkit as the checkbox isn't keyboard focusable there
await list.keyboard.press('Shift+Tab');
await list.keyboard.press(' ');
await list.waitForTimeout(500);
await list.locator('button.delete-button').locator('visible=true').click();

// Give the second window a chance to update itself
await list.waitForTimeout(3000);

// The open window should be cleared out now
await expect(page2.locator('div.ProseMirror')).not.toContainText(enteredText);
});

0 comments on commit 1d12837

Please sign in to comment.