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

Autocomplete Component: add e2e tests (take two) #42905

Merged
merged 55 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
bfb52cf
add initial autocomplete e2e test structure
chad1008 Jul 21, 2022
399879a
add newline regression test
chad1008 Jul 21, 2022
382092a
add multiple completer crash regression test
chad1008 Jul 21, 2022
c0a886e
add autocomplete disable option test
chad1008 Jul 22, 2022
b4d8506
add more test autocomplete options and the `Escape` keypress test
chad1008 Jul 22, 2022
377b180
add keypress selection test
chad1008 Jul 25, 2022
49b0060
remove out-of-place JSX
chad1008 Jul 25, 2022
0f5b3a7
add click event test
chad1008 Jul 25, 2022
520293e
update order of tests
chad1008 Jul 25, 2022
f6fd408
update CHANGELOG
chad1008 Jul 25, 2022
97bc7c5
fix php doc spacing
chad1008 Jul 25, 2022
e87fd73
replace hard-coded classes with role selectors
chad1008 Jul 26, 2022
ee1c181
add EOF newline
chad1008 Jul 26, 2022
a0378b0
remove superfluous waitForXPath call
chad1008 Jul 26, 2022
2fcace8
add text content matching to XPath checks
chad1008 Jul 26, 2022
48e2e57
create new combined suite scaffold
chad1008 Jul 28, 2022
9e8a234
implement basic autocompletion test
chad1008 Jul 28, 2022
bc6bbef
implement test for inserting a completion between two words
chad1008 Jul 28, 2022
b1aa177
implement test for two subsequent completions
chad1008 Jul 28, 2022
42b8737
implement click event test
chad1008 Jul 28, 2022
4d17956
implement test for keypress interaction
chad1008 Jul 29, 2022
6569de5
implement test for `escape` keypress
chad1008 Aug 1, 2022
518a9b0
publish post after each test
chad1008 Aug 1, 2022
952a8cc
implement a test for disable options (custom completers only)
chad1008 Aug 1, 2022
71b5a58
remove unneeded `else` statements
chad1008 Aug 1, 2022
0a9e274
implement regression test for text/newlines after multiple completers
chad1008 Aug 1, 2022
dbd5c60
implement test for multiple async completers
chad1008 Aug 2, 2022
9b7b82f
remove old test files
chad1008 Aug 2, 2022
c22fafd
Autocomplete: skip regression test that causes a crashing infinite loop
chad1008 Aug 29, 2022
d4d4463
Autocomplete: add doc for itif e2e helper
chad1008 Aug 29, 2022
ab1d3cb
remove accidental regression test changes
chad1008 Aug 31, 2022
720453d
Autocomplete: update e2e test comment
chad1008 Sep 1, 2022
887cba3
Autocomplete: remove itif e2e helper function
chad1008 Sep 1, 2022
186ae25
Autocomplete: move test file for Playwright refactor. Update imports …
chad1008 Sep 19, 2022
d1e393c
Autocomplete: add `forEach` loop to replace `describe.each` in e2e te…
chad1008 Sep 19, 2022
3805648
remove old `describe.each` block
chad1008 Sep 19, 2022
02636e9
Autocomplete: refactor e2e to use Playwright `requestUtils` imports
chad1008 Sep 19, 2022
f44780f
update user list for playwright utils
chad1008 Sep 19, 2022
0d55755
Autocomplete: refactor e2e to use Playwright utils for new post creat…
chad1008 Sep 19, 2022
8c19eaf
Autocomplete: refactor away from Puppeteer e2e clickBlockAppender util
chad1008 Sep 19, 2022
5f8b2bd
Autocomplete: update refactor e2e snapshots
chad1008 Sep 19, 2022
78dbac1
Autocomplete: refactor e2e to Playwright utils `pressKeyTimes`
chad1008 Sep 19, 2022
d2fa25d
Autocomplete: refactor `waitForXPath` to Playwright locators
chad1008 Sep 20, 2022
7859b4b
Autocomplete: restore xpath selectors
chad1008 Sep 20, 2022
afa599d
Autocomplete: fix click event
chad1008 Sep 20, 2022
26c4e79
Autocomplete: minor snapshot formatting fixes
chad1008 Sep 20, 2022
2d88eb6
Autocomplete: add completer label to test names
chad1008 Sep 21, 2022
ea96190
Autocomplete: restore infinite loop regression test
chad1008 Sep 21, 2022
5bbad6e
Autocomplete: convert e2e test expectations to role selectors
chad1008 Sep 26, 2022
3886ba4
Autocomplete: run e2e test user creation concurrently
chad1008 Sep 26, 2022
c0936b2
Components: update CHANGELOG
chad1008 Sep 26, 2022
00b0116
Autocomplete: update e2e testdata naming
chad1008 Sep 26, 2022
29d0d57
Autocomplete: use `.poll` for promise-assertions
chad1008 Sep 26, 2022
f66ea47
Autocomplete: update e2e regression test comment
chad1008 Sep 26, 2022
1ead803
Autocomplete: replace `hasText` with `name` attribute in e2e
chad1008 Sep 28, 2022
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
4 changes: 4 additions & 0 deletions packages/e2e-tests/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### New features

- Added Autocomplete Component e2e test suite. [#42905](https://github.com/WordPress/gutenberg/pull/42905).

## 5.2.0 (2022-09-21)

## 5.0.0 (2022-08-24)
Expand Down
27 changes: 27 additions & 0 deletions packages/e2e-tests/plugins/test-autocompleter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Plugin Name: Gutenberg Test Autocompleter
* Plugin URI: https://github.com/WordPress/gutenberg
* Author: Gutenberg Team
*
* @package gutenberg-test-autocompleter
*/

/**
* Registers a custom script for the plugin.
*/
function enqueue_test_autocompleter_plugin_script() {
wp_enqueue_script(
'gutenberg-test-autocompleter',
plugins_url( 'test-autocompleter/index.js', __FILE__ ),
array(
'wp-hooks',
'wp-element',
'wp-block-editor',
),
filemtime( plugin_dir_path( __FILE__ ) . 'test-autocompleter/index.js' ),
false
);
}

add_action( 'init', 'enqueue_test_autocompleter_plugin_script' );
55 changes: 55 additions & 0 deletions packages/e2e-tests/plugins/test-autocompleter/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
(function () {
const fruits = {
name: 'fruit',
// The prefix that triggers this completer
triggerPrefix: '~',
// The option data
options: [
{ visual: '🍎', name: 'Apple', id: 1 },
{ visual: '🍊', name: 'Orange', id: 2 },
{ visual: '🍇', name: 'Grapes', id: 3 },
{ visual: '🥭', name: 'Mango', id: 4 },
{ visual: '🍓', name: 'Strawberry', id: 5 },
{ visual: '🫐', name: 'Blueberry', id: 6 },
{ visual: '🍒', name: 'Cherry', id: 7 },
],
// Returns a label for an option like "🍊 Orange"
getOptionLabel: ( option ) => `${ option.visual } ${ option.name }`,
// Declares that options should be matched by their name
getOptionKeywords: ( option ) => [ option.name ],
// Declares that the Grapes option is disabled
isOptionDisabled: ( option ) => option.name === 'Grapes',
// Declares completions should be inserted as abbreviations
getOptionCompletion: ( option ) => (
option.visual
),
};

function duplicateUserMentions( completers ) {
const [ users ] = completers.filter(
( completer ) => completer.name === 'users'
);
return {
...users,
name: 'users-copy',
triggerPrefix: '+',
getOptionCompletion: ( user ) => `+${ user.slug }`,
};
}

function appendTestCompleters( completers, blockName ) {
const copiedUsers = duplicateUserMentions( completers );
return blockName === 'core/paragraph'
? [ ...completers, fruits, copiedUsers ]
: completers;
}

// Adding the filter with a priority of 11
// to ensure it fires after the default user mentions are added.
wp.hooks.addFilter(
'editor.Autocomplete.completers',
'editor/autocompleters/test',
appendTestCompleters,
11
);
})()
69 changes: 0 additions & 69 deletions packages/e2e-tests/specs/editor/various/mentions.test.js

This file was deleted.

Loading