mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Search.feature
This commit is contained in:
parent
aa2fffb947
commit
61d4107e7b
@ -4,17 +4,17 @@ Feature: Search
|
||||
In order to find related content
|
||||
|
||||
Background:
|
||||
Given I have a user account
|
||||
And we have the following posts in our database:
|
||||
Given the following "users" are in the database:
|
||||
| slug | email | password | id | name | termsAndConditionsAgreedVersion |
|
||||
| narrator | narrator@example.org | 1234 | narrator | Nathan Narrator | 0.0.4 |
|
||||
| search-for-me | u1@example.org | 1234 | user-for-search | Search for me | 0.0.4 |
|
||||
| not-to-be-found | u2@example.org | 1234 | just-an-id | Not to be found | 0.0.4 |
|
||||
And the following "posts" are in the database:
|
||||
| id | title | content |
|
||||
| p1 | 101 Essays that will change the way you think | 101 Essays, of course (PR)! |
|
||||
| p2 | No 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
|
||||
| p2 | No content | will be found in this post, I guarantee |
|
||||
And I am logged in as "narrator"
|
||||
And I navigate to page "landing"
|
||||
|
||||
Scenario: Search for specific words
|
||||
When I search for "Essays"
|
||||
@ -25,10 +25,12 @@ Feature: Search
|
||||
|
||||
Scenario: Press enter opens search page
|
||||
When I type "PR" and press Enter
|
||||
Then I should see the search results page
|
||||
Then I should see the following posts on the search results page
|
||||
Then I am on page "/search/search-results"
|
||||
And the search parameter equals "?search=PR"
|
||||
Then I should see the following posts on the search results page:
|
||||
| title |
|
||||
| 101 Essays that will change the way you think |
|
||||
And I wait for 750 milliseconds
|
||||
|
||||
Scenario: Press escape clears search
|
||||
When I type "Ess" and press escape
|
||||
@ -37,7 +39,7 @@ Feature: Search
|
||||
Scenario: Select entry goes to post
|
||||
When I search for "Essays"
|
||||
And I select a post entry
|
||||
Then I should be on the post's page
|
||||
Then I am on page "/post/p1/101-essays-that-will-change-the-way-you-think"
|
||||
|
||||
Scenario: Select dropdown content
|
||||
When I search for "Essays"
|
||||
@ -52,4 +54,4 @@ Feature: Search
|
||||
| slug |
|
||||
| search-for-me |
|
||||
And I select a user entry
|
||||
Then I should be on the user's profile
|
||||
Then I am on page "/profile/user-for-search/search-for-me"
|
||||
7
cypress/integration/Search/I_search_for_{string}.js
Normal file
7
cypress/integration/Search/I_search_for_{string}.js
Normal file
@ -0,0 +1,7 @@
|
||||
import { When } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
When("I search for {string}", value => {
|
||||
cy.get(".searchable-input .ds-select input")
|
||||
.focus()
|
||||
.type(value);
|
||||
});
|
||||
7
cypress/integration/Search/I_select_a_post_entry.js
Normal file
7
cypress/integration/Search/I_select_a_post_entry.js
Normal file
@ -0,0 +1,7 @@
|
||||
import { When } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
When("I select a post entry", () => {
|
||||
cy.get(".searchable-input .search-post")
|
||||
.first()
|
||||
.trigger("click");
|
||||
});
|
||||
7
cypress/integration/Search/I_select_a_user_entry.js
Normal file
7
cypress/integration/Search/I_select_a_user_entry.js
Normal file
@ -0,0 +1,7 @@
|
||||
import { Then } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
Then("I select a user entry", () => {
|
||||
cy.get(".searchable-input .user-teaser")
|
||||
.first()
|
||||
.trigger("click");
|
||||
})
|
||||
@ -0,0 +1,7 @@
|
||||
import { Then } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,6 @@
|
||||
import { Then } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
Then("I should not see posts without the searched-for term in the select dropdown", () => {
|
||||
cy.get(".ds-select-dropdown")
|
||||
.should("not.contain","No searched for content");
|
||||
});
|
||||
@ -0,0 +1,6 @@
|
||||
import { Then } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
Then("I should see posts with the searched-for term in the select dropdown", () => {
|
||||
cy.get(".ds-select-dropdown")
|
||||
.should("contain","101 Essays that will change the way you think");
|
||||
});
|
||||
@ -0,0 +1,8 @@
|
||||
import { Then } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
Then("I should see the following posts in the select dropdown:", table => {
|
||||
table.hashes().forEach(({ title }) => {
|
||||
cy.get(".ds-select-dropdown")
|
||||
.should("contain", title);
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,8 @@
|
||||
import { Then } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
Then("I should see the following posts on the search results page:", table => {
|
||||
table.hashes().forEach(({ title }) => {
|
||||
cy.get(".post-teaser")
|
||||
.should("contain",title)
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,8 @@
|
||||
import { Then } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
Then("I should see the following users in the select dropdown:", table => {
|
||||
cy.get(".search-heading").should("contain", "Users");
|
||||
table.hashes().forEach(({ slug }) => {
|
||||
cy.get(".ds-select-dropdown").should("contain", slug);
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,8 @@
|
||||
import { When } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
When("I type {string} and press Enter", value => {
|
||||
cy.get(".searchable-input .ds-select input")
|
||||
.focus()
|
||||
.type(value)
|
||||
.type("{enter}", { force: true });
|
||||
});
|
||||
@ -0,0 +1,8 @@
|
||||
import { When } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
When("I type {string} and press escape", value => {
|
||||
cy.get(".searchable-input .ds-select input")
|
||||
.focus()
|
||||
.type(value)
|
||||
.type("{esc}");
|
||||
});
|
||||
@ -0,0 +1,6 @@
|
||||
import { Then } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
Then("the search field should clear", () => {
|
||||
cy.get(".searchable-input .ds-select input")
|
||||
.should("have.text", "");
|
||||
});
|
||||
@ -0,0 +1,6 @@
|
||||
import { Then } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
Then("the search parameter equals {string}", search => {
|
||||
cy.location("search")
|
||||
.should("eq", search);
|
||||
});
|
||||
@ -1,15 +1,4 @@
|
||||
import { When, Then } from "cypress-cucumber-preprocessor/steps";
|
||||
When("I search for {string}", value => {
|
||||
cy.get(".searchable-input .ds-select input")
|
||||
.focus()
|
||||
.type(value);
|
||||
});
|
||||
|
||||
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 should not contain posts by the annoying user", () => {
|
||||
cy.get(".searchable-input .ds-select-dropdown").should($li => {
|
||||
@ -28,99 +17,4 @@ Then("the search should contain the annoying user", () => {
|
||||
cy.get(".searchable-input .ds-select input")
|
||||
.focus()
|
||||
.type("{esc}");
|
||||
})
|
||||
|
||||
Then("I should see the following posts in the select dropdown:", table => {
|
||||
table.hashes().forEach(({ title }) => {
|
||||
cy.get(".ds-select-dropdown").should("contain", title);
|
||||
});
|
||||
});
|
||||
|
||||
Then("I should see the following users in the select dropdown:", table => {
|
||||
cy.get(".search-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(".searchable-input .ds-select input")
|
||||
.focus()
|
||||
.type(value)
|
||||
.type("{enter}", { force: true });
|
||||
});
|
||||
|
||||
When("I type {string} and press escape", value => {
|
||||
cy.get(".searchable-input .ds-select input")
|
||||
.focus()
|
||||
.type(value)
|
||||
.type("{esc}");
|
||||
});
|
||||
|
||||
Then("the search field should clear", () => {
|
||||
cy.get(".searchable-input .ds-select input").should("have.text", "");
|
||||
});
|
||||
|
||||
When("I select a post entry", () => {
|
||||
cy.get(".searchable-input .search-post")
|
||||
.first()
|
||||
.trigger("click");
|
||||
});
|
||||
|
||||
Then("I should be on the post's page", () => {
|
||||
cy.location("pathname").should("contain", "/post/");
|
||||
cy.location("pathname").should(
|
||||
"eq",
|
||||
"/post/p1/101-essays-that-will-change-the-way-you-think"
|
||||
);
|
||||
});
|
||||
|
||||
Then(
|
||||
"I should see posts with the searched-for term in the select dropdown",
|
||||
() => {
|
||||
cy.get(".ds-select-dropdown").should(
|
||||
"contain",
|
||||
"101 Essays that will change the way you think"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
Then("I should see the search results page", () => {
|
||||
cy.location("pathname").should(
|
||||
"eq",
|
||||
"/search/search-results"
|
||||
);
|
||||
cy.location("search").should(
|
||||
"eq",
|
||||
"?search=PR"
|
||||
);
|
||||
});
|
||||
|
||||
Then("I should see the following posts on the search results page",
|
||||
() => {
|
||||
cy.get(".post-teaser").should(
|
||||
"contain",
|
||||
"101 Essays that will change the way you think"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
Then(
|
||||
"I should not see posts without the searched-for term in the select dropdown",
|
||||
() => {
|
||||
cy.get(".ds-select-dropdown").should(
|
||||
"not.contain",
|
||||
"No searched for content"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
Then("I select a user entry", () => {
|
||||
cy.get(".searchable-input .user-teaser")
|
||||
.first()
|
||||
.trigger("click");
|
||||
})
|
||||
|
||||
Then("I should be on the user's profile", () => {
|
||||
cy.location("pathname").should("eq", "/profile/user-for-search/search-for-me")
|
||||
})
|
||||
})
|
||||
@ -1,5 +1,6 @@
|
||||
import { Then } from "cypress-cucumber-preprocessor/steps";
|
||||
|
||||
Then("I am on page {string}", page => {
|
||||
cy.location("pathname").should("contain", page.replace("...", ""));
|
||||
cy.location("pathname")
|
||||
.should("contain", page.replace("...", ""));
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user