MCPcopy
hub / github.com/blitz-js/blitz / runTests

Function runTests

integration-tests/auth-with-rpc/test/index.test.ts:18–277  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16let mode: "dev" | "server" = "dev"
17
18const 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", () => {

Callers 1

index.test.tsFile · 0.70

Calls 9

waitForFunction · 0.90
webdriverFunction · 0.85
textMethod · 0.45
elementByCssMethod · 0.45
waitForElementByCssMethod · 0.45
closeMethod · 0.45
clickMethod · 0.45
evalMethod · 0.45
urlMethod · 0.45

Tested by

no test coverage detected