Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic E2E test for blocks. #174

Merged
merged 29 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1ad4b9b
Add e2e utils package.
ryanwelcher Oct 25, 2021
7b41c22
Adds .eslintrc
ryanwelcher Oct 25, 2021
ee288c5
Add e2e to CI
ryanwelcher Oct 25, 2021
2934466
Add tests for first 5 blocks.
ryanwelcher Oct 25, 2021
786ef21
Add remaining tests and snapshot data.
ryanwelcher Oct 25, 2021
4154f04
Fix syntax error.
ryanwelcher Oct 25, 2021
420a630
Use correct script name.
ryanwelcher Oct 25, 2021
8ad14f3
Remove import approach to test for timeout.
ryanwelcher Oct 25, 2021
b9f8cb9
Add e2e workflow.
ryanwelcher Oct 25, 2021
5084006
Spaces.
ryanwelcher Oct 25, 2021
6c65a35
Use inline snapshots and increase test timeout.
ryanwelcher Oct 26, 2021
2640079
Move all tests into /tests in corresponding block directory and rena…
ryanwelcher Oct 26, 2021
b6d0eb7
Change timeout to 30 seconds to match changes in scripts package.
ryanwelcher Oct 27, 2021
8d2891f
Remove tests from the first three blocks to reduce ramp up.
ryanwelcher Oct 27, 2021
c6bcb50
Remove timeout change.
ryanwelcher Dec 1, 2021
22c30d3
Update packages.
ryanwelcher Dec 1, 2021
ad24fbd
Revert "Update packages."
ryanwelcher Dec 1, 2021
cb1225a
Merge branch 'trunk' into feature/basic-e2e-tests
ryanwelcher Mar 7, 2023
6aa4573
Update packages.
ryanwelcher Mar 7, 2023
671e894
Remove test directory. The tests don't work and have to real use.
ryanwelcher Mar 7, 2023
9eee50a
Move basic block e2e tests into corresponding directory.
ryanwelcher Mar 7, 2023
8715ca6
Ignore the e2e folders when linting js.
ryanwelcher Mar 7, 2023
aeb3ebc
Add build to e2e workflow.
ryanwelcher Mar 7, 2023
9bfa144
Spaces, not tabs 🤦
ryanwelcher Mar 7, 2023
643e4bf
Update .github/workflows/e2e-tests.yml
ryanwelcher Mar 8, 2023
d4ecb3b
Update .github/workflows/e2e-tests.yml
ryanwelcher Mar 8, 2023
8bb9c03
Add changes to the build process per code review.
ryanwelcher Mar 8, 2023
5604829
Whitespace issues.
ryanwelcher Mar 8, 2023
c55b2e6
Update .github/workflows/e2e-tests.yml
ryanwelcher Mar 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": [ "plugin:@wordpress/eslint-plugin/recommended" ]
}
23 changes: 23 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: E2E Tests

on:
pull_request:
push:
branches:
- trunk
jobs:
e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, start env and run e2e tests
run: |
npm ci
npm run env:start
npm run test:e2e
env:
CI: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ index.js.map
.vscode

/vendor/
artifacts
28 changes: 28 additions & 0 deletions 03-editable-esnext/tests/basic.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* WordPress dependencies
*/
import {
getEditedPostContent,
insertBlock,
createNewPost,
} from '@wordpress/e2e-test-utils';

/**
* Internal dependencies
*/
import json from '../block.json';
const { title, name } = json;

it( `${ title } block should be available`, async () => {
await createNewPost();
await insertBlock( title );

// Check if block was inserted
expect( await page.$( `[data-type="${ name }"]` ) ).not.toBeNull();

expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
"<!-- wp:gutenberg-examples/example-03-editable-esnext -->
<p class=\\"wp-block-gutenberg-examples-example-03-editable-esnext\\"></p>
<!-- /wp:gutenberg-examples/example-03-editable-esnext -->"
` );
} );
28 changes: 28 additions & 0 deletions 03-editable/tests/basic.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* WordPress dependencies
*/
import {
getEditedPostContent,
insertBlock,
createNewPost,
} from '@wordpress/e2e-test-utils';

/**
* Internal dependencies
*/
import json from '../block.json';
const { title, name } = json;

it( `${ title } block should be available`, async () => {
await createNewPost();
await insertBlock( title );

// Check if block was inserted
expect( await page.$( `[data-type="${ name }"]` ) ).not.toBeNull();

expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
"<!-- wp:gutenberg-examples/example-03-editable -->
<p class=\\"wp-block-gutenberg-examples-example-03-editable\\"></p>
<!-- /wp:gutenberg-examples/example-03-editable -->"
` );
} );
28 changes: 28 additions & 0 deletions 04-controls-esnext/tests/basic.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* WordPress dependencies
*/
import {
getEditedPostContent,
insertBlock,
createNewPost,
} from '@wordpress/e2e-test-utils';

/**
* Internal dependencies
*/
import json from '../block.json';
const { title, name } = json;

it( `${ title } block should be available`, async () => {
await createNewPost();
await insertBlock( title );

// Check if block was inserted
expect( await page.$( `[data-type="${ name }"]` ) ).not.toBeNull();

expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
"<!-- wp:gutenberg-examples/example-04-controls-esnext -->
<p class=\\"wp-block-gutenberg-examples-example-04-controls-esnext gutenberg-examples-align-none\\"></p>
<!-- /wp:gutenberg-examples/example-04-controls-esnext -->"
` );
} );
28 changes: 28 additions & 0 deletions 04-controls/tests/basic.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* WordPress dependencies
*/
import {
getEditedPostContent,
insertBlock,
createNewPost,
} from '@wordpress/e2e-test-utils';

/**
* Internal dependencies
*/
import json from '../block.json';
const { title, name } = json;

it( `${ title } block should be available`, async () => {
await createNewPost();
await insertBlock( title );

// Check if block was inserted
expect( await page.$( `[data-type="${ name }"]` ) ).not.toBeNull();

expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
"<!-- wp:gutenberg-examples/example-04-controls -->
<p class=\\"wp-block-gutenberg-examples-example-04-controls gutenberg-examples-align-none\\"></p>
<!-- /wp:gutenberg-examples/example-04-controls -->"
` );
} );
28 changes: 28 additions & 0 deletions 05-recipe-card-esnext/tests/basic.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* WordPress dependencies
*/
import {
getEditedPostContent,
insertBlock,
createNewPost,
} from '@wordpress/e2e-test-utils';

/**
* Internal dependencies
*/
import json from '../block.json';
const { title, name } = json;

it( `${ title } block should be available`, async () => {
await createNewPost();
await insertBlock( title );

// Check if block was inserted
expect( await page.$( `[data-type="${ name }"]` ) ).not.toBeNull();

expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
"<!-- wp:gutenberg-examples/example-05-recipe-card-esnext -->
<div class=\\"wp-block-gutenberg-examples-example-05-recipe-card-esnext\\"><h2></h2><h3>Ingredients</h3><ul class=\\"ingredients\\"></ul><h3>Instructions</h3><div class=\\"steps\\"></div></div>
<!-- /wp:gutenberg-examples/example-05-recipe-card-esnext -->"
` );
} );
28 changes: 28 additions & 0 deletions 05-recipe-card/tests/basic.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* WordPress dependencies
*/
import {
getEditedPostContent,
insertBlock,
createNewPost,
} from '@wordpress/e2e-test-utils';

/**
* Internal dependencies
*/
import json from '../block.json';
const { title, name } = json;

it( `${ title } block should be available`, async () => {
await createNewPost();
await insertBlock( title );

// Check if block was inserted
expect( await page.$( `[data-type="${ name }"]` ) ).not.toBeNull();

expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
"<!-- wp:gutenberg-examples/example-05-recipe-card -->
<div class=\\"wp-block-gutenberg-examples-example-05-recipe-card\\"><h2></h2><h3>Ingredients</h3><ul class=\\"ingredients\\"></ul><h3>Instructions</h3><div class=\\"steps\\"></div></div>
<!-- /wp:gutenberg-examples/example-05-recipe-card -->"
` );
} );
28 changes: 28 additions & 0 deletions 06-inner-blocks-esnext/tests/basic.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* WordPress dependencies
*/
import {
getEditedPostContent,
insertBlock,
createNewPost,
} from '@wordpress/e2e-test-utils';

/**
* Internal dependencies
*/
import json from '../block.json';
const { title, name } = json;

it( `${ title } block should be available`, async () => {
await createNewPost();
await insertBlock( title );

// Check if block was inserted
expect( await page.$( `[data-type="${ name }"]` ) ).not.toBeNull();

expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
"<!-- wp:gutenberg-examples/example-06-esnext -->
<div class=\\"wp-block-gutenberg-examples-example-06-esnext\\"></div>
<!-- /wp:gutenberg-examples/example-06-esnext -->"
` );
} );
31 changes: 31 additions & 0 deletions 06-inner-blocks/tests/basic.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* WordPress dependencies
*/
import {
getEditedPostContent,
insertBlock,
createNewPost,
} from '@wordpress/e2e-test-utils';

/**
* Internal dependencies
*/
import json from '../block.json';
const { title, name } = json;

// Increase the timeout limit for this test.
jest.setTimeout( 30000 );

it( `${ title } block should be available`, async () => {
await createNewPost();
await insertBlock( title );

// Check if block was inserted
expect( await page.$( `[data-type="${ name }"]` ) ).not.toBeNull();

expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
"<!-- wp:gutenberg-examples/example-06 -->
<div class=\\"wp-block-gutenberg-examples-example-06\\"></div>
<!-- /wp:gutenberg-examples/example-06 -->"
` );
} );
Loading