-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e): add Modal and Popup anchor check
- Loading branch information
1 parent
ce610a5
commit f981a59
Showing
2 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { test, expect } from '@wordpress/e2e-test-utils-playwright'; | ||
|
||
test.describe( 'Modal', () => { | ||
test.beforeEach( async({ admin }) => { | ||
await admin.createNewPost(); | ||
}); | ||
|
||
test( 'anchor to a button', async({ editor, page }) => { | ||
await editor.insertBlock({ | ||
name: 'core/buttons', | ||
attributes: {}, | ||
innerBlocks: [ | ||
{ | ||
name: 'core/button', | ||
attributes: { | ||
text: 'Open Modal', | ||
anchor: 'modal-trigger' | ||
} | ||
} | ||
] | ||
}); | ||
|
||
await editor.insertBlock({ | ||
name: 'themeisle-blocks/modal', | ||
attributes: { | ||
anchor: 'modal-trigger' | ||
}, | ||
innerBlocks: [ | ||
{ | ||
name: 'core/paragraph', | ||
attributes: { | ||
content: 'Popup Content Test' | ||
} | ||
} | ||
] | ||
}); | ||
|
||
const postId = await editor.publishPost(); | ||
await page.goto( `/?p=${postId}` ); | ||
|
||
await page.locator( 'div' ).filter({ hasText: /^Open Modal$/ }).click(); | ||
|
||
await expect( page.getByText( 'Popup Content Test' ) ).toBeVisible(); | ||
}); | ||
|
||
test( 'close on escape', async({ editor, page }) => { | ||
|
||
await editor.insertBlock({ | ||
name: 'core/buttons', | ||
attributes: {}, | ||
innerBlocks: [ | ||
{ | ||
name: 'core/button', | ||
attributes: { | ||
text: 'Open Modal', | ||
anchor: 'modal-trigger' | ||
} | ||
} | ||
] | ||
}); | ||
|
||
await editor.insertBlock({ | ||
name: 'themeisle-blocks/modal', | ||
attributes: { | ||
anchor: 'modal-trigger' | ||
}, | ||
innerBlocks: [ | ||
{ | ||
name: 'core/paragraph', | ||
attributes: { | ||
content: 'Popup Content Test' | ||
} | ||
} | ||
] | ||
}); | ||
|
||
const postId = await editor.publishPost(); | ||
await page.goto( `/?p=${postId}` ); | ||
|
||
await page.locator( 'div' ).filter({ hasText: /^Open Modal$/ }).click(); | ||
|
||
await expect( page.getByText( 'Popup Content Test' ) ).toBeVisible(); | ||
await page.keyboard.press( 'Escape' ); | ||
await expect( page.getByText( 'Popup Content Test' ) ).toBeHidden(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters