@@ -470,9 +470,9 @@ export async function testExportBackpage(
470
470
} ) ;
471
471
await expect ( firstButtonLocator ) . toBeEnabled ( ) ;
472
472
// Select all checkboxes on the pages
473
- const checkboxes = await page . getByRole ( "checkbox" ) . all ( ) ;
474
- console . log ( checkboxes ) ;
475
- for ( const checkboxLocator of checkboxes ) {
473
+ const checkboxLocators = await page . getByRole ( "checkbox" ) . all ( ) ;
474
+ console . log ( checkboxLocators ) ;
475
+ for ( const checkboxLocator of checkboxLocators ) {
476
476
console . log ( checkboxLocator ) ;
477
477
if ( ! ( await checkboxLocator . isChecked ( ) ) ) {
478
478
await checkboxLocator . click ( ) ;
@@ -506,7 +506,7 @@ export async function testExportBackpage(
506
506
} )
507
507
) . toBeVisible ( { timeout : 60000 } ) ;
508
508
const secondButtonLocator = page . getByRole ( "button" , {
509
- name : tab . backpageExportButtons ?. secondButtonName ?? "" ,
509
+ name : tab . backpageExportButtons ?. secondButtonName ?? "ERROR " ,
510
510
} ) ;
511
511
await expect ( secondButtonLocator ) . toBeEnabled ( ) ;
512
512
// Click the "Open Terra" Button and await a new browser tab
@@ -523,25 +523,30 @@ export async function testBackpageAccess(
523
523
page : Page ,
524
524
tab : TabDescription
525
525
) : Promise < void > {
526
+ if ( tab . backpageExportButtons == null ) {
527
+ // Fail if this test is ran on a tab without defined backpages
528
+ await expect ( false ) ;
529
+ return ;
530
+ }
526
531
// Goto the specified tab
527
532
await page . goto ( tab . url ) ;
528
533
// Check that the first "Granted" tab has access granted
529
534
const grantedRowLocator = getRowLocatorByAccess ( page , "Granted" ) ;
530
535
await expect ( grantedRowLocator ) . toBeVisible ( ) ;
531
536
await grantedRowLocator . dispatchEvent ( "click" ) ;
532
537
await expect (
533
- page . getByText ( tab . backpageExportButtons ? .detailsName ?? "" )
538
+ page . getByText ( tab . backpageExportButtons . detailsName )
534
539
) . toBeVisible ( ) ;
535
540
await expect ( page . getByText ( "Access Granted" ) ) . toBeVisible ( ) ;
536
541
await page
537
- . getByText ( tab . backpageExportButtons ? .exportTabName ?? "ERROR" , {
542
+ . getByText ( tab . backpageExportButtons . exportTabName , {
538
543
exact : true ,
539
544
} )
540
545
. click ( ) ;
541
- await expect ( page ) . toHaveURL ( tab . backpageExportButtons ? .exportUrl ?? / E R R O R / ) ;
546
+ await expect ( page ) . toHaveURL ( tab . backpageExportButtons . exportUrl ) ;
542
547
await expect ( page . getByRole ( "checkbox" ) . first ( ) ) . toBeVisible ( ) ;
543
548
const requestLinkButtonLocator = page . getByRole ( "button" , {
544
- name : tab . backpageExportButtons ? .firstButtonName ,
549
+ name : tab . backpageExportButtons . firstButtonName ,
545
550
} ) ;
546
551
await expect ( requestLinkButtonLocator ) . toBeEnabled ( ) ;
547
552
// Go back to the table page
@@ -568,9 +573,10 @@ export async function testBackpageAccess(
568
573
export async function testBackpageDetails (
569
574
page : Page ,
570
575
tab : TabDescription
571
- ) : Promise < boolean > {
572
- if ( tab ?. backpageHeaders === undefined ) {
573
- return false ;
576
+ ) : Promise < void > {
577
+ if ( tab . backpageHeaders == null ) {
578
+ await expect ( false ) ;
579
+ return ; // This is unreachable, but typescript doesn't know without it
574
580
}
575
581
await page . goto ( tab . url ) ;
576
582
// Enable test columns
@@ -590,7 +596,7 @@ export async function testBackpageDetails(
590
596
if ( headerCorrespondingColumns . includes ( headerColumnText ) ) {
591
597
const headerEntryText = await getNthElementTextLocator (
592
598
page ,
593
- 0 ,
599
+ 1 ,
594
600
i
595
601
) . innerText ( ) ;
596
602
const correspondingHeaderName = tab . backpageHeaders . find (
@@ -599,27 +605,25 @@ export async function testBackpageDetails(
599
605
) ?. name ;
600
606
if ( correspondingHeaderName === undefined ) {
601
607
// Fail the test, because this means there is an incorrect configuraiton in the tab definition
602
- return false ;
608
+ await expect ( false ) ;
609
+ return ;
603
610
}
604
611
headers . push ( { header : correspondingHeaderName , value : headerEntryText } ) ;
605
612
}
606
613
}
607
- await getNthElementTextLocator ( page , 0 , 0 ) . click ( ) ;
614
+ await getNthElementTextLocator ( page , 1 , 0 ) . click ( ) ;
608
615
await expect (
609
616
page . getByText ( tab . backpageExportButtons ?. detailsName ?? "ERROR" )
610
617
) . toBeVisible ( ) ;
611
618
for ( const headerValue of headers ) {
612
619
// Expect the correct value to be below the correct header in the dataset values table
613
- // TODO: this locator does not appear to work on Webkit
614
620
await expect (
615
621
page
616
- . locator (
617
- `:text('${ headerValue . value } '):below(:text('${ headerValue . header } '))`
618
- )
622
+ . locator ( `:below(:text('${ headerValue . header } '))` )
623
+ . getByText ( headerValue . value )
619
624
. first ( )
620
625
) . toBeVisible ( ) ;
621
626
}
622
- return true ;
623
627
}
624
628
625
629
/* eslint-enable sonarjs/no-duplicate-string -- Checking duplicate strings again*/
0 commit comments