-
Notifications
You must be signed in to change notification settings - Fork 8
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
Command/39 checkPostExists
from any CPT
#61
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
Potentially chainable command. IMO, we should wrap the result and don't fail if the post doesn't exist. |
@faisal-alvi I have a suggestion to make this command run faster, effectively running tests faster. The admin page exposes the fetch( `${Cypress.config().baseUrl}/wp-json/wp/v2/post?s="${searchString}"` )
.then( response => {
return response.json();
} )
.then( data => {
// Run assertions here.
} ); Let me know what you think of this. Thanks! |
# Conflicts: # src/index.ts
@Sidsector9 thanks for the suggestion, however, I can see only one drawback of using the REST API. It won't work with the CPTs in which the REST API support is disabled, i.e. |
@cadic thanks for the suggestion, the result is now wrapped and returned. |
Fair point @faisal-alvi Although, we can still have the best of both worlds:
|
@faisal-alvi thank you for the command. I've added few tests to cover the functionality in both situations (post exists or not) |
@cadic any thoughts on @Sidsector9's ^recommendation? |
* Command/39 `checkPostExists` from any CPT * adding examples in documentation * command/39 wrapping the result and return * Add real tests * Activate Classic Editor * test name fix * Use block editor to create test posts * Ignore WP 5.2 Synchronous XHR error Co-authored-by: Faisal Alvi <[email protected]> Co-authored-by: Max Lyuchin <[email protected]>
Description of the Change
Added a new command
checkPostExists
which checks whether a given post title exists in a specified post type or not.It accepts the following parameters.
title
: Post Title.postType
: Post type. Default topost
.Note: The command searches for the exact
title
on the site. It fails the test if the title string does not match.Closes #39
Verification Process
npm run build
.npm run env:start
.npm run cypress:open
.check-post-exists.test.js
./tests/cypress/integration/check-post-exists.test.js
file and see the test should fail.Checklist:
Changelog Entry
Credits
Props @faisal-alvi