@@ -7,12 +7,12 @@ test.describe('dialog interactions', () => {
7
7
} ) ;
8
8
9
9
test ( 'open settings dialog' , async ( { page, queries } ) => {
10
- await queries . getControl ( 'Settings' ) . click ( ) ;
10
+ await queries . getButton ( 'Settings' ) . click ( ) ;
11
11
await expect ( page . getByRole ( 'dialog' , { name : 'Settings' } ) ) . toBeVisible ( ) ;
12
12
} ) ;
13
13
14
14
test ( 'close settings dialog with button' , async ( { queries, page } ) => {
15
- await queries . getControl ( 'Settings' ) . click ( ) ;
15
+ await queries . getButton ( 'Settings' ) . click ( ) ;
16
16
await expect ( page . getByRole ( 'dialog' , { name : 'Settings' } ) ) . toBeVisible ( ) ;
17
17
18
18
await queries . getButton ( 'Cancel' ) . click ( ) ;
@@ -22,7 +22,7 @@ test.describe('dialog interactions', () => {
22
22
} ) ;
23
23
24
24
test ( 'close settings dialog with key' , async ( { queries, page } ) => {
25
- await queries . getControl ( 'Settings' ) . click ( ) ;
25
+ await queries . getButton ( 'Settings' ) . click ( ) ;
26
26
27
27
const dialog = page . getByRole ( 'dialog' , { name : 'Settings' } ) ;
28
28
await expect ( dialog ) . toBeVisible ( ) ;
@@ -35,47 +35,47 @@ test.describe('dialog interactions', () => {
35
35
test . describe ( 'functionality' , ( ) => {
36
36
test . beforeEach ( async ( { page, queries } ) => {
37
37
await page . goto ( '/' ) ;
38
- await queries . getControl ( 'Settings' ) . click ( ) ;
38
+ await queries . getButton ( 'Settings' ) . click ( ) ;
39
39
} ) ;
40
- test ( 'Type field' , async ( { appPage } ) => {
41
- await appPage . withinSettings ( async ( settings ) => {
40
+ test ( 'Type field' , async ( { queries } ) => {
41
+ await queries . withinSettings ( async ( settings ) => {
42
42
const select = settings . getByLabel ( 'Type' ) ;
43
43
await expect ( select ) . toHaveRole ( 'combobox' ) ;
44
44
45
45
await expect ( select ) . toHaveOptions ( [ 'Work' , 'ShortBreak' , 'LongBreak' ] ) ;
46
46
await expect ( select ) . toHaveSelected ( 'Work' ) ;
47
47
} ) ;
48
48
} ) ;
49
- test ( 'Duration field' , async ( { appPage } ) => {
50
- await appPage . withinSettings ( async ( settings ) => {
49
+ test ( 'Duration field' , async ( { queries } ) => {
50
+ await queries . withinSettings ( async ( settings ) => {
51
51
const duration = settings . getByLabel ( / D u r a t i o n / ) ;
52
52
await expect ( duration ) . toHaveAttribute ( 'type' , 'number' ) ;
53
53
await expect ( duration ) . toHaveValue ( '45' ) ;
54
54
} ) ;
55
55
} ) ;
56
- test ( 'Update an interval' , async ( { appPage , queries } ) => {
57
- await appPage . withinSettings ( async ( settings ) => {
56
+ test ( 'Update an interval' , async ( { queries } ) => {
57
+ await queries . withinSettings ( async ( settings ) => {
58
58
await settings . getByLabel ( / D u r a t i o n / ) . fill ( '1' ) ;
59
59
await settings . getByLabel ( 'Type' ) . selectOption ( { label : 'ShortBreak' } ) ;
60
60
61
- await queries . getButton ( 'Save' , { context : settings } ) . click ( ) ;
61
+ await queries . getButton ( 'Save' ) . click ( ) ;
62
62
} ) ;
63
63
64
64
const newTimer = queries . getIntervalList ( ) . first ( ) ;
65
65
await expect ( newTimer ) . toContainText ( 'SB' ) ;
66
66
await expect ( newTimer ) . toContainText ( '01:00' ) ;
67
67
} ) ;
68
- test ( 'Add an interval' , async ( { appPage , queries } ) => {
69
- await appPage . withinSettings ( async ( settings ) => {
70
- await queries . getButton ( 'Add' , { context : settings } ) . click ( ) ;
68
+ test ( 'Add an interval' , async ( { queries } ) => {
69
+ await queries . withinSettings ( async ( settings ) => {
70
+ await queries . getButton ( 'Add' ) . click ( ) ;
71
71
72
72
const row = settings
73
73
. getByRole ( 'group' , { name : 'Interval Settings' } )
74
74
. last ( ) ;
75
75
76
76
await row . getByLabel ( 'Type' ) . selectOption ( { label : 'ShortBreak' } ) ;
77
77
await row . getByLabel ( / D u r a t i o n / ) . fill ( '20' ) ;
78
- await queries . getButton ( 'Save' , { context : settings } ) . click ( ) ;
78
+ await queries . getButton ( 'Save' ) . click ( ) ;
79
79
} ) ;
80
80
81
81
const newTimer = queries . getIntervalList ( ) . last ( ) ;
@@ -91,32 +91,34 @@ test.describe('functionality', () => {
91
91
await page . reload ( ) ;
92
92
await expect ( queries . getIntervalList ( ) ) . toHaveCount ( 2 ) ;
93
93
94
- await queries . getControl ( 'Settings' ) . click ( ) ;
94
+ await queries . getButton ( 'Settings' ) . click ( ) ;
95
95
96
- await appPage . withinSettings ( async ( settings ) => {
96
+ await queries . withinSettings ( async ( settings ) => {
97
97
const row = settings
98
98
. getByRole ( 'group' , { name : 'Interval Settings' } )
99
99
. first ( ) ;
100
100
101
- await queries . getButton ( 'Delete' , { context : row } ) . click ( ) ;
102
- await queries . getButton ( 'Save' , { context : settings } ) . click ( ) ;
101
+ await queries . within ( row , async ( ) => {
102
+ await queries . getButton ( 'Delete' ) . click ( ) ;
103
+ } ) ;
104
+
105
+ await queries . getButton ( 'Save' ) . click ( ) ;
103
106
} ) ;
104
107
105
108
await expect ( queries . getIntervalList ( ) ) . toHaveCount ( 1 ) ;
106
109
} ) ;
107
110
108
111
test ( 'Cannot remove the interval when it is the only one' , async ( {
109
- appPage,
110
112
queries,
111
113
} ) => {
112
- await appPage . withinSettings ( async ( settings ) => {
114
+ await queries . withinSettings ( async ( settings ) => {
113
115
const row = settings
114
116
. getByRole ( 'group' , { name : 'Interval Settings' } )
115
117
. first ( ) ;
116
118
117
- await expect (
118
- queries . getButton ( 'Delete' , { context : row } ) ,
119
- ) . toBeDisabled ( ) ;
119
+ await queries . within ( row , async ( ) => {
120
+ await expect ( queries . getButton ( 'Delete' ) ) . toBeDisabled ( ) ;
121
+ } ) ;
120
122
} ) ;
121
123
} ) ;
122
124
} ) ;
@@ -125,18 +127,14 @@ test.describe('interactions', () => {
125
127
test . beforeEach ( async ( { page } ) => {
126
128
await page . goto ( '/' ) ;
127
129
} ) ;
128
- test ( 'Saving the intervals reset the timer' , async ( {
129
- appPage,
130
- queries,
131
- page,
132
- } ) => {
133
- await queries . getControl ( 'Play' ) . click ( ) ;
130
+ test ( 'Saving the intervals reset the timer' , async ( { queries, page } ) => {
131
+ await queries . getButton ( 'Play' ) . click ( ) ;
134
132
await page . waitForTimeout ( 2000 ) ;
135
- await queries . getControl ( 'Settings' ) . click ( ) ;
136
- await appPage . withinSettings ( async ( settings ) => {
137
- await queries . getButton ( 'Save' , { context : settings } ) . click ( ) ;
133
+ await queries . getButton ( 'Settings' ) . click ( ) ;
134
+ await queries . withinSettings ( async ( ) => {
135
+ await queries . getButton ( 'Save' ) . click ( ) ;
138
136
} ) ;
139
137
140
- await expect ( queries . getControl ( 'Play' ) ) . toBeVisible ( ) ;
138
+ await expect ( queries . getButton ( 'Play' ) ) . toBeVisible ( ) ;
141
139
} ) ;
142
140
} ) ;
0 commit comments