From fa60c6533711343a6788c9c684741f54ef97667f Mon Sep 17 00:00:00 2001 From: Frederic Cabassut Date: Tue, 10 Mar 2026 15:31:46 +0100 Subject: [PATCH] fix: prevent e2e test pollution from preferences shared state Settings tests set defaultNoteMode to 'markdown' without resetting, causing parallel sharing test to timeout when TiptapEditor wasn't rendered (textarea shown instead). Two fixes: - Reset preferences in settings tests after changing them - Create note via API in sharing test (tests sharing, not note creation) --- tests/e2e/settings.spec.ts | 12 ++++++++++++ tests/e2e/sharing.spec.ts | 13 ++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/tests/e2e/settings.spec.ts b/tests/e2e/settings.spec.ts index addeeec..bc3117d 100644 --- a/tests/e2e/settings.spec.ts +++ b/tests/e2e/settings.spec.ts @@ -26,6 +26,13 @@ test.describe('Settings — Preferences', () => { // Then the note editor opens in markdown mode (textarea visible) await expect(page.getByTestId('note-content-input')).toBeVisible(); + + // Cleanup: reset to richtext so parallel tests aren't affected + await page.getByTestId('close-editor-btn').click(); + await page.goto('/settings/preferences'); + const resetResponse = page.waitForResponse((res) => res.url().includes('/api/preferences') && res.request().method() === 'PUT'); + await page.getByTestId('pref-mode-richtext').click(); + await resetResponse; }); test('Scenario: Footer toggle hides and shows footer', async ({ @@ -65,6 +72,11 @@ test.describe('Settings — Preferences', () => { // Then the Markdown button is still selected (has primary styling) const mdBtn = page.getByTestId('pref-mode-markdown'); await expect(mdBtn).toHaveClass(/font-medium/); + + // Cleanup: reset to richtext so parallel tests aren't affected + const resetResponse = page.waitForResponse((res) => res.url().includes('/api/preferences') && res.request().method() === 'PUT'); + await page.getByTestId('pref-mode-richtext').click(); + await resetResponse; }); }); diff --git a/tests/e2e/sharing.spec.ts b/tests/e2e/sharing.spec.ts index ce46274..2b6acb3 100644 --- a/tests/e2e/sharing.spec.ts +++ b/tests/e2e/sharing.spec.ts @@ -35,13 +35,12 @@ test.describe('Note Sharing', () => { authenticatedPage: page, collabPage }) => { - // When the owner creates a note titled "Share Test" - await page.getByTestId('new-note-btn').click(); - await page.getByTestId('note-title-input').fill('Share Test'); - const editor = page.getByTestId('tiptap-editor').locator('.tiptap'); - await editor.click(); - await editor.pressSequentially('Shared content'); - await page.getByTestId('close-editor-btn').click(); + // Given a note titled "Share Test" exists + await page.request.post('/api/notes', { + data: { title: 'Share Test', content: 'Shared content' } + }); + await page.reload(); + await page.waitForLoadState('networkidle'); await expect(noteCard(page, 'Share Test')).toBeVisible(); // And the owner opens the share dialog and adds the collaborator