Skip to content

Commit fdaab51

Browse files
committed
Add WebpageSnapshotTests.test_CustomCollectionShow
1 parent 51a1522 commit fdaab51

File tree

3 files changed

+256
-0
lines changed

3 files changed

+256
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright Dave Verwer, Sven A. Schmidt, and other contributors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
@testable import App
16+
17+
import Foundation
18+
19+
20+
extension CustomCollectionShow.Model {
21+
static var mock: Self {
22+
let packages = (1...5).map { PackageInfo(
23+
title: "Package \($0)",
24+
description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas nec orci scelerisque, interdum purus a, tempus turpis.",
25+
repositoryOwner: "owner",
26+
repositoryName: "name",
27+
url: "https://example.com/owner/name.git",
28+
stars: 4,
29+
lastActivityAt: .t0
30+
) }
31+
return .init(name: "Some Collection", packages: packages, page: 1, hasMoreResults: false)
32+
}
33+
}

Tests/AppTests/WebpageSnapshotTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,12 @@ class WebpageSnapshotTests: SnapshotTestCase {
452452
assertSnapshot(of: page, as: .html)
453453
}
454454

455+
func test_CustomCollectionShow() throws {
456+
let page = { CustomCollectionShow.View(path: "", model: .mock).document() }
457+
458+
assertSnapshot(of: page, as: .html)
459+
}
460+
455461
func test_DocCTemplate() throws {
456462
let doccTemplatePath = fixturesDirectory().appendingPathComponent("docc-template.html").path
457463
let doccHtml = try String(contentsOfFile: doccTemplatePath)
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
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>Packages for collection Some Collection &ndash; Swift Package Index</title>
11+
<meta name="twitter:title" content="Packages for collection Some Collection &ndash; Swift Package Index"/>
12+
<meta property="og:title" content="Packages for collection Some Collection &ndash; Swift Package Index"/>
13+
<meta name="description" content="The Swift Package Index is indexing 5 packages for collection Some Collection."/>
14+
<meta name="twitter:description" content="The Swift Package Index is indexing 5 packages for collection Some Collection."/>
15+
<meta property="og:description" content="The Swift Package Index is indexing 5 packages for collection Some Collection."/>
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>
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+
<nav class="breadcrumbs">
70+
<div class="inner">
71+
<ul>
72+
<li>
73+
<a href="/">
74+
<span>Home</span>
75+
</a>
76+
</li>
77+
<li>
78+
<span>Some Collection</span>
79+
</li>
80+
</ul>
81+
</div>
82+
</nav>
83+
<main>
84+
<div class="inner">
85+
<h2 class="trimmed">Packages for collection “Some Collection”</h2>
86+
<ul id="package-list">
87+
<li>
88+
<a href="https://example.com/owner/name.git">
89+
<h4>Package 1</h4>
90+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas nec orci scelerisque, interdum purus a, tempus turpis.</p>
91+
<ul class="metadata">
92+
<li class="identifier">
93+
<small>owner/name</small>
94+
</li>
95+
<li class="activity">
96+
<small>Active in 0 seconds</small>
97+
</li>
98+
<li class="stars">
99+
<small>4 stars</small>
100+
</li>
101+
</ul>
102+
</a>
103+
</li>
104+
<li>
105+
<a href="https://example.com/owner/name.git">
106+
<h4>Package 2</h4>
107+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas nec orci scelerisque, interdum purus a, tempus turpis.</p>
108+
<ul class="metadata">
109+
<li class="identifier">
110+
<small>owner/name</small>
111+
</li>
112+
<li class="activity">
113+
<small>Active in 0 seconds</small>
114+
</li>
115+
<li class="stars">
116+
<small>4 stars</small>
117+
</li>
118+
</ul>
119+
</a>
120+
</li>
121+
<li>
122+
<a href="https://example.com/owner/name.git">
123+
<h4>Package 3</h4>
124+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas nec orci scelerisque, interdum purus a, tempus turpis.</p>
125+
<ul class="metadata">
126+
<li class="identifier">
127+
<small>owner/name</small>
128+
</li>
129+
<li class="activity">
130+
<small>Active in 0 seconds</small>
131+
</li>
132+
<li class="stars">
133+
<small>4 stars</small>
134+
</li>
135+
</ul>
136+
</a>
137+
</li>
138+
<li>
139+
<a href="https://example.com/owner/name.git">
140+
<h4>Package 4</h4>
141+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas nec orci scelerisque, interdum purus a, tempus turpis.</p>
142+
<ul class="metadata">
143+
<li class="identifier">
144+
<small>owner/name</small>
145+
</li>
146+
<li class="activity">
147+
<small>Active in 0 seconds</small>
148+
</li>
149+
<li class="stars">
150+
<small>4 stars</small>
151+
</li>
152+
</ul>
153+
</a>
154+
</li>
155+
<li>
156+
<a href="https://example.com/owner/name.git">
157+
<h4>Package 5</h4>
158+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas nec orci scelerisque, interdum purus a, tempus turpis.</p>
159+
<ul class="metadata">
160+
<li class="identifier">
161+
<small>owner/name</small>
162+
</li>
163+
<li class="activity">
164+
<small>Active in 0 seconds</small>
165+
</li>
166+
<li class="stars">
167+
<small>4 stars</small>
168+
</li>
169+
</ul>
170+
</a>
171+
</li>
172+
</ul>
173+
<p>
174+
<strong>5 packages.</strong>
175+
</p>
176+
<ul class="pagination"></ul>
177+
</div>
178+
</main>
179+
<footer>
180+
<div class="inner">
181+
<nav>
182+
<ul>
183+
<li>
184+
<a href="/blog">Blog</a>
185+
</li>
186+
<li>
187+
<a href="https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server">GitHub</a>
188+
</li>
189+
<li>
190+
<a href="/privacy">Privacy and Cookies</a>
191+
</li>
192+
<li>
193+
<a href="https://swiftpackageindex.statuspage.io">Uptime and System Status</a>
194+
</li>
195+
<li>
196+
<a href="/build-monitor">Build System Monitor</a>
197+
</li>
198+
<li>
199+
<a href="https://mas.to/@SwiftPackageIndex">Mastodon</a>
200+
</li>
201+
</ul>
202+
<small>The Swift Package Index is entirely funded by community sponsorship. Thank you to
203+
<a href="https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server#funding-and-sponsorship">all our sponsors for their generosity</a>.
204+
</small>
205+
<small>The Swift Package Index is operated by SPI Operations Limited, a company registered in the UK with company number 13466692.</small>
206+
<a rel="me" href="https://mas.to/@SwiftPackageIndex"></a>
207+
<a rel="me" href="https://mas.to/@SwiftPackageUpdates"></a>
208+
</nav>
209+
</div>
210+
</footer>
211+
<spi-debug-panel class="hidden">
212+
<table>
213+
<tbody></tbody>
214+
</table>
215+
</spi-debug-panel>
216+
</body>
217+
</html>

0 commit comments

Comments
 (0)