|
| 1 | +import { page, data } from "../../../shared-data/head-function-export.js" |
| 2 | + |
| 3 | +describe(`Head function export html insertion`, () => { |
| 4 | + it(`should work with static data`, () => { |
| 5 | + cy.visit(page.basic).waitForRouteChange() |
| 6 | + cy.getTestElement(`base`) |
| 7 | + .invoke(`attr`, `href`) |
| 8 | + .should(`equal`, data.static.base) |
| 9 | + cy.getTestElement(`title`).should(`have.text`, data.static.title) |
| 10 | + cy.getTestElement(`meta`) |
| 11 | + .invoke(`attr`, `content`) |
| 12 | + .should(`equal`, data.static.meta) |
| 13 | + cy.getTestElement(`noscript`).should(`have.text`, data.static.noscript) |
| 14 | + cy.getTestElement(`style`).should(`contain`, data.static.style) |
| 15 | + cy.getTestElement(`link`) |
| 16 | + .invoke(`attr`, `href`) |
| 17 | + .should(`equal`, data.static.link) |
| 18 | + }) |
| 19 | + |
| 20 | + it(`should work with data from a page query`, () => { |
| 21 | + cy.visit(page.pageQuery).waitForRouteChange() |
| 22 | + cy.getTestElement(`base`) |
| 23 | + .invoke(`attr`, `href`) |
| 24 | + .should(`equal`, data.queried.base) |
| 25 | + cy.getTestElement(`title`).should(`have.text`, data.queried.title) |
| 26 | + cy.getTestElement(`meta`) |
| 27 | + .invoke(`attr`, `content`) |
| 28 | + .should(`equal`, data.queried.meta) |
| 29 | + cy.getTestElement(`noscript`).should(`have.text`, data.queried.noscript) |
| 30 | + cy.getTestElement(`style`).should(`contain`, data.queried.style) |
| 31 | + cy.getTestElement(`link`) |
| 32 | + .invoke(`attr`, `href`) |
| 33 | + .should(`equal`, data.queried.link) |
| 34 | + }) |
| 35 | + |
| 36 | + it(`should work when a head function with static data is re-exported from the page`, () => { |
| 37 | + cy.visit(page.reExport).waitForRouteChange() |
| 38 | + cy.getTestElement(`base`) |
| 39 | + .invoke(`attr`, `href`) |
| 40 | + .should(`equal`, data.static.base) |
| 41 | + cy.getTestElement(`title`).should(`have.text`, data.static.title) |
| 42 | + cy.getTestElement(`meta`) |
| 43 | + .invoke(`attr`, `content`) |
| 44 | + .should(`equal`, data.static.meta) |
| 45 | + cy.getTestElement(`noscript`).should(`have.text`, data.static.noscript) |
| 46 | + cy.getTestElement(`style`).should(`contain`, data.static.style) |
| 47 | + cy.getTestElement(`link`) |
| 48 | + .invoke(`attr`, `href`) |
| 49 | + .should(`equal`, data.static.link) |
| 50 | + }) |
| 51 | + |
| 52 | + it(`should work when an imported Head component with queried data is used`, () => { |
| 53 | + cy.visit(page.staticQuery).waitForRouteChange() |
| 54 | + cy.getTestElement(`base`) |
| 55 | + .invoke(`attr`, `href`) |
| 56 | + .should(`equal`, data.queried.base) |
| 57 | + cy.getTestElement(`title`).should(`have.text`, data.queried.title) |
| 58 | + cy.getTestElement(`meta`) |
| 59 | + .invoke(`attr`, `content`) |
| 60 | + .should(`equal`, data.queried.meta) |
| 61 | + cy.getTestElement(`noscript`).should(`have.text`, data.queried.noscript) |
| 62 | + cy.getTestElement(`style`).should(`contain`, data.queried.style) |
| 63 | + cy.getTestElement(`link`) |
| 64 | + .invoke(`attr`, `href`) |
| 65 | + .should(`equal`, data.queried.link) |
| 66 | + }) |
| 67 | + |
| 68 | + it(`should work in a DSG page (exporting function named config)`, () => { |
| 69 | + cy.visit(page.dsg).waitForRouteChange() |
| 70 | + cy.getTestElement(`base`) |
| 71 | + .invoke(`attr`, `href`) |
| 72 | + .should(`equal`, data.dsg.base) |
| 73 | + cy.getTestElement(`title`).should(`have.text`, data.dsg.title) |
| 74 | + cy.getTestElement(`meta`) |
| 75 | + .invoke(`attr`, `content`) |
| 76 | + .should(`equal`, data.dsg.meta) |
| 77 | + cy.getTestElement(`noscript`).should(`have.text`, data.dsg.noscript) |
| 78 | + cy.getTestElement(`style`).should(`contain`, data.dsg.style) |
| 79 | + cy.getTestElement(`link`) |
| 80 | + .invoke(`attr`, `href`) |
| 81 | + .should(`equal`, data.dsg.link) |
| 82 | + }) |
| 83 | + |
| 84 | + it(`should work in an SSR page (exporting function named getServerData)`, () => { |
| 85 | + cy.visit(page.ssr).waitForRouteChange() |
| 86 | + cy.getTestElement(`base`) |
| 87 | + .invoke(`attr`, `href`) |
| 88 | + .should(`equal`, data.ssr.base) |
| 89 | + cy.getTestElement(`title`).should(`have.text`, data.ssr.title) |
| 90 | + cy.getTestElement(`meta`) |
| 91 | + .invoke(`attr`, `content`) |
| 92 | + .should(`equal`, data.ssr.meta) |
| 93 | + cy.getTestElement(`noscript`).should(`have.text`, data.ssr.noscript) |
| 94 | + cy.getTestElement(`style`).should(`contain`, data.ssr.style) |
| 95 | + cy.getTestElement(`link`) |
| 96 | + .invoke(`attr`, `href`) |
| 97 | + .should(`equal`, data.ssr.link) |
| 98 | + }) |
| 99 | +}) |
0 commit comments