|
| 1 | +//Both should return results for "opensearch" |
| 2 | +//Only Upsun should return a match for "vertical scaling" |
| 3 | +//Only platform should return a match for "24.55 gb" |
| 4 | +describe("Searches",()=>{ |
| 5 | + beforeEach(()=>{ |
| 6 | + if('local' == Cypress.env('environment')) { |
| 7 | + cy.intercept("/indexes/*_docs/search*", { "hits":[] }) |
| 8 | + } |
| 9 | + |
| 10 | + //cy.visit("/") |
| 11 | + }) |
| 12 | + |
| 13 | + context("Search tests",()=>{ |
| 14 | + it("Searches for something that should match in both", () => { |
| 15 | + cy.visit("/") |
| 16 | + if('local' == Cypress.env('environment')) { |
| 17 | + cy.intercept({ |
| 18 | + pathname: '/indexes/*_docs/search', |
| 19 | + query: { |
| 20 | + q: 'opensearch' |
| 21 | + } |
| 22 | + },{ fixture: "opensearchresults" }).as("searchresultsopensearch") |
| 23 | + } |
| 24 | + |
| 25 | + cy.get("#searchwicon-header").type("opensearch") |
| 26 | + |
| 27 | + if ('local' == Cypress.env('environment')) { |
| 28 | + cy.wait('@searchresultsopensearch') |
| 29 | + } |
| 30 | + |
| 31 | + cy.get("#xssroot").find("h2").as("searchresultsheader") |
| 32 | + cy.get("@searchresultsheader").should("exist") |
| 33 | + cy.get("@searchresultsheader").contains("Documentation") |
| 34 | + cy.get("#xssroot").find("li").contains("OpenSearch").should("exist") |
| 35 | + |
| 36 | + cy.get("#searchwicon-header").type("{enter}") |
| 37 | + cy.location("pathname").should( |
| 38 | + "eq", |
| 39 | + "/search.html" |
| 40 | + ) |
| 41 | + |
| 42 | + cy.get("#xssSearchPage").find("h2").as("searchpageresults") |
| 43 | + cy.get("@searchpageresults").should("exist") |
| 44 | + cy.get("@searchpageresults").contains("Documentation") |
| 45 | + |
| 46 | + cy.get("#xssSearchPage").find("li").contains("OpenSearch").should("exist") |
| 47 | + |
| 48 | + }) |
| 49 | + |
| 50 | + it("Searches for something that should not match on Platformsh, but should on Upsun", ()=>{ |
| 51 | + const searchDetails = { |
| 52 | + search: 'vertical scaling', |
| 53 | + header: 'No results', |
| 54 | + body: 'No documentation matched' |
| 55 | + } |
| 56 | + |
| 57 | + if ('upsun' == Cypress.env('site')) { |
| 58 | + searchDetails.header = 'Documentation' |
| 59 | + searchDetails.body = searchDetails.search |
| 60 | + } |
| 61 | + |
| 62 | + cy.visit("/") |
| 63 | + cy.get("#searchwicon-header").type(searchDetails.search) |
| 64 | + cy.get("#xssroot").find("h2").as("searchresultsheader") |
| 65 | + cy.get("@searchresultsheader").should("exist") |
| 66 | + cy.get("@searchresultsheader").contains(searchDetails.header) |
| 67 | + cy.get("#xssroot").find("p").contains(searchDetails.body) |
| 68 | + |
| 69 | + cy.get("#searchwicon-header").type("{enter}") |
| 70 | + cy.location("pathname").should( |
| 71 | + "eq", |
| 72 | + "/search.html" |
| 73 | + ) |
| 74 | + |
| 75 | + cy.get("#xssSearchPage").find("h2").as("searchpageresults") |
| 76 | + cy.get("@searchpageresults").should("exist") |
| 77 | + if ('upsun' == Cypress.env('site')) { |
| 78 | + cy.get("#xssSearchPage").find("li").contains(searchDetails.body).should("exist") |
| 79 | + } else { |
| 80 | + cy.get("#xssSearchPage").contains(searchDetails.header) |
| 81 | + } |
| 82 | + |
| 83 | + }) |
| 84 | + |
| 85 | + it("Searches for something that should ONLY match on platformsh, but not on Upsun", () => { |
| 86 | + const searchDetails = { |
| 87 | + search: '24.55', |
| 88 | + header: 'No results', |
| 89 | + body: 'No documentation matched' |
| 90 | + } |
| 91 | + |
| 92 | + console.log('Current site is ' + Cypress.env('site')) |
| 93 | + |
| 94 | + if ('platformsh' == Cypress.env('site')) { |
| 95 | + searchDetails.header = 'Documentation' |
| 96 | + searchDetails.body = searchDetails.search |
| 97 | + } |
| 98 | + |
| 99 | + cy.visit("/") |
| 100 | + if('local' == Cypress.env('environment')) { |
| 101 | + cy.intercept({ |
| 102 | + pathname: '/indexes/*_docs/search', |
| 103 | + query: { |
| 104 | + q: 'opensearch' |
| 105 | + } |
| 106 | + },{ fixture: "searchosresults" }).as("searchresultsopensearch") |
| 107 | + } |
| 108 | + |
| 109 | + console.log('Pausing before starting') |
| 110 | + cy.wait(1000) |
| 111 | + console.log('finished pausing') |
| 112 | + |
| 113 | + cy.get("#searchwicon-header").clear().type(searchDetails.search) |
| 114 | + |
| 115 | + if ('local' == Cypress.env('environment')) { |
| 116 | + cy.wait('@searchresultsopensearch') |
| 117 | + } |
| 118 | + |
| 119 | + cy.get("#xssroot").find("h2").as("searchresultsheader") |
| 120 | + cy.get("@searchresultsheader").should("exist") |
| 121 | + cy.get("@searchresultsheader").contains(searchDetails.header) |
| 122 | + cy.get('#xssroot').find('p').contains(searchDetails.body) |
| 123 | + |
| 124 | + cy.get("#searchwicon-header").type("{enter}") |
| 125 | + cy.location("pathname").should( |
| 126 | + "eq", |
| 127 | + "/search.html" |
| 128 | + ) |
| 129 | + |
| 130 | + cy.get("#xssSearchPage").find("h2").as("searchpageresults") |
| 131 | + cy.get("@searchpageresults").should("exist") |
| 132 | + cy.get("@searchpageresults").contains(searchDetails.header) |
| 133 | + |
| 134 | + if ('platformsh' == Cypress.env('site')) { |
| 135 | + cy.get("#xssSearchPage").find("li").contains(searchDetails.body).should("exist") |
| 136 | + } else { |
| 137 | + cy.get("#xssSearchPage").contains(searchDetails.body) |
| 138 | + } |
| 139 | + |
| 140 | + }) |
| 141 | + }) |
| 142 | +}) |
0 commit comments