Implemented phase 0 for the POC prototype in the Website service.
This commit is contained in:
1 parent
916df7e2f0
commit
717df5208c
31 files changed
+2351
-240
No files matched your search
@@ -27,16 +27,47 @@ struct IndexPageTests {
|
||||
#expect(html.contains("/apple-touch-icon.png"))
|
||||
#expect(html.contains("/site.webmanifest"))
|
||||
#expect(html.contains(#"media="(prefers-color-scheme: dark)""#))
|
||||
#expect(html.contains("Hello world!"))
|
||||
#expect(html.contains("Back issues, from shops you can vet first."))
|
||||
#expect(html.contains("/js/shared.js"))
|
||||
#expect(html.contains("/js/index.js"))
|
||||
}
|
||||
|
||||
@Test
|
||||
func `renders no font preloads until fonts are declared`() {
|
||||
// The template ships no fonts, so a preload link here would point at a file the service does not serve.
|
||||
#expect(IndexPage.preloadedFonts.isEmpty)
|
||||
#expect(!IndexPage(locale: .init(identifier: "en")).render().contains(#"rel="preload""#))
|
||||
func `renders the site frame around its content`() {
|
||||
let html = IndexPage(
|
||||
locale: .init(identifier: "en")
|
||||
).render()
|
||||
|
||||
#expect(html.contains(#"class="skip-link""#))
|
||||
#expect(html.contains(#"class="site-header""#))
|
||||
#expect(html.contains(#"<main id="main">"#))
|
||||
#expect(html.contains(#"class="site-footer""#))
|
||||
}
|
||||
|
||||
@Test
|
||||
func `renders no inline styles`() {
|
||||
// The Content-Security-Policy is `default-src 'self'`, which blocks `style` attributes and elements alike.
|
||||
let html = IndexPage(
|
||||
locale: .init(identifier: "en")
|
||||
).render()
|
||||
|
||||
#expect(!html.contains("style="))
|
||||
#expect(!html.contains("<style"))
|
||||
}
|
||||
|
||||
@Test
|
||||
func `preloads every font face unversioned`() {
|
||||
// A preload URL must match the stylesheet's `@font-face` source exactly, or the browser fetches the font twice.
|
||||
let html = IndexPage(
|
||||
locale: .init(identifier: "en"),
|
||||
assetVersion: "0123456789abcdef"
|
||||
).render()
|
||||
|
||||
#expect(IndexPage.preloadedFonts.count == 3)
|
||||
|
||||
for font in IndexPage.preloadedFonts {
|
||||
#expect(html.contains(#"<link rel="preload" href="\#(font.urlPath(for: .woff2))" as="font""#))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user