From ebddd5687ce9817916e59e26f0c66778ff2b3457 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Fri, 30 Oct 2026 15:45:46 -0700 Subject: [PATCH] Chore: fix a couple e2e warnings / flakiness (#14596) --- src-ui/e2e/backend.py | 10 +++++++++- .../e2e/document-detail/document-detail.spec.ts | 15 ++++++++++++--- .../e2e/permissions/global-permissions.spec.ts | 16 ++++++++-------- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src-ui/e2e/backend.py b/src-ui/e2e/backend.py index 0a4ed8fa3..b4a77bd2e 100644 --- a/src-ui/e2e/backend.py +++ b/src-ui/e2e/backend.py @@ -43,6 +43,7 @@ def configure_environment(instance_root: Path) -> None: def seed_database() -> None: + from django.contrib.auth.models import Permission from django.contrib.auth.models import User from django.core.management import call_command from django.utils import timezone @@ -63,11 +64,18 @@ def seed_database() -> None: username="playwright", password="playwright", # NOSONAR ) - User.objects.create_user( + viewer = User.objects.create_user( username="viewer", password="viewer", # NOSONAR ) + viewer.user_permissions.add( + Permission.objects.get( + content_type__app_label="documents", + codename="view_uisettings", + ), + ) + inbox = Tag.objects.create(name="Inbox", is_inbox_tag=True, owner=admin) quick_filter = Tag.objects.create(name="Another Sample Tag", owner=admin) Tag.objects.create(name="TagWithPartial", owner=admin) diff --git a/src-ui/e2e/document-detail/document-detail.spec.ts b/src-ui/e2e/document-detail/document-detail.spec.ts index 2eaec2263..ba3d8841e 100644 --- a/src-ui/e2e/document-detail/document-detail.spec.ts +++ b/src-ui/e2e/document-detail/document-detail.spec.ts @@ -80,12 +80,21 @@ test('should show a list of notes', async ({ page }) => { test('should support quick filters', async ({ page }) => { await page.goto('/documents/1/details') + // filter button is available before tags have loaded + const selectedTags = page.locator('pngx-input-tags .ng-value pngx-tag') + await expect(selectedTags).toHaveCount(2) + await expect( + selectedTags.getByText('Another Sample Tag', { exact: true }) + ).toBeVisible() + await expect(selectedTags.getByText('Inbox', { exact: true })).toBeVisible() await page .getByRole('button', { name: 'Filter documents with these Tags' }) .click() - await expect(page).toHaveURL( - /tags__id__all=2,1&sort=created&reverse=1&page=1/ - ) + await expect(page).toHaveURL((url) => { + const tags = url.searchParams.get('tags__id__all')?.split(',').sort() + return url.pathname === '/documents' && tags?.join(',') === '1,2' + }) + await expect(page.locator('pngx-document-list')).toHaveText(/one document/i) }) test('should finish reloading the preview after a remote document update', async ({ diff --git a/src-ui/e2e/permissions/global-permissions.spec.ts b/src-ui/e2e/permissions/global-permissions.spec.ts index 42d9002ff..1cff42b27 100644 --- a/src-ui/e2e/permissions/global-permissions.spec.ts +++ b/src-ui/e2e/permissions/global-permissions.spec.ts @@ -6,8 +6,15 @@ test.use({ }, }) -test('should not allow user to edit settings', async ({ page }) => { +test.beforeEach(async ({ page }) => { + const settingsLoaded = page.waitForResponse((response) => + response.url().endsWith('/api/ui_settings/') + ) await page.goto('/dashboard') + expect((await settingsLoaded).status()).toBe(200) +}) + +test('should not allow user to edit settings', async ({ page }) => { await expect(page.getByRole('link', { name: 'Settings' })).not.toBeAttached() await page.goto('/settings') await expect(page.locator('body')).toHaveText( @@ -16,7 +23,6 @@ test('should not allow user to edit settings', async ({ page }) => { }) test('should not allow user to view documents', async ({ page }) => { - await page.goto('/dashboard') await expect( page.locator('nav').getByRole('link', { name: 'Documents' }) ).not.toBeAttached() @@ -31,7 +37,6 @@ test('should not allow user to view documents', async ({ page }) => { }) test('should not allow user to view correspondents', async ({ page }) => { - await page.goto('/dashboard') await expect( page.getByRole('link', { name: 'Attributes' }) ).not.toBeAttached() @@ -42,7 +47,6 @@ test('should not allow user to view correspondents', async ({ page }) => { }) test('should not allow user to view tags', async ({ page }) => { - await page.goto('/dashboard') await expect( page.getByRole('link', { name: 'Attributes' }) ).not.toBeAttached() @@ -53,7 +57,6 @@ test('should not allow user to view tags', async ({ page }) => { }) test('should not allow user to view document types', async ({ page }) => { - await page.goto('/dashboard') await expect( page.getByRole('link', { name: 'Attributes' }) ).not.toBeAttached() @@ -64,7 +67,6 @@ test('should not allow user to view document types', async ({ page }) => { }) test('should not allow user to view storage paths', async ({ page }) => { - await page.goto('/dashboard') await expect( page.getByRole('link', { name: 'Attributes' }) ).not.toBeAttached() @@ -75,7 +77,6 @@ test('should not allow user to view storage paths', async ({ page }) => { }) test('should not allow user to view logs', async ({ page }) => { - await page.goto('/dashboard') await expect(page.getByRole('link', { name: 'Logs' })).not.toBeAttached() await page.goto('/logs') await expect(page.locator('body')).toHaveText( @@ -84,7 +85,6 @@ test('should not allow user to view logs', async ({ page }) => { }) test('should not allow user to view tasks', async ({ page }) => { - await page.goto('/dashboard') await expect(page.getByRole('link', { name: 'Tasks' })).not.toBeAttached() await page.goto('/tasks') await expect(page.locator('body')).toHaveText(