diff options
Diffstat (limited to 'cgithub')
| -rw-r--r-- | cgithub/src/app.test.ts | 23 | ||||
| -rw-r--r-- | cgithub/views/error.eta | 14 |
2 files changed, 26 insertions, 11 deletions
diff --git a/cgithub/src/app.test.ts b/cgithub/src/app.test.ts index c028e1b..450c1cc 100644 --- a/cgithub/src/app.test.ts +++ b/cgithub/src/app.test.ts @@ -458,3 +458,26 @@ describe("redirects to GitHub", () => { ); }); }); + +describe("error page", () => { + it("should render inside the page shell", () => { + const html = eta.render("error.eta", { + title: "Not Found", + message: "GitHub responded with HTTP 404 Not Found", + buildCommit: "v0-g1234567", + githubUrl: "https://github.com/actions/deploy-pages", + }); + + assert.match(html, /<title>Not Found<\/title>/); + assert.match(html, /GitHub responded with HTTP 404 Not Found/); + assert.match(html, /<footer>Generated by cgithub commit <code>v0-g1234567<\/code>/); + assert.match(html, /href="https:\/\/github.com\/actions\/deploy-pages"/); + }); + + // The title falls back to the message for errors that carry no status text. + it("should title itself with the message when it has no title", () => { + const html = eta.render("error.eta", { message: "Error: boom" }); + + assert.match(html, /<title>Error: boom<\/title>/); + }); +}); diff --git a/cgithub/views/error.eta b/cgithub/views/error.eta index 784a843..a46411e 100644 --- a/cgithub/views/error.eta +++ b/cgithub/views/error.eta @@ -1,11 +1,3 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8"> - <title><%= it.title ?? it.message %></title> - <link rel="stylesheet" href="/static/style.css"> -</head> -<body> - <%= it.message %> -</body> -</html> +<% layout("/layouts/base.eta", { title: it.title ?? it.message }) %> + +<%= it.message %> |
