Skip to content

Commit 7f8bf77

Browse files
committed
Snapshot test now tests the maintenance page rather than the route.
1 parent 780b125 commit 7f8bf77

File tree

4 files changed

+124
-9
lines changed

4 files changed

+124
-9
lines changed

Tests/AppTests/RoutesTests.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,12 @@ final class RoutesTests: AppTestCase {
6565
}
6666
}
6767

68+
func test_HomePageInterstitial() throws {
69+
Current.homepageInterstitial = { "HOMEPAGE_INTERSTITIAL" }
70+
71+
try app.test(.GET, "/") { res in
72+
XCTAssertContains(res.body.string, "HOMEPAGE_INTERSTITIAL")
73+
}
74+
}
75+
6876
}

Tests/AppTests/WebpageSnapshotTests.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,19 @@ class WebpageSnapshotTests: SnapshotTestCase {
4848
assertSnapshot(of: page, as: .html)
4949
}
5050

51-
func test_HomeIndexView_interstitial() throws {
52-
Current.homepageInterstitial = {
53-
"""
51+
func test_MaintenanceIndexView() throws {
52+
let interstitial = """
5453
# ⚠️ Server Maintenance ⚠️
5554
5655
We are currently performing an update to our database server.
5756
5857
Service should be restored within a few minutes.
5958
"""
60-
}
6159

62-
try app.test(.GET, "/") { res in
63-
assertSnapshot(of: res.body.string, as: .html)
64-
}
60+
let model = MaintenanceIndex.Model(markdown: interstitial)
61+
let page = { MaintenanceIndex.View(path: "/", model: model).document() }
62+
63+
assertSnapshot(of: page, as: .html, record: true)
6564
}
6665

6766
func test_PackageShowView() throws {

Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_HomeIndexView_interstitial.1.html

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<!DOCTYPE html>
2+
<html lang="en"><!--Version: test--><!--DB Id: db-id-->
3+
<head>
4+
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
5+
<meta charset="UTF-8"/>
6+
<meta property="og:site_name" content="The Swift Package Index"/>
7+
<link rel="canonical" href="http://localhost:8080/"/>
8+
<meta name="twitter:url" content="http://localhost:8080/"/>
9+
<meta property="og:url" content="http://localhost:8080/"/>
10+
<title>Swift Package Index</title>
11+
<meta name="twitter:title" content="Swift Package Index"/>
12+
<meta property="og:title" content="Swift Package Index"/>
13+
<meta name="description" content="The Swift Package Index is the place to find the best Swift packages."/>
14+
<meta name="twitter:description" content="The Swift Package Index is the place to find the best Swift packages."/>
15+
<meta property="og:description" content="The Swift Package Index is the place to find the best Swift packages."/>
16+
<meta name="twitter:card" content="summary"/>
17+
<meta name="twitter:image" content="http://localhost:8080/images/logo.png"/>
18+
<meta property="og:image" content="http://localhost:8080/images/logo.png"/>
19+
<link rel="shortcut icon" href="/images/logo-tiny.png" type="image/png"/>
20+
<link rel="alternate" type="application/rss+xml" title="Swift Package Index Blog" href="http://localhost:8080/blog/feed.xml"/>
21+
<link rel="alternate" type="application/rss+xml" title="Swift Package Index – Recently Added Packages" href="http://localhost:8080/packages.rss"/>
22+
<link rel="alternate" type="application/rss+xml" title="Swift Package Index – Recent Package Releases" href="http://localhost:8080/releases.rss"/>
23+
<link rel="alternate" type="application/rss+xml" title="Swift Package Index – Recent Major Package Releases" href="http://localhost:8080/releases.rss?major=true"/>
24+
<link rel="alternate" type="application/rss+xml" title="Swift Package Index – Recent Major & Minor Package Releases" href="http://localhost:8080/releases.rss?major=true&minor=true"/>
25+
<link rel="alternate" type="application/rss+xml" title="Swift Package Index – Recent Package Pre-Releases" href="http://localhost:8080/releases.rss?pre=true"/>
26+
<link rel="stylesheet" href="/shared.css?test" data-turbolinks-track="reload"/>
27+
<link rel="stylesheet" href="/main.css?test" data-turbolinks-track="reload"/>
28+
<script src="/shared.js?test" data-turbolinks-track="reload" defer></script>
29+
<script src="/main.js?test" data-turbolinks-track="reload" defer></script><script async defer data-domain="swiftpackageindex.com" src="https://plausible.io/js/plausible.outbound-links.js"></script>
30+
<script>window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>
31+
</head>
32+
<body class="maintenance">
33+
<header>
34+
<div class="inner">
35+
<a href="/">
36+
<h1>
37+
<img alt="The Swift Package Index logo." src="/images/logo.svg"/>Swift Package Index
38+
</h1>
39+
</a>
40+
<nav>
41+
<ul>
42+
<li>
43+
<a class="supporters" href="/supporters">Supporters</a>
44+
</li>
45+
<li>
46+
<a href="/add-a-package">Add a Package</a>
47+
</li>
48+
<li>
49+
<a href="/blog">Blog</a>
50+
</li>
51+
<li>
52+
<a href="/faq">FAQ</a>
53+
</li>
54+
<li class="search">
55+
<form action="/search">
56+
<input id="query" name="query" type="search" placeholder="Search" spellcheck="false" autocomplete="off" data-gramm="false" data-focus="false"/>
57+
<button type="submit">
58+
<div title="Search"></div>
59+
</button>
60+
</form>
61+
</li>
62+
</ul>
63+
</nav>
64+
</div>
65+
</header>
66+
<p class="announcement">Track the adoption of Swift 6 strict concurrency checks for data race safety. How many packages are
67+
<a href="/ready-for-swift-6">Ready for Swift 6</a>?
68+
</p>
69+
<main>
70+
<div class="inner"><h1>⚠️ Server Maintenance ⚠️</h1><p>We are currently performing an update to our database server.</p><p>Service should be restored within a few minutes.</p></div>
71+
</main>
72+
<footer>
73+
<div class="inner">
74+
<nav>
75+
<ul>
76+
<li>
77+
<a href="/blog">Blog</a>
78+
</li>
79+
<li>
80+
<a href="https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server">GitHub</a>
81+
</li>
82+
<li>
83+
<a href="/privacy">Privacy and Cookies</a>
84+
</li>
85+
<li>
86+
<a href="https://swiftpackageindex.statuspage.io">Uptime and System Status</a>
87+
</li>
88+
<li>
89+
<a href="/build-monitor">Build System Monitor</a>
90+
</li>
91+
<li>
92+
<a href="https://mas.to/@SwiftPackageIndex">Mastodon</a>
93+
</li>
94+
</ul>
95+
<small>The Swift Package Index is entirely funded by community sponsorship. Thank you to
96+
<a href="https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server#funding-and-sponsorship">all our sponsors for their generosity</a>.
97+
</small>
98+
<small>The Swift Package Index is operated by SPI Operations Limited, a company registered in the UK with company number 13466692.</small>
99+
<a rel="me" href="https://mas.to/@SwiftPackageIndex"></a>
100+
<a rel="me" href="https://mas.to/@SwiftPackageUpdates"></a>
101+
</nav>
102+
</div>
103+
</footer>
104+
<spi-debug-panel class="hidden">
105+
<table>
106+
<tbody></tbody>
107+
</table>
108+
</spi-debug-panel>
109+
</body>
110+
</html>

0 commit comments

Comments
 (0)