fix(tests): smoke specs use page.request for auth-cookie carryover

The bare `request` fixture is an isolated API context that does not
share the browser session cookie established by login(). Result: every
API call hit withAuth and 401'd, and the tests silently skipped
themselves through the existing graceful-skip guards — the assertions
never ran. Switching to page.request shares the browser context cookie
jar, so the API calls now reach the handler and the assertions execute.

Also adds a conditional "view signing details" trigger assertion
behind a feature-flag-style check so future signed-file seed fixtures
exercise the SigningDetailsDialog path automatically.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-11 12:59:01 +02:00
parent b598740b2a
commit eceb77a6c4
2 changed files with 33 additions and 35 deletions

View File

@@ -81,11 +81,13 @@ test.describe('Documents hub — aggregated view', () => {
test('entity sub-folder view renders Signing-in-progress and Files sections', async ({
page,
request,
}) => {
// Create a fresh client via the API so we have a guaranteed entity with a
// folder. ensureEntityFolder is called by the createClient service hook.
const res = await request.post('/api/v1/clients', {
// page.request shares the browser context cookie jar (session cookie from
// login()) — the bare `request` fixture is an isolated API context that
// does not carry the session cookie and would 401.
const res = await page.request.post('/api/v1/clients', {
data: {
firstName: 'HubAgg',
lastName: `Smoke${Date.now()}`,
@@ -101,7 +103,9 @@ test.describe('Documents hub — aggregated view', () => {
);
return;
}
const { data: client } = (await res.json()) as { data: { id: string; firstName: string; lastName: string } };
const { data: client } = (await res.json()) as {
data: { id: string; firstName: string; lastName: string };
};
// Navigate to the documents hub.
await navigateTo(page, '/documents');
@@ -110,10 +114,7 @@ test.describe('Documents hub — aggregated view', () => {
// Expand the Clients system root by clicking its chevron (Expand button).
// The Expand chevron is the first button sibling inside the FolderRow div.
// It is aria-labeled "Expand" when collapsed.
const expandBtn = page
.locator('aside')
.getByRole('button', { name: 'Expand' })
.first();
const expandBtn = page.locator('aside').getByRole('button', { name: 'Expand' }).first();
await expect(expandBtn).toBeVisible({ timeout: 10_000 });
await expandBtn.click();
@@ -129,10 +130,7 @@ test.describe('Documents hub — aggregated view', () => {
await navigateTo(page, '/documents');
await page.waitForLoadState('networkidle');
// Re-expand.
const expandBtn2 = page
.locator('aside')
.getByRole('button', { name: 'Expand' })
.first();
const expandBtn2 = page.locator('aside').getByRole('button', { name: 'Expand' }).first();
await expandBtn2.click();
}
@@ -142,5 +140,14 @@ test.describe('Documents hub — aggregated view', () => {
// EntityFolderView renders two AggregatedSection blocks with these headings.
await expect(page.getByText('Signing in progress')).toBeVisible({ timeout: 10_000 });
await expect(page.getByText('Files')).toBeVisible({ timeout: 5_000 });
// TODO(Task 19 verification): assert SigningDetailsDialog trigger once
// a signed-file fixture exists in the smoke seed. The button is only
// rendered when files[].signedFromDocumentId is non-null (Task 15 fix-up).
const detailsButton = page.getByRole('button', { name: /view signing details/i });
if ((await detailsButton.count()) > 0) {
await detailsButton.first().click();
await expect(page.getByRole('dialog', { name: /Signing details/i })).toBeVisible();
}
});
});