Skip to content

Commit

Permalink
Playwright test
Browse files Browse the repository at this point in the history
Tests the fix for this issue: #292
  • Loading branch information
bosschaert committed Jan 6, 2025
1 parent a2e87bd commit f32c7d2
Showing 1 changed file with 44 additions and 1 deletion.
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 f32c7d2

Please sign in to comment.