From 74328e12fa92ba8a603521e58cab29aab7f77d55 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Tue, 16 Aug 2022 17:01:45 +0500 Subject: [PATCH] Add post terms test --- .../features/search/search.spec.js | 15 +++++++++++++ tests/cypress/support/commands.js | 22 ++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/cypress/integration/features/search/search.spec.js b/tests/cypress/integration/features/search/search.spec.js index bc7beda505..b8de2b3a87 100644 --- a/tests/cypress/integration/features/search/search.spec.js +++ b/tests/cypress/integration/features/search/search.spec.js @@ -141,4 +141,19 @@ describe('Post Search Feature', () => { ); }); }); + + it('Can update related posts when the term is updated', () => { + cy.createTerm({ name: 'test-category' }); + + cy.publishPost({ + title: 'Test Post 1', + category: 'test-category', + }); + + cy.publishPost({ + title: 'Test Post 2', + category: 'test-category', + }); + + }); }); diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index b584341b9d..ba4a374646 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -114,7 +114,12 @@ Cypress.Commands.add('wpCliEval', (command) => { }); Cypress.Commands.add('publishPost', (postData, viewPost) => { - const newPostData = { title: 'Test Post', content: 'Test content.', ...postData }; + const newPostData = { + title: 'Test Post', + content: 'Test content.', + category: null, + ...postData, + }; cy.visitAdminPage('post-new.php'); cy.get('h1.editor-post-title__input, #post-title-0').should('exist'); @@ -131,6 +136,21 @@ Cypress.Commands.add('publishPost', (postData, viewPost) => { cy.get('h1.editor-post-title__input, #post-title-0').clearThenType(newPostData.title); cy.get('.block-editor-default-block-appender__content').type(newPostData.content); + if (newPostData.category !== null) { + cy.get('.edit-post-sidebar__panel-tab').first().click(); + cy.contains('.components-panel__body-toggle', 'Categories') + .click() + .then(() => { + cy.get('.editor-post-taxonomies__hierarchical-terms-filter input', { + timeout: 10000, + }).type('test-category'); + + cy.get('.editor-post-taxonomies__hierarchical-terms-choice label').click({ + force: true, + }); + }); + } + if (newPostData.status && newPostData.status === 'draft') { cy.get('.editor-post-save-draft').click(); cy.get('.editor-post-saved-state').should('have.text', 'Saved');