1
1
import { expect , test } from "@playwright/test" ;
2
2
import {
3
- filter_regex ,
3
+ filterRegex ,
4
4
getFirstElementTextLocator ,
5
+ testFilterBubbles ,
6
+ testFilterCounts ,
7
+ testFilterPersistence ,
5
8
testFilterPresence ,
6
9
} from "../testFunctions" ;
7
10
import { anvilFilters , anvilTabs , anvilTabTestOrder } from "./anvil-tabs" ;
8
11
9
12
test . describe . configure ( { mode : "parallel" } ) ;
13
+ const filter_index_list = [ 3 , 4 , 5 , 7 , 6 , 2 ] ;
10
14
11
15
test ( "Check that all filters exist on the Datasets tab and are clickable" , async ( {
12
16
page,
13
17
} ) => {
14
- await testFilterPresence ( page , anvilTabs . datasets ) ;
18
+ await testFilterPresence ( page , anvilTabs . datasets , anvilFilters ) ;
15
19
} ) ;
16
20
17
21
test ( "Check that all filters exist on the Donors tab and are clickable" , async ( {
18
22
page,
19
23
} ) => {
20
- await testFilterPresence ( page , anvilTabs . donors ) ;
24
+ await testFilterPresence ( page , anvilTabs . donors , anvilFilters ) ;
21
25
} ) ;
22
26
23
27
test ( "Check that all filters exist on the BioSamples tab and are clickable" , async ( {
24
28
page,
25
29
} ) => {
26
- await testFilterPresence ( page , anvilTabs . biosamples ) ;
30
+ await testFilterPresence ( page , anvilTabs . biosamples , anvilFilters ) ;
27
31
} ) ;
28
32
29
33
test ( "Check that all filters exist on the Activities tab and are clickable" , async ( {
30
34
page,
31
35
} ) => {
32
- await testFilterPresence ( page , anvilTabs . activities ) ;
36
+ await testFilterPresence ( page , anvilTabs . activities , anvilFilters ) ;
33
37
} ) ;
34
38
35
39
test ( "Check that all filters exist on the Files tab and are clickable" , async ( {
36
40
page,
37
41
} ) => {
38
- await testFilterPresence ( page , anvilTabs . files ) ;
42
+ await testFilterPresence ( page , anvilTabs . files , anvilFilters ) ;
39
43
} ) ;
40
44
41
45
test ( "Check that the first filter on the Datasets tab creates at least one checkbox, and that checking up to the first five does not cause an error and does not cause there to be no entries in the table" , async ( {
@@ -51,9 +55,7 @@ test("Check that the first filter on the Datasets tab creates at least one check
51
55
await page
52
56
. getByRole ( "button" )
53
57
. getByText (
54
- filter_regex (
55
- anvilFilters [ Math . floor ( Math . random ( ) * anvilFilters . length ) ]
56
- )
58
+ filterRegex ( anvilFilters [ Math . floor ( Math . random ( ) * anvilFilters . length ) ] )
57
59
)
58
60
. click ( ) ;
59
61
// Expect all checkboxes to be unchecked initially and to work properly
@@ -70,39 +72,54 @@ test("Check that the first filter on the Datasets tab creates at least one check
70
72
await expect ( getFirstElementTextLocator ( page , 0 ) ) . toBeVisible ( ) ;
71
73
} ) ;
72
74
73
- test ( "Check that filter checkboxes are persistent across pages" , async ( {
75
+ test ( "Check that filter checkboxes are persistent across pages on an arbitrary filter " , async ( {
74
76
page,
75
77
} ) => {
76
- // Randomly select a filter
77
- const test_filter =
78
- anvilFilters [ Math . floor ( Math . random ( ) * anvilFilters . length ) ] ;
79
- // Start on the first tab in the test order (should be files)
80
- await page . goto ( anvilTabs [ anvilTabTestOrder [ 0 ] ] . url ) ;
81
- await expect (
82
- page . getByRole ( "tab" ) . getByText ( anvilTabs . datasets . tabName )
83
- ) . toBeVisible ( ) ;
84
- // Select the first checkbox on the test filter
85
- await page . getByText ( filter_regex ( test_filter ) ) . click ( ) ;
86
- await expect ( page . getByRole ( "checkbox" ) . first ( ) ) . not . toBeChecked ( ) ;
87
- await page . getByRole ( "checkbox" ) . first ( ) . click ( ) ;
88
- await expect ( page . getByRole ( "checkbox" ) . first ( ) ) . toBeChecked ( ) ;
89
- await page . locator ( "body" ) . click ( ) ;
90
- // Expect at least some text to still be visible
91
- await expect ( getFirstElementTextLocator ( page , 0 ) ) . toBeVisible ( ) ;
92
- // For each tab, check that the selected filter is still checked
93
- for ( const tab of anvilTabTestOrder . slice ( 1 ) ) {
94
- await page . getByRole ( "tab" ) . getByText ( anvilTabs [ tab ] . tabName ) . click ( ) ;
95
- await expect ( page . getByText ( filter_regex ( test_filter ) ) ) . toBeVisible ( ) ;
96
- await page . getByText ( filter_regex ( test_filter ) ) . click ( ) ;
97
- await expect ( page . getByRole ( "checkbox" ) . first ( ) ) . toBeChecked ( ) ;
98
- await page . locator ( "body" ) . click ( ) ;
99
- }
100
- // Return to the start tab and confirm that the filter stays checked and that some content is visible
101
- await page
102
- . getByRole ( "tab" )
103
- . getByText ( anvilTabs [ anvilTabTestOrder [ 0 ] ] . tabName )
104
- . click ( ) ;
105
- await expect ( getFirstElementTextLocator ( page , 0 ) ) . toBeVisible ( ) ;
106
- await page . getByText ( filter_regex ( test_filter ) ) . click ( ) ;
107
- await expect ( page . getByRole ( "checkbox" ) . first ( ) ) . toBeChecked ( ) ;
78
+ await testFilterPersistence (
79
+ page ,
80
+ anvilFilters [ 3 ] ,
81
+ anvilTabTestOrder . map ( ( x ) => anvilTabs [ x ] )
82
+ ) ;
83
+ } ) ;
84
+
85
+ test ( "Check that filter menu counts match actual counts on the Datasets tab" , async ( {
86
+ page,
87
+ } ) => {
88
+ await testFilterCounts (
89
+ page ,
90
+ anvilTabs . datasets ,
91
+ filter_index_list . map ( ( x ) => anvilFilters [ x ] ) ,
92
+ 25
93
+ ) ;
94
+ } ) ;
95
+
96
+ test ( "Check that filter menu counts match actual counts on the Activities tab" , async ( {
97
+ page,
98
+ } ) => {
99
+ await testFilterCounts (
100
+ page ,
101
+ anvilTabs . activities ,
102
+ filter_index_list . map ( ( x ) => anvilFilters [ x ] ) ,
103
+ 25
104
+ ) ;
105
+ } ) ;
106
+
107
+ test ( "Check that the blue filter bubbles match the selected filter for an arbitrary filter on the Files tab" , async ( {
108
+ page,
109
+ } ) => {
110
+ await testFilterBubbles (
111
+ page ,
112
+ anvilTabs . files ,
113
+ filter_index_list . map ( ( x ) => anvilFilters [ x ] )
114
+ ) ;
115
+ } ) ;
116
+
117
+ test ( "Check that the blue filter bubbles match the selected filter for an arbitrary filter on the BioSamples tab" , async ( {
118
+ page,
119
+ } ) => {
120
+ await testFilterBubbles (
121
+ page ,
122
+ anvilTabs . biosamples ,
123
+ filter_index_list . map ( ( x ) => anvilFilters [ x ] )
124
+ ) ;
108
125
} ) ;
0 commit comments