@@ -438,7 +438,8 @@ const getRowLocatorByAccess = (page: Page, access: string): Locator =>
438
438
. filter ( { has : page . getByRole ( "cell" , { name : access } ) } )
439
439
. first ( )
440
440
. getByRole ( "cell" )
441
- . first ( ) ;
441
+ . first ( )
442
+ . getByRole ( "link" ) ;
442
443
443
444
// Backpages tests
444
445
export async function testExportBackpage (
@@ -448,51 +449,73 @@ export async function testExportBackpage(
448
449
) : Promise < void > {
449
450
// Goto the specified tab
450
451
await page . goto ( tab . url ) ;
451
- await expect ( getFirstElementTextLocator ( page , 1 ) ) . toBeVisible ( ) ;
452
452
// Expect to find row with a granted status indicator
453
- const granted_row_locator = getRowLocatorByAccess ( page , "Granted" ) ;
454
- await expect ( granted_row_locator ) . toBeVisible ( ) ;
453
+ const grantedRowLocator = getRowLocatorByAccess ( page , "Granted" ) ;
454
+ await expect ( grantedRowLocator ) . toBeVisible ( ) ;
455
455
// Click into the selected row
456
- await granted_row_locator . click ( ) ;
456
+ await grantedRowLocator . dispatchEvent ( "click" ) ; //TODO: this is sometimes unreliable and changes the url without changing the tab.
457
+ await expect (
458
+ page . getByText ( tab . backpageExportButtons ?. detailsName ?? "" )
459
+ ) . toBeVisible ( ) ;
457
460
// Click the "Export" tab
458
- await page . getByText ( "Export" , { exact : true } ) . click ( ) ;
459
- await expect ( page ) . toHaveURL ( / \. * \/ e x p o r t - t o - t e r r a / ) ;
461
+ await page
462
+ . getByText ( tab . backpageExportButtons ?. exportTabName ?? "ERROR" , {
463
+ exact : true ,
464
+ } )
465
+ . click ( ) ;
466
+ await expect ( page ) . toHaveURL ( tab . backpageExportButtons ?. exportUrl ?? "" ) ;
460
467
await expect ( page . getByRole ( "checkbox" ) . first ( ) ) . toBeVisible ( ) ;
461
- const requestLinkButtonLocator = page . getByRole ( "button" , {
468
+ const firstButtonLocator = page . getByRole ( "button" , {
462
469
name : "Request Link" ,
463
470
} ) ;
464
- await expect ( requestLinkButtonLocator ) . toBeEnabled ( ) ;
465
- // Select all checkboxes on the page
471
+ await expect ( firstButtonLocator ) . toBeEnabled ( ) ;
472
+ // Select all checkboxes on the pages
466
473
const checkboxes = await page . getByRole ( "checkbox" ) . all ( ) ;
467
474
console . log ( checkboxes ) ;
468
- for ( const checkbox of checkboxes ) {
469
- console . log ( checkbox ) ;
470
- if ( ! ( await checkbox . isChecked ( ) ) ) {
471
- await checkbox . click ( ) ;
472
- await expect ( checkbox ) . toBeChecked ( ) ;
473
- await expect ( checkbox ) . toBeEnabled ( { timeout : 10000 } ) ;
475
+ for ( const checkboxLocator of checkboxes ) {
476
+ console . log ( checkboxLocator ) ;
477
+ if ( ! ( await checkboxLocator . isChecked ( ) ) ) {
478
+ await checkboxLocator . click ( ) ;
479
+ await expect ( checkboxLocator ) . toBeChecked ( ) ;
480
+ await expect ( checkboxLocator ) . toBeEnabled ( { timeout : 10000 } ) ;
481
+ }
482
+ }
483
+ await expect ( firstButtonLocator ) . toBeEnabled ( { timeout : 10000 } ) ;
484
+ // Uncheck all checkboxes except one in each table, to reduce overhead
485
+ for ( const tableLocator of await page . getByRole ( "table" ) . all ( ) ) {
486
+ const checkboxLocatorsInTable = await tableLocator
487
+ . getByRole ( "checkbox" )
488
+ . all ( ) ;
489
+ for ( const checkboxLocator of checkboxLocatorsInTable . slice ( 2 ) ) {
490
+ await checkboxLocator . click ( ) ;
491
+ await expect ( checkboxLocator ) . not . toBeChecked ( ) ;
492
+ await expect ( checkboxLocator ) . toBeEnabled ( { timeout : 10000 } ) ;
474
493
}
475
494
}
476
495
// Click the "Request Link" button
477
- await expect ( requestLinkButtonLocator ) . toBeEnabled ( { timeout : 10000 } ) ;
478
- await requestLinkButtonLocator . click ( ) ;
496
+ await expect ( firstButtonLocator ) . toBeEnabled ( { timeout : 10000 } ) ;
497
+ await firstButtonLocator . click ( ) ;
479
498
await expect (
480
- page . getByText ( "Your link will be ready shortly..." , { exact : true } )
499
+ page . getByText ( tab . backpageExportButtons ?. firstLoadingMessage ?? "ERROR" , {
500
+ exact : true ,
501
+ } )
481
502
) . toBeVisible ( ) ;
482
503
await expect (
483
- page . getByText ( "Your Terra Workspace Link is Ready" , { exact : true } )
504
+ page . getByText ( tab . backpageExportButtons ?. secondLandingMessage ?? "ERROR" , {
505
+ exact : true ,
506
+ } )
484
507
) . toBeVisible ( { timeout : 60000 } ) ;
485
- const openTerraButton = page . getByRole ( "button" , { name : "Open Terra" } ) ;
486
- await expect ( openTerraButton ) . toBeEnabled ( ) ;
508
+ const secondButtonLocator = page . getByRole ( "button" , {
509
+ name : tab . backpageExportButtons ?. secondButtonName ?? "" ,
510
+ } ) ;
511
+ await expect ( secondButtonLocator ) . toBeEnabled ( ) ;
487
512
// Click the "Open Terra" Button and await a new browser tab
488
- const pagePromise = context . waitForEvent ( "page" ) ;
489
- await openTerraButton . click ( ) ;
490
- const newPage = await pagePromise ;
513
+ const newPagePromise = context . waitForEvent ( "page" ) ;
514
+ await secondButtonLocator . click ( ) ;
515
+ const newPage = await newPagePromise ;
491
516
// Expect the new browser tab to look like the Terra page
492
517
await expect (
493
- newPage . getByText (
494
- "If you are a new user or returning user, click sign in to continue."
495
- )
518
+ newPage . getByText ( tab . backpageExportButtons ?. newTabMessage ?? "ERROR" )
496
519
) . toBeVisible ( ) ;
497
520
}
498
521
@@ -505,27 +528,38 @@ export async function testBackpageAccess(
505
528
// Check that the first "Granted" tab has access granted
506
529
const grantedRowLocator = getRowLocatorByAccess ( page , "Granted" ) ;
507
530
await expect ( grantedRowLocator ) . toBeVisible ( ) ;
508
- await grantedRowLocator . click ( ) ;
531
+ await grantedRowLocator . dispatchEvent ( "click" ) ;
532
+ await expect (
533
+ page . getByText ( tab . backpageExportButtons ?. detailsName ?? "" )
534
+ ) . toBeVisible ( ) ;
509
535
await expect ( page . getByText ( "Access Granted" ) ) . toBeVisible ( ) ;
510
- await page . getByText ( "Export" , { exact : true } ) . click ( ) ;
511
- await expect ( page ) . toHaveURL ( / \. * \/ e x p o r t - t o - t e r r a / ) ;
536
+ await page
537
+ . getByText ( tab . backpageExportButtons ?. exportTabName ?? "ERROR" , {
538
+ exact : true ,
539
+ } )
540
+ . click ( ) ;
541
+ await expect ( page ) . toHaveURL ( tab . backpageExportButtons ?. exportUrl ?? / E R R O R / ) ;
512
542
await expect ( page . getByRole ( "checkbox" ) . first ( ) ) . toBeVisible ( ) ;
513
543
const requestLinkButtonLocator = page . getByRole ( "button" , {
514
- name : "Request Link" ,
544
+ name : tab . backpageExportButtons ?. firstButtonName ,
515
545
} ) ;
516
546
await expect ( requestLinkButtonLocator ) . toBeEnabled ( ) ;
517
547
// Go back to the table page
518
- await page . getByRole ( "link" , { name : "Datasets" } ) . click ( ) ;
548
+ await page . getByRole ( "link" , { name : tab . tabName } ) . click ( ) ;
519
549
// Check that the first "Required" tab does not have access granted
520
550
const requiredRowLocator = getRowLocatorByAccess ( page , "Required" ) ;
521
551
await expect ( requiredRowLocator ) . toBeVisible ( ) ;
522
552
await requiredRowLocator . click ( ) ;
523
553
await expect ( page . getByText ( "Access Required" ) ) . toBeVisible ( ) ;
524
- await page . getByText ( "Export" , { exact : true } ) . click ( ) ;
525
- await expect ( page ) . toHaveURL ( / \. * \/ e x p o r t - t o - t e r r a / ) ;
554
+ await page
555
+ . getByText ( tab . backpageExportButtons ?. exportTabName ?? "ERROR" , {
556
+ exact : true ,
557
+ } )
558
+ . click ( ) ;
559
+ await expect ( page ) . toHaveURL ( tab . backpageExportButtons ?. exportUrl ?? / E R R O R / ) ;
526
560
await expect (
527
561
page . getByText (
528
- "To export this dataset, please sign in and, if necessary, request access. ",
562
+ tab . backpageExportButtons ?. accessNotGrantedMessage ?? "ERROR ",
529
563
{ exact : true }
530
564
)
531
565
) . toBeVisible ( ) ;
@@ -540,38 +574,43 @@ export async function testBackpageDetails(
540
574
}
541
575
await page . goto ( tab . url ) ;
542
576
// Enable test columns
543
- await testSelectableColumns ( page , tab ) ; //TODO: check if this funtion breaks if selectable columns don't load in order
577
+ await testSelectableColumns ( page , tab ) ; //TODO: check if this function breaks if selectable columns don't load in order
544
578
const headers : { header : string ; value : string } [ ] = [ ] ;
545
579
const combinedColumns = tab . preselectedColumns . concat ( tab . selectableColumns ) ;
546
580
const filterString = ( x : string | undefined ) : x is string => x !== undefined ;
581
+ // Get the columns that correspond with a header on the backpage details
547
582
const headerCorrespondingColumns : string [ ] = tab . backpageHeaders
548
583
. map ( ( header ) => header ?. correspondingColumn ?. name )
549
584
. filter ( filterString )
550
585
. map ( ( x ) => x . trim ( ) ) ;
551
- console . log ( headerCorrespondingColumns ) ;
552
586
for ( let i = 0 ; i < combinedColumns . length ; i ++ ) {
553
587
const headerColumnText = (
554
588
await page . getByRole ( "columnheader" ) . nth ( i ) . innerText ( )
555
589
) . trim ( ) ;
556
590
if ( headerCorrespondingColumns . includes ( headerColumnText ) ) {
557
591
const headerEntryText = await getNthElementTextLocator (
558
592
page ,
559
- 2 ,
593
+ 0 ,
560
594
i
561
595
) . innerText ( ) ;
562
596
const correspondingHeaderName = tab . backpageHeaders . find (
563
597
( header : backpageHeader ) =>
564
598
header ?. correspondingColumn ?. name === headerColumnText
565
599
) ?. name ;
566
600
if ( correspondingHeaderName === undefined ) {
601
+ // Fail the test, because this means there is an incorrect configuraiton in the tab definition
567
602
return false ;
568
603
}
569
604
headers . push ( { header : correspondingHeaderName , value : headerEntryText } ) ;
570
605
}
571
606
}
572
- await getNthElementTextLocator ( page , 2 , 0 ) . click ( ) ;
573
- await expect ( page . getByText ( "Dataset Details" ) ) . toBeVisible ( ) ;
607
+ await getNthElementTextLocator ( page , 0 , 0 ) . click ( ) ;
608
+ await expect (
609
+ page . getByText ( tab . backpageExportButtons ?. detailsName ?? "ERROR" )
610
+ ) . toBeVisible ( ) ;
574
611
for ( const headerValue of headers ) {
612
+ // 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
575
614
await expect (
576
615
page
577
616
. locator (
0 commit comments