diff --git a/cypress/integration/common/search.js b/cypress/integration/common/search.js index 110278cb0..1cada998f 100644 --- a/cypress/integration/common/search.js +++ b/cypress/integration/common/search.js @@ -5,17 +5,18 @@ When("I search for {string}", value => { .type(value); }); -Then("I should have one post in the select dropdown", () => { - cy.get(".input .ds-select-dropdown").should($li => { +Then("I should have one item in the select dropdown", () => { + cy.get(".searchable-input .ds-select-dropdown").should($li => { expect($li).to.have.length(1); }); }); Then("the search has no results", () => { - cy.get(".input .ds-select-dropdown").should($li => { + cy.get(".searchable-input .ds-select-dropdown").should($li => { expect($li).to.have.length(1); }); cy.get(".ds-select-dropdown").should("contain", 'Nothing found'); + cy.get(".search-clear-btn").trigger("click"); }); Then("I should see the following posts in the select dropdown:", table => { @@ -24,6 +25,13 @@ Then("I should see the following posts in the select dropdown:", table => { }); }); +Then("I should see the following users in the select dropdown:", table => { + cy.get(".ds-heading").should("contain", "Users"); + table.hashes().forEach(({ slug }) => { + cy.get(".ds-select-dropdown").should("contain", slug); + }); +}); + When("I type {string} and press Enter", value => { cy.get("#search-resources") .focus() @@ -42,8 +50,8 @@ Then("the search field should clear", () => { cy.get("#search-resources").should("have.text", ""); }); -When("I select an entry", () => { - cy.get(".input .ds-select-dropdown ul li") +When("I select a post entry", () => { + cy.get(".searchable-input .search-post") .first() .trigger("click"); }); @@ -75,3 +83,13 @@ Then( ); } ); + +Then("I select a user entry", () => { + cy.get(".searchable-input .userinfo") + .first() + .trigger("click"); +}) + +Then("I should be on the user's profile", () => { + cy.location("pathname").should("eq", "/profile/user-for-search/search-for-me") +}) \ No newline at end of file diff --git a/cypress/integration/search/Search.feature b/cypress/integration/search/Search.feature index c1afc5b97..e83f58477 100644 --- a/cypress/integration/search/Search.feature +++ b/cypress/integration/search/Search.feature @@ -9,18 +9,23 @@ Feature: Search | id | title | content | | p1 | 101 Essays that will change the way you think | 101 Essays, of course! | | p2 | No searched for content | will be found in this post, I guarantee | + And we have the following user accounts: + | slug | name | id | + | search-for-me | Search for me | user-for-search | + | not-to-be-found | Not to be found | just-an-id | + Given I am logged in Scenario: Search for specific words When I search for "Essays" - Then I should have one post in the select dropdown + Then I should have one item in the select dropdown Then I should see the following posts in the select dropdown: | title | | 101 Essays that will change the way you think | Scenario: Press enter starts search - When I type "Essa" and press Enter - Then I should have one post in the select dropdown + When I type "Es" and press Enter + Then I should have one item in the select dropdown Then I should see the following posts in the select dropdown: | title | | 101 Essays that will change the way you think | @@ -31,11 +36,20 @@ Feature: Search Scenario: Select entry goes to post When I search for "Essays" - And I select an entry + And I select a post entry Then I should be on the post's page Scenario: Select dropdown content When I search for "Essays" - Then I should have one post in the select dropdown + Then I should have one item in the select dropdown Then I should see posts with the searched-for term in the select dropdown And I should not see posts without the searched-for term in the select dropdown + + Scenario: Search for users + Given I search for "Search" + Then I should have one item in the select dropdown + And I should see the following users in the select dropdown: + | slug | + | search-for-me | + And I select a user entry + Then I should be on the user's profile \ No newline at end of file diff --git a/cypress/integration/user_profile/blocked-users/Blocking.feature b/cypress/integration/user_profile/blocked-users/Blocking.feature index 41a548e36..9b27f82a3 100644 --- a/cypress/integration/user_profile/blocked-users/Blocking.feature +++ b/cypress/integration/user_profile/blocked-users/Blocking.feature @@ -37,7 +37,7 @@ Feature: Block a User And I refresh the page And I search for "Spam" Then the search has no results - But I search for "blocked" + But I search for "not blocked" Then I should see the following posts in the select dropdown: | title | | Post that should be seen |