Add cypress example for data sources.

This commit is contained in:
Dillon Kearns 2021-07-21 13:30:21 -07:00
parent ced6284a95
commit d865c20ccb
2 changed files with 45 additions and 1 deletions

View File

@ -0,0 +1,44 @@
context("dev server with base path", () => {
it("404 message", () => {
cy.visit("/qwer/asdf", { failOnStatusCode: false });
cy.contains("No route found for /asdf");
});
it("navigates to root page", () => {
cy.visit("/qwer/");
cy.contains("This is the index page");
});
it("loads file data sources", () => {
cy.writeFile(
"examples/end-to-end/my-json-data.json",
JSON.stringify({
greeting: "Hello, World!",
})
);
cy.visit("/qwer/file-data");
cy.contains("Greeting: Hello, World!");
cy.writeFile(
"examples/end-to-end/my-json-data.json",
JSON.stringify({
greeting: "Goodbye, World!",
})
);
cy.contains("Greeting: Goodbye, World!");
cy.writeFile(
"examples/end-to-end/my-json-data.json",
JSON.stringify({
greeting: null,
})
);
cy.contains(`I encountered some errors while decoding this JSON:
At path /jsonFile/greeting
I expected a string here, but instead found this value:
null`);
});
});

View File

@ -52,7 +52,7 @@ manifest static =
Manifest.init
{ name = static.siteName
, description = "elm-pages - " ++ tagline
, startUrl = Route.Slide__Number_ { number = "1" } |> Route.toPath
, startUrl = Route.Index |> Route.toPath
, icons =
[ icon webp 192
, icon webp 512