mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
- cypress passing locally, but failing the build, the previous search term is not being cleared, which does happen when the clear button is clicked
95 lines
2.4 KiB
JavaScript
95 lines
2.4 KiB
JavaScript
import { When, Then } from "cypress-cucumber-preprocessor/steps";
|
|
When("I search for {string}", value => {
|
|
cy.get("#search-resources")
|
|
.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 has no results", () => {
|
|
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", { force: true });
|
|
});
|
|
|
|
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(".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()
|
|
.type(value)
|
|
.type("{enter}", { force: true });
|
|
});
|
|
|
|
When("I type {string} and press escape", value => {
|
|
cy.get("#search-resources")
|
|
.focus()
|
|
.type(value)
|
|
.type("{esc}");
|
|
});
|
|
|
|
Then("the search field should clear", () => {
|
|
cy.get("#search-resources").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 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 .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")
|
|
}) |