1
1
import { BrowserContext , expect , Locator , Page } from "@playwright/test" ;
2
- import { ANVIL_TABS } from "./anvil/anvil-tabs" ;
3
- import {
4
- BackpageHeader ,
5
- ColumnDescription ,
6
- TabDescription ,
7
- } from "./testInterfaces" ;
8
- import { BrowserContext , expect , Locator , Page } from "@playwright/test" ;
9
2
import {
10
3
BackpageHeader ,
11
4
ColumnDescription ,
@@ -942,8 +935,8 @@ export async function filterAndTestLastPagePagination(
942
935
. filter (
943
936
( n ) =>
944
937
! isNaN ( n ) &&
945
- n > ( ANVIL_TABS . FILES . maxPages ?? 0 ) * 3 &&
946
- n < ( ANVIL_TABS . FILES . maxPages ?? 0 ) * MAX_PAGINATIONS
938
+ n > ( tab . maxPages ?? 0 ) * 3 &&
939
+ n < ( tab . maxPages ?? 0 ) * MAX_PAGINATIONS
947
940
) ;
948
941
if ( filterCounts . length == 0 ) {
949
942
console . log (
@@ -968,27 +961,27 @@ export async function filterAndTestLastPagePagination(
968
961
) . not . toHaveText ( "Page 1 of 1" ) ;
969
962
970
963
// Detect number of pages
971
- const SplitStartingPageText = (
964
+ const splitStartingPageText = (
972
965
await page . getByText ( PAGE_COUNT_REGEX , { exact : true } ) . innerText ( )
973
966
) . split ( " " ) ;
974
- const max_pages = parseInt (
975
- SplitStartingPageText [ SplitStartingPageText . length - 1 ]
967
+ const maxPages = parseInt (
968
+ splitStartingPageText [ splitStartingPageText . length - 1 ]
976
969
) ;
977
970
// Paginate forwards
978
- for ( let i = 2 ; i < max_pages + 1 ; i ++ ) {
971
+ for ( let i = 2 ; i < maxPages + 1 ; i ++ ) {
979
972
await page
980
973
. getByRole ( "button" )
981
974
. filter ( { has : page . getByTestId ( FORWARD_BUTTON_TEST_ID ) } )
982
975
. dispatchEvent ( "click" ) ;
983
976
await expect ( getFirstRowNthColumnCellLocator ( page , 0 ) ) . toBeVisible ( ) ;
984
977
// Expect the page count to have incremented
985
978
await expect ( page . getByText ( PAGE_COUNT_REGEX , { exact : true } ) ) . toHaveText (
986
- `Page ${ i } of ${ max_pages } `
979
+ `Page ${ i } of ${ maxPages } `
987
980
) ;
988
981
}
989
982
// Expect to be on the last page
990
983
await expect ( page . getByText ( PAGE_COUNT_REGEX , { exact : true } ) ) . toContainText (
991
- `Page ${ max_pages } of ${ max_pages } `
984
+ `Page ${ maxPages } of ${ maxPages } `
992
985
) ;
993
986
// Expect the back button to be enabled on the last page
994
987
await expect (
@@ -1021,11 +1014,11 @@ export async function testPaginationContent(
1021
1014
await expect ( page . getByText ( PAGE_COUNT_REGEX , { exact : true } ) ) . toHaveText (
1022
1015
/ P a g e 1 o f [ 0 - 9 ] + /
1023
1016
) ;
1024
- const max_pages = 5 ;
1017
+ const maxPages = 5 ;
1025
1018
const FirstTableEntries = [ ] ;
1026
1019
1027
1020
// Paginate forwards
1028
- for ( let i = 2 ; i < max_pages + 1 ; i ++ ) {
1021
+ for ( let i = 2 ; i < maxPages + 1 ; i ++ ) {
1029
1022
await expect ( firstElementTextLocator ) . not . toHaveText ( "" ) ;
1030
1023
const OriginalFirstTableEntry = await firstElementTextLocator . innerText ( ) ;
1031
1024
// Click the next button
@@ -1044,7 +1037,7 @@ export async function testPaginationContent(
1044
1037
. filter ( { has : page . getByTestId ( BACK_BUTTON_TEST_ID ) } )
1045
1038
) . toBeEnabled ( ) ;
1046
1039
// Expect the forwards button to be enabled
1047
- if ( i != max_pages ) {
1040
+ if ( i != maxPages ) {
1048
1041
await expect (
1049
1042
page
1050
1043
. getByRole ( "button" )
@@ -1060,15 +1053,15 @@ export async function testPaginationContent(
1060
1053
}
1061
1054
1062
1055
// Paginate backwards
1063
- for ( let i = 0 ; i < max_pages - 1 ; i ++ ) {
1064
- const OldFirstTableEntry = FirstTableEntries [ max_pages - i - 2 ] ;
1056
+ for ( let i = 0 ; i < maxPages - 1 ; i ++ ) {
1057
+ const OldFirstTableEntry = FirstTableEntries [ maxPages - i - 2 ] ;
1065
1058
await page
1066
1059
. getByRole ( "button" )
1067
1060
. filter ( { has : page . getByTestId ( BACK_BUTTON_TEST_ID ) } )
1068
1061
. click ( ) ;
1069
1062
// Expect page number to be correct
1070
1063
await expect ( page . getByText ( PAGE_COUNT_REGEX , { exact : true } ) ) . toHaveText (
1071
- RegExp ( `Page ${ max_pages - i - 1 } of [0-9]+` )
1064
+ RegExp ( `Page ${ maxPages - i - 1 } of [0-9]+` )
1072
1065
) ;
1073
1066
// Expect page entry to be consistent with forward pagination
1074
1067
await expect ( firstElementTextLocator ) . toHaveText ( OldFirstTableEntry ) ;
0 commit comments