@@ -115,7 +115,7 @@ test('removes all toast from particular container', async ({ page }) => {
115
115
} )
116
116
117
117
test ( 'renders custom component and is reactive' , async ( { page } ) => {
118
- await page . goto ( '/' , { waitUntil : 'networkidle' } )
118
+ await page . goto ( '/' )
119
119
await page . getByTestId ( 'sendComponentAsAMessage' ) . click ( )
120
120
await expect ( page . locator ( '._toastItem h1' ) ) . toHaveText ( 'A Dummy Cookie Component' )
121
121
await page . getByTestId ( 'removeLastToast' ) . click ( )
@@ -210,43 +210,25 @@ test('removes all toasts from a container target', async ({ page }) => {
210
210
await expect ( page . locator ( '._toastItem' ) ) . toHaveCount ( 0 )
211
211
} )
212
212
213
- // Playwright currently doesn't provide a way to test this
214
- // https://github.com/microsoft/playwright/issues/2286
215
- // TODO: migrate this Cypress test
216
- /*
217
- it('Toggles pause and resume on visibilitychange', () => {
218
- cy.get('[data-btn=default]')
219
- .click()
220
- .document()
221
- .then((doc) => {
222
- cy.stub(doc, 'hidden').value(true)
223
- })
224
- .document()
225
- .trigger('visibilitychange')
226
- .get('._toastBar')
227
- .then(($bar) => {
228
- const old = parseFloat($bar.val())
229
- cy.wait(500).then(() => {
230
- expect(parseFloat($bar.val())).to.be.equal(old)
231
- })
232
- })
233
- .document()
234
- .then((doc) => {
235
- cy.stub(doc, 'hidden').value(false)
236
- })
237
- .document()
238
- .trigger('visibilitychange')
239
- .get('._toastBar')
240
- .then(($bar) => {
241
- const old = parseFloat($bar.val())
242
- cy.wait(500).then(() => {
243
- expect(parseFloat($bar.val())).to.be.below(old)
244
- })
245
- })
246
- .get('._toastBtn')
247
- .click()
213
+ test ( 'toggles pause and resume on visibilitychange' , async ( { page } ) => {
214
+ const get = async ( ) => parseFloat ( await page . locator ( '._toastBar' ) . getAttribute ( 'value' ) )
215
+ const fire = async ( hidden = false ) =>
216
+ await page . evaluate ( ( value ) => {
217
+ Object . defineProperty ( document , 'hidden' , { value, writable : true } )
218
+ document . dispatchEvent ( new Event ( 'visibilitychange' ) )
219
+ } , hidden )
220
+ await page . goto ( '/' )
221
+ await page . getByTestId ( 'default' ) . click ( )
222
+ await fire ( true )
223
+ const v0 = await get ( )
224
+ await sleep ( 100 )
225
+ const v1 = await get ( )
226
+ expect ( v0 ) . toEqual ( v1 )
227
+ await fire ( false )
228
+ await sleep ( 100 )
229
+ const v2 = await get ( )
230
+ expect ( v2 ) . toBeLessThan ( v1 )
248
231
} )
249
- */
250
232
251
233
// Backward compatibility tests
252
234
0 commit comments