-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First pass at automating some of the default state assertions for Soc…
…ial Icons, e.g., which Social Icons are rendered, in/active, hyperlinked, etc. The manual tests being referenced come from here: https://github.com/wordpress-mobile/test-cases/blob/trunk/test-cases/gutenberg/social-icons.md#tc001
- Loading branch information
Showing
6 changed files
with
163 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
140 changes: 140 additions & 0 deletions
140
packages/block-library/src/social-link/test/index.native.js
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,140 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
// noinspection DuplicatedCode | ||
import { fireEvent, initializeEditor, waitFor, within } from 'test/helpers'; | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { registerCoreBlocks } from '@wordpress/block-library'; | ||
import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks'; | ||
|
||
const unregisterBlocks = () => { | ||
const blocks = getBlockTypes(); | ||
|
||
blocks.forEach( ( { name } ) => unregisterBlockType( name ) ); | ||
}; | ||
|
||
describe( '<SocialLinkEdit/>', () => { | ||
beforeAll( () => { | ||
registerCoreBlocks(); | ||
} ); | ||
|
||
afterAll( () => { | ||
unregisterBlocks(); | ||
} ); | ||
|
||
/** | ||
* GIVEN an EDITOR is displayed; | ||
* WHEN a SOCIAL ICONS BLOCK is selected from the BLOCK INSERTER; | ||
*/ | ||
it( 'should display WORDPRESS, FACEBOOK, TWITTER, INSTAGRAM by default.', async () => { | ||
// Arrange | ||
const subject = await initializeEditor( {} ); | ||
|
||
// Act | ||
fireEvent.press( | ||
await waitFor( () => subject.getByA11yLabel( 'Add block' ) ) | ||
); | ||
fireEvent.changeText( | ||
await waitFor( () => | ||
subject.getByPlaceholderText( 'Search blocks' ) | ||
), | ||
'social icons' | ||
); | ||
fireEvent.press( | ||
await waitFor( () => | ||
subject.getByA11yLabel( 'Social Icons block' ) | ||
) | ||
); | ||
fireEvent( | ||
await waitFor( () => | ||
within( | ||
subject.getByA11yLabel( /Social Icons Block. Row 1/ ) | ||
).getByTestId( 'block-list-wrapper' ) | ||
), | ||
'layout', | ||
{ nativeEvent: { layout: { width: 100 } } } | ||
); | ||
|
||
// Assert | ||
expect( | ||
await waitFor( () => | ||
subject.getByA11yLabel( /WordPress social icon/ ) | ||
) | ||
).toBeDefined(); | ||
expect( | ||
await waitFor( () => | ||
subject.getByA11yLabel( /Facebook social icon/ ) | ||
) | ||
).toBeDefined(); | ||
expect( | ||
await waitFor( () => | ||
subject.getByA11yLabel( /Twitter social icon/ ) | ||
) | ||
).toBeDefined(); | ||
expect( | ||
await waitFor( () => | ||
subject.getByA11yLabel( /Instagram social icon/ ) | ||
) | ||
).toBeDefined(); | ||
} ); | ||
|
||
/** | ||
* GIVEN an EDITOR is displayed; | ||
* WHEN a SOCIAL ICONS BLOCK is selected from the BLOCK INSERTER; | ||
*/ | ||
it( `should display WORDPRESS with a URL set by default | ||
AND should display FACEBOOK, TWITTER, INSTAGRAM with NO URL set by default.`, async () => { | ||
// Arrange | ||
const subject = await initializeEditor( {} ); | ||
|
||
// Act | ||
fireEvent.press( | ||
await waitFor( () => subject.getByA11yLabel( 'Add block' ) ) | ||
); | ||
fireEvent.changeText( | ||
await waitFor( () => | ||
subject.getByPlaceholderText( 'Search blocks' ) | ||
), | ||
'social icons' | ||
); | ||
fireEvent.press( | ||
await waitFor( () => | ||
subject.getByA11yLabel( 'Social Icons block' ) | ||
) | ||
); | ||
fireEvent( | ||
await waitFor( () => | ||
within( | ||
subject.getByA11yLabel( /Social Icons Block. Row 1/ ) | ||
).getByTestId( 'block-list-wrapper' ) | ||
), | ||
'layout', | ||
{ nativeEvent: { layout: { width: 100 } } } | ||
); | ||
|
||
// Assert | ||
expect( | ||
await waitFor( () => | ||
subject.getByA11yHint( /WordPress has URL set/ ) | ||
) | ||
).toBeDefined(); | ||
expect( | ||
await waitFor( () => | ||
subject.getByA11yHint( /Facebook has no URL set/ ) | ||
) | ||
).toBeDefined(); | ||
expect( | ||
await waitFor( () => | ||
subject.getByA11yHint( /Twitter has no URL set/ ) | ||
) | ||
).toBeDefined(); | ||
expect( | ||
await waitFor( () => | ||
subject.getByA11yHint( /Instagram has no URL set/ ) | ||
) | ||
).toBeDefined(); | ||
// console.log( JSON.stringify( subject.toJSON(), null, 1 ) ); | ||
} ); | ||
} ); |
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
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
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