Fix/extend cypress Search.feature

This commit is contained in:
mattwr18 2019-12-19 17:14:45 +01:00
parent 46191e5889
commit 7ee57033be
3 changed files with 43 additions and 11 deletions

View File

@ -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")
})

View File

@ -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

View File

@ -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 |