@@ -193,8 +193,18 @@ test('can change dismiss btn char', async ({ page }) => {
193193 expect ( btn ) . toBe ( '"x"' )
194194} )
195195
196- // Playwright currently does not provide a way to test this
196+ test ( 'removes all toasts from a container target' , async ( { page } ) => {
197+ await page . goto ( '/' )
198+ for ( let a = 0 ; a < 3 ; a ++ ) {
199+ await page . getByTestId ( 'createNewToastContainer' ) . click ( )
200+ }
201+ await page . getByTestId ( 'removeAllToastsFromContainer' ) . click ( )
202+ await expect ( page . locator ( '._toastItem' ) ) . toHaveCount ( 0 )
203+ } )
204+
205+ // Playwright currently doesn't provide a way to test this
197206// https://github.com/microsoft/playwright/issues/2286
207+ // TODO: migrate this Cypress test
198208/*
199209it('Toggles pause and resume on visibilitychange', () => {
200210 cy.get('[data-btn=default]')
@@ -249,3 +259,12 @@ test('`push()` accepts both string and obj', async ({ page }) => {
249259 await page . evaluate ( `window.toast.push({msg:'push with obj'})` )
250260 await expect ( page . getByText ( 'push with obj' ) ) . toBeVisible ( )
251261} )
262+
263+ test ( 'removes toasts from container via filter fn' , async ( { page } ) => {
264+ await page . goto ( '/' , { waitUntil : 'networkidle' } )
265+ for ( let a = 0 ; a < 3 ; a ++ ) {
266+ await page . getByTestId ( 'createNewToastContainer' ) . click ( )
267+ }
268+ await page . evaluate ( `window.toast.pop(i=>i.target!=='new')` )
269+ await expect ( page . locator ( '._toastItem' ) ) . toHaveCount ( 0 )
270+ } )
0 commit comments