Skip to content

Replace or enhance existing commands to take a programmatic approach #96

@Sidsector9

Description

@Sidsector9

Related #91

Is your enhancement related to a problem? Please describe.

Currently the commands we have take a UI approach. There are a few problems with this:

  • UI navigation is slow
  • Targeted HTML class names and IDs can change with WordPress versions, which means tests can fail on older WP versions.

We should avoid UI wherever possible. UI navigation should be for situations when we actually test UI features.
For example, to insert a paragraph block, instead of doing:

  1. Click the inserter
  2. Type in the name of the block
  3. Click the block name
  4. Type the paragraph content

We can directly call:

const paraBlock = wp.blocks.createBlock( 'core/paragraph', { content: '<CONTENT>' } );
wp.data.dispatch( 'core/editor' ).insertBlocks( paraBlock );
  1. This will be a comparatively faster approach
  2. Won't be affected by change of selectors in Block Editor
  3. Reduce test sizes in most cases

We can also modify/create existing/new commands that can take both the programmatic and the UI approach as per requirement.

This was discussed previously but it was lost in comments:

#62 (comment)

@10up/open-source-practice would be great to hear your thoughts on this.

Designs

No response

Describe alternatives you've considered

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    Status

    To Do

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions