Skip to content

Commit

Permalink
DIGG-501: Organisation search, landingpage test + fix on other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessandro Gasperini authored and MikaMunterud committed Jan 14, 2025
1 parent 0d97759 commit ceb440e
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/EntryscapeLandingPage/conceptpage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe("Search concepts", () => {
// Type a search query and click search + find first result and click.
cy.get("input#search-field").type("data");

cy.get(`button[aria-label="Sök"]`)
cy.get(`button[aria-label="Sök begrepp"]`)
.click()
.then(() => {
cy.reload();
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/EntryscapeLandingPage/datasetpage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("Check dataset page", () => {
// Type a search query and click search + find first result and click.
cy.get("input#search-field", { timeout: 6000 }).type("api");

cy.get(`button[aria-label="Sök"]`)
cy.get(`button[aria-label="Sök Data & Api:er"]`)
.click()
.then(() => {
cy.reload();
Expand Down
49 changes: 49 additions & 0 deletions cypress/e2e/EntryscapeLandingPage/organisationpage.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
beforeEach(() => {
// Ignore a 3rd party library error with message "ReferenceError: ESJS is not defined".
// We don't want to fail the test due to this so we return false.
// This is a workaround for the implementation of entryStore (ESJS) in the application.
cy.on("uncaught:exception", (e) => {
return !e.message.includes("ESJS is not defined");
});
});

describe("Check organisation page", () => {
it("Verify organisation page route and check data", () => {
// Go to searchpage
cy.visit("/sv/organisations");

// verify H1 text
cy.get("h1").contains("Sök organisationer");

// Verify that the search field is present and contains correct placeholder text.
cy.get("input#search-field")
.invoke("attr", "placeholder")
.should("contain", "Sök organisationer");

// Type a search query and click search + find first result and click.
cy.get("input#search-field", { timeout: 6000 }).type("kommun");

cy.get(`button[aria-label="Sök organisationer"]`)
.click()
.then(() => {
cy.reload();
cy.get("ul.search-result-list", { timeout: 6000 })
.find("li")
.first()
.click();
});

// Check for heading
cy.get("h1").should("exist");

// Check for organisation data
cy.get("h2").should("contain", "Datamängder");
cy.get("span").should("contain", "Antal datamängder");
cy.get("span").should("contain", "Öppna datamängder");
cy.get("span").should("contain", "Skyddade datamängder");
cy.get("span").should("contain", "Datamängder med API");
cy.get("span").should("contain", "Värdefulla datamängder");
cy.get("span").should("contain", "Avgiftsbelagda datamängder");
cy.get("span").should("contain", "Datamängder som följer specifikation");
});
});
2 changes: 1 addition & 1 deletion cypress/e2e/EntryscapeLandingPage/specificationpage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("Check specification page", () => {
// Type a search query and click search + find first result and click.
cy.get("input#search-field").type("api");

cy.get(`button[aria-label="Sök"]`)
cy.get(`button[aria-label="Sök specifikationer"]`)
.click()
.then(() => {
cy.reload();
Expand Down
6 changes: 4 additions & 2 deletions cypress/e2e/Search/searchConcepts.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("Search concepts", () => {

// Type a search query and click search.
cy.get("input#search-field").type("api");
cy.get(`button[aria-label="Sök"]`).click();
cy.get(`button[aria-label="Sök begrepp"]`).click();

// Verify that we have 20 results on first page.
// Also change the default waiting time of 4 seconds from Cypress.
Expand Down Expand Up @@ -69,7 +69,9 @@ describe("Search concepts", () => {
cy.get("#SearchFilters button").contains("Terminologier").click();

// Select one category item.
cy.get("#SearchFilters button").contains("The GEMET thesaurus - version 4.2.3").click();
cy.get("#SearchFilters button")
.contains("The GEMET thesaurus - version 4.2.3")
.click();

// Close the category filter popup bu clicking it again.
cy.get("#SearchFilters button").contains("Terminologier").click();
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/Search/searchDatasets.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("Search datasets", () => {

// Type a search query and click search.
cy.get("input#search-field").type("api");
cy.get(`button[aria-label="Sök"]`).click();
cy.get(`button[aria-label="Sök Data & Api:er"]`).click();

// Verify that we have 20 results on first page.
// Also change the default waiting time of 4 seconds from Cypress.
Expand Down
76 changes: 76 additions & 0 deletions cypress/e2e/Search/searchOrganisations.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
beforeEach(() => {
// Ignore a 3rd party library error with message "ReferenceError: ESJS is not defined".
// We don't want to fail the test due to this so we return false.
// This is a workaround for the implementation of entryStore (ESJS) in the application.
cy.on("uncaught:exception", (e) => {
return !e.message.includes("ESJS is not defined");
});
});

describe("Search organisations", () => {
/**
* Verify that the search page is accessible and that the search for organisations gives results.
*/
it("Verify organisations search result", () => {
// Gg to searchpage
cy.visit("/sv/organisations");

// verify H1 text
cy.get("h1").contains("Sök organisationer");

// Verify that the search field is present and contains correct placeholder text.
cy.get("input#search-field")
.invoke("attr", "placeholder")
.should("contain", "Sök organisationer");

// Type a search query and click search.
cy.get("input#search-field").type("kommun");
cy.get(`button[aria-label="Sök organisationer"]`).click();

// Verify that we have 20 results on first page.
// Also change the default waiting time of 4 seconds from Cypress.
// We instead set it to 6 seconds. We have to do this due to our slow
// integration against Entrystore that sometimes can take longer than 4
// seconds to load the search results completely.
cy.get("ul.search-result-list", { timeout: 6000 })
.find("li")
.should("have.length", 20);

// verify that url specifies "page 1" and search query "kommun" after we have done the search.
cy.url().should("include", "/organisations?p=1&q=kommun");
});

/**
* Verify that the search filters exist and is usable.
*/
it("Verify search filter on organisations search result", () => {
// Go to search page with a search query of "kommun".
cy.visit("/sv/organisations?q=kommun");

// Verify that we have 20 results on first page.
// Also change the default waiting time of 4 seconds from Cypress.
// We instead set it to 6 seconds. We have to do this due to our slow
// integration against Entrystore that sometimes can take longer than 4
// seconds to load the search results completely.
cy.get("ul.search-result-list", { timeout: 6000 })
.find("li")
.should("have.length", 20);

// Get the search result count, so we can check against it later when we add a filter.
cy.get("h2.search-result-header").then((firstSearchCount) =>
cy.wrap(firstSearchCount.text()).as("firstSearchCount"),
);

// Open search filters.
cy.get(`#SearchFilters button[aria-label="Visa filter"]`).first().click();
cy.get(`#SearchFilters button[aria-label="Dölj filter"]`).should("exist");

// Verify filter buttons.
cy.get("#SearchFilters button").contains("Organisationstyp");
// Open the first filter named "Organisationstyp".
cy.get("#SearchFilters button").contains("Organisationstyp").click();

// Close the category filter popup bu clicking it again.
cy.get("#SearchFilters button").contains("Organisationstyp").click();
});
});
2 changes: 1 addition & 1 deletion cypress/e2e/Search/searchspecifications.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("Search specifications", () => {

// Type a search query and click search.
cy.get("input#search-field").type("data");
cy.get(`button[aria-label="Sök"]`).click();
cy.get(`button[aria-label="Sök specifikationer"]`).click();

// Verify that we have 20 results on first page.
// Also change the default waiting time of 4 seconds from Cypress.
Expand Down

0 comments on commit ceb440e

Please sign in to comment.