11import assert from 'node:assert/strict'
22import { mkdir , writeFile } from 'node:fs/promises'
33import { dirname , resolve } from 'node:path'
4- import { chromium , expect } from '@playwright/test'
4+ import { chromium , expect , type Locator } from '@playwright/test'
55import { assertDisposableTestDatabaseUrl } from '@sim/db/testing/test-infrastructure'
66import { createLogger } from '@sim/logger'
77import { createDeferred } from '@sim/testing/helpers/deferred'
@@ -188,6 +188,16 @@ async function capture(name: string) {
188188 await page . screenshot ( { path : resolve ( artifactDirectory , `${ name } .png` ) , animations : 'disabled' } )
189189}
190190
191+ async function captureExpandedReceipt ( name : string , disclosure : Locator ) {
192+ await disclosure . hover ( )
193+ await page . mouse . wheel ( 0 , - 1000 )
194+ await disclosure . click ( )
195+ await expect ( disclosure ) . toHaveAttribute ( 'aria-expanded' , 'true' )
196+ await expect ( disclosure ) . toBeInViewport ( { ratio : 1 } )
197+ await capture ( name )
198+ await expect ( disclosure ) . toBeInViewport ( { ratio : 1 } )
199+ }
200+
191201function proposalArguments ( summary : string ) {
192202 return {
193203 credential : credentialId ,
@@ -1042,10 +1052,12 @@ try {
10421052 const historicalReceipt = page
10431053 . getByRole ( 'region' , { name : 'Create Jira issue receipt' } )
10441054 . filter ( { hasText : 'Approved historical title' } )
1045- await historicalReceipt
1046- . getByRole ( 'button' , { name : 'View Create Jira issue receipt: Completed' , exact : true } )
1047- . click ( )
1048- await capture ( 'action-receipt-completed-expanded' )
1055+ await captureExpandedReceipt (
1056+ 'action-receipt-completed-expanded' ,
1057+ historicalReceipt . getByRole ( 'button' , {
1058+ name : / ^ ( V i e w | H i d e ) C r e a t e J i r a i s s u e r e c e i p t : C o m p l e t e d $ / ,
1059+ } )
1060+ )
10491061 await historicalReceipt
10501062 . getByRole ( 'button' , { name : 'Hide Create Jira issue receipt: Completed' , exact : true } )
10511063 . click ( )
@@ -1633,7 +1645,15 @@ try {
16331645 await expect (
16341646 page . getByText ( 'Could not load action history' , { exact : true } )
16351647 ) . toHaveCount ( index + 1 , { timeout : 15_000 } )
1648+ const historyError = page
1649+ . getByText ( 'Could not load action history' , { exact : true } )
1650+ . last ( )
1651+ await historyError . hover ( )
1652+ await page . mouse . wheel ( 0 , - 1000 )
1653+ await historyError . scrollIntoViewIfNeeded ( )
1654+ await expect ( historyError ) . toBeInViewport ( { ratio : 1 } )
16361655 await capture ( `receipt-history-${ fixture . state . toLowerCase ( ) } -retry` )
1656+ await expect ( historyError ) . toBeInViewport ( { ratio : 1 } )
16371657 } finally {
16381658 await page . unroute ( `${ receiptsUrl } *` )
16391659 }
@@ -1660,13 +1680,12 @@ try {
16601680 const receipt = page
16611681 . getByRole ( 'region' , { name : 'Create Jira issue receipt' } )
16621682 . filter ( { hasText : 'Batch issue 62' } )
1663- await receipt
1664- . getByRole ( 'button ', {
1665- name : `View Create Jira issue receipt: ${ fixture . label } ` ,
1666- exact : true ,
1683+ await captureExpandedReceipt (
1684+ `action-receipt- ${ fixture . label . toLowerCase ( ) . replaceAll ( ' ', '-' ) } ` ,
1685+ receipt . getByRole ( 'button' , {
1686+ name : new RegExp ( `^(View|Hide) Create Jira issue receipt: ${ fixture . label } $` ) ,
16671687 } )
1668- . click ( )
1669- await capture ( `action-receipt-${ fixture . label . toLowerCase ( ) . replaceAll ( ' ' , '-' ) } ` )
1688+ )
16701689 }
16711690 const incompatibleBinding = {
16721691 ...toRecord ( savedExecution . assistant_action ) ,
@@ -1681,13 +1700,12 @@ try {
16811700 ] ) {
16821701 await sql `update copilot_async_tool_calls set assistant_action = ${ sql . json ( fixture . binding ) } where run_id = ${ bulkRunId } and tool_call_id = ${ precedingCallId } `
16831702 await page . reload ( )
1684- await page
1685- . getByRole ( 'button' , {
1686- name : 'View Create Jira issue receipt: Outcome unknown' ,
1687- exact : true ,
1703+ await captureExpandedReceipt (
1704+ `action-receipt- ${ fixture . name } ` ,
1705+ page . getByRole ( 'button' , {
1706+ name : / ^ ( V i e w | H i d e ) C r e a t e J i r a i s s u e r e c e i p t : O u t c o m e u n k n o w n $ / ,
16881707 } )
1689- . click ( )
1690- await capture ( `action-receipt-${ fixture . name } ` )
1708+ )
16911709 }
16921710 } finally {
16931711 await sql `update copilot_async_tool_calls set status = ${ savedExecution . status } , execution_started_at = ${ savedExecution . execution_started_at } , execution_settled_at = ${ savedExecution . execution_settled_at } , execution_owner_token = ${ savedExecution . execution_owner_token } , execution_lease_expires_at = ${ savedExecution . execution_lease_expires_at } , completed_at = ${ savedExecution . completed_at } , result = ${ savedExecution . result === null ? null : sql . json ( savedExecution . result ) } , assistant_action = ${ sql . json ( savedExecution . assistant_action ) } where run_id = ${ bulkRunId } and tool_call_id = ${ precedingCallId } `
0 commit comments