-
Notifications
You must be signed in to change notification settings - Fork 315
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
Fix remove from index on update #3937
base: develop
Are you sure you want to change the base?
Changes from all commits
1f22e86
eafddcc
0789506
3b9e46d
3d8d9c7
df90727
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test should either go to the protected-content.cy.js file or (preferably) to indexables/post.cy.js, but we'll need to make sure the test actually fails if we remove those additional |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
describe('Set password on post', () => { | ||
it('Removes Post from Index when Password is Set', () => { | ||
cy.login(); | ||
cy.maybeDisableFeature('protected_content'); | ||
|
||
// Delete previous posts, so we can be sure we just expect 1 post. | ||
cy.wpCli('post list --format=ids').then((wpCliResponse) => { | ||
if (wpCliResponse.stdout !== '') { | ||
cy.wpCli(`post delete ${wpCliResponse.stdout}`); | ||
} | ||
}); | ||
|
||
cy.publishPost({ | ||
title: 'Protected Post Removal Test', | ||
}); | ||
|
||
/** | ||
* Give Elasticsearch some time to process the new post. | ||
* | ||
* @todo instead of waiting for an arbitrary time, we should ensure the post is stored. | ||
*/ | ||
// eslint-disable-next-line cypress/no-unnecessary-waiting | ||
cy.wait(2000); | ||
|
||
// Post is indexed | ||
cy.visit('/?s=Protected+Post+Removal+Test'); | ||
cy.contains('.site-content article h2', 'Protected Post Removal Test').should('exist'); | ||
|
||
cy.wpCli('post list --format=ids').then((wpCliResponse) => { | ||
if (wpCliResponse.stdout !== '') { | ||
cy.postSetPassword(wpCliResponse.stdout, 'enter'); | ||
} | ||
}); | ||
|
||
/** | ||
* Give Elasticsearch some time to process the update. | ||
* | ||
* @todo instead of waiting for an arbitrary time, we should ensure the post is stored. | ||
*/ | ||
// eslint-disable-next-line cypress/no-unnecessary-waiting | ||
cy.wait(2000); | ||
|
||
// Post is removed from index | ||
cy.visit('/?s=Protected+Post+Removal+Test'); | ||
cy.contains('.site-content article h2', 'Protected Post Removal Test').should('not.exist'); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -202,6 +202,26 @@ Cypress.Commands.add('publishPost', (postData, viewPost) => { | |
cy.wait(2000); | ||
}); | ||
|
||
Cypress.Commands.add('postSetPassword', (id, password) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we rename this to |
||
cy.visitAdminPage(`post.php?post=${id}&action=edit`); | ||
cy.get('h1.editor-post-title__input').click(); | ||
cy.get('body').then(($body) => { | ||
const $button = $body.find('.edit-post-post-visibility__toggle'); | ||
if (!$button.is(':visible')) { | ||
cy.get('.edit-post-header__settings button[aria-label="Settings"]').click(); | ||
} | ||
}); | ||
cy.get('.edit-post-post-visibility__toggle').click(); | ||
cy.get('.editor-post-visibility__dialog-radio, .editor-post-visibility__radio').check( | ||
'password', | ||
); | ||
cy.get( | ||
'.editor-post-visibility__dialog-password-input, .editor-post-visibility__password-input', | ||
).type(password); | ||
|
||
cy.get('.editor-post-publish-button').click(); | ||
}); | ||
|
||
Cypress.Commands.add('updateFeatures', (featureName, newValues) => { | ||
const escapedNewValues = JSON.stringify(newValues); | ||
|
||
|
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.
Since EP 5.0.0 the sync_queue is indexed by the blog ID, so this
if
can go away (we check the same thing a bit further down.)