()
| 16 | let mode: "dev" | "server" = "dev" |
| 17 | |
| 18 | const runTests = () => { |
| 19 | describe("Auth", () => { |
| 20 | describe("unauthenticated", () => { |
| 21 | it("should render result for open query", async () => { |
| 22 | const browser = await webdriver(appPort, "/noauth-query") |
| 23 | let text = await browser.elementByCss("#page").text() |
| 24 | await browser.waitForElementByCss("#content") |
| 25 | text = await browser.elementByCss("#content").text() |
| 26 | expect(text).toMatch(/noauth-basic-result/) |
| 27 | if (browser) await browser.close() |
| 28 | }) |
| 29 | |
| 30 | it("should render error for protected query", async () => { |
| 31 | const browser = await webdriver(appPort, "/authenticated-query") |
| 32 | await browser.waitForElementByCss("#error") |
| 33 | let text = await browser.elementByCss("#error").text() |
| 34 | if (mode === "server") { |
| 35 | expect(text).toMatch(/AuthenticationError/) |
| 36 | } else { |
| 37 | expect(text).toContain("Error") |
| 38 | } |
| 39 | if (browser) await browser.close() |
| 40 | }) |
| 41 | |
| 42 | it("should render error for protected page", async () => { |
| 43 | const browser = await webdriver(appPort, "/page-dot-authenticate") |
| 44 | await browser.waitForElementByCss("#error") |
| 45 | let text = await browser.elementByCss("#error").text() |
| 46 | expect(text).toMatch(/AuthenticationError/) |
| 47 | if (browser) await browser.close() |
| 48 | }) |
| 49 | |
| 50 | it("Page.authenticate = {role} should work ", async () => { |
| 51 | const browser = await webdriver(appPort, "/page-dot-authenticate-role") |
| 52 | await browser.waitForElementByCss("#error") |
| 53 | let text = await browser.elementByCss("#error").text() |
| 54 | expect(text).toMatch(/AuthenticationError/) |
| 55 | if (browser) await browser.close() |
| 56 | }) |
| 57 | |
| 58 | it("should render error for protected layout", async () => { |
| 59 | const browser = await webdriver(appPort, "/layout-authenticate") |
| 60 | await browser.waitForElementByCss("#error") |
| 61 | let text = await browser.elementByCss("#error").text() |
| 62 | expect(text).toMatch(/AuthenticationError/) |
| 63 | if (browser) await browser.close() |
| 64 | }) |
| 65 | |
| 66 | it("should render Page.authenticate = false even when Layout.authenticate = true", async () => { |
| 67 | const browser = await webdriver(appPort, "/layout-unauthenticate") |
| 68 | await browser.waitForElementByCss("#content") |
| 69 | let text = await browser.elementByCss("#content").text() |
| 70 | expect(text).toMatch(/this should be rendered/) |
| 71 | if (browser) await browser.close() |
| 72 | }) |
| 73 | }) |
| 74 | |
| 75 | describe("authenticated", () => { |
no test coverage detected