Skip to content

Commit c1a24e5

Browse files
Fix tests after an old series unexpectedly updated
* πŸ€–πŸ’– β€” Update snapshots after data refresh * Fix tests due to old series updated --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Essential Randomness <essentialrandomn3ss@gmail.com>
1 parent 1cdc3ac commit c1a24e5

80 files changed

Lines changed: 7462 additions & 7632 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import type { Reporter, TestModule } from "vitest/node";
2+
3+
declare module "vitest" {
4+
interface TaskMeta {
5+
requestedUrls?: string[];
6+
}
7+
}
8+
9+
export default class FailedUrlsReporter implements Reporter {
10+
onTestRunEnd(testModules: ReadonlyArray<TestModule>) {
11+
const failed: { name: string; urls: string[] }[] = [];
12+
for (const module of testModules) {
13+
for (const test of module.children.allTests("failed")) {
14+
const urls = test.meta().requestedUrls;
15+
if (!urls || urls.length === 0) continue;
16+
failed.push({ name: test.fullName, urls });
17+
}
18+
}
19+
20+
if (failed.length === 0) return;
21+
22+
console.log("\nURLs requested during failed tests:");
23+
for (const { name, urls } of failed) {
24+
console.log(` ${name}`);
25+
for (const url of urls) {
26+
console.log(` ${url}`);
27+
}
28+
}
29+
}
30+
}

β€Žtests/helpers/invariants.tsβ€Ž

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { expect } from "vitest";
2+
3+
interface DriftingCountMatchers<R = unknown> {
4+
driftingCount(bounds: { atLeast: number; atMost: number }): R;
5+
}
6+
7+
expect.extend({
8+
driftingCount(
9+
received: unknown,
10+
bounds: Parameters<DriftingCountMatchers["driftingCount"]>[0],
11+
) {
12+
const { atLeast, atMost } = bounds;
13+
const pass =
14+
typeof received === "number" &&
15+
Number.isFinite(received) &&
16+
received >= atLeast &&
17+
received <= atMost;
18+
return {
19+
pass,
20+
message: () =>
21+
pass
22+
? `expected ${received} not to be within [${atLeast}, ${atMost}]`
23+
: `expected ${received} to be a number within [${atLeast}, ${atMost}]`,
24+
actual: received,
25+
expected: `number in [${atLeast}, ${atMost}]`,
26+
};
27+
},
28+
});
29+
30+
declare module "vitest" {
31+
interface Assertion<T = any> extends DriftingCountMatchers<T> {}
32+
interface AsymmetricMatchersContaining extends DriftingCountMatchers {}
33+
}

β€Žtests/mocks/data/ao3/series/1728802/index.htmlβ€Ž

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<script src="/javascripts/livevalidation_standalone.js"></script>
3535

3636
<meta name="csrf-param" content="authenticity_token" />
37-
<meta name="csrf-token" content="SVv7GDfUF_aYl_mZqTnDvlATm29gfoSjNih2cNTszf7ohBQMqD5HrQ0PYYE2NZMMOq6quJgRwv-X39wgp-bvbg" />
37+
<meta name="csrf-token" content="2mzsJCl4eBmWYeOCFfS9gdNifE6LGZqM5TX-dKH69UYDuqvqRThuXHqPAQHrq6isROGgzNtqm0sG43882ZAHPQ" />
3838

3939

4040
</head>
@@ -57,7 +57,7 @@ <h1 class="heading">
5757
<a id="login-dropdown" href="/users/login?return_to=%2Fseries%2F1728802%3Fview_adult%3Dtrue">Log In</a>
5858
</p>
5959
<div id="small_login" class="simple login">
60-
<form class="new_user" id="new_user_session_small" action="/users/login?return_to=%2Fseries%2F1728802%3Fview_adult%3Dtrue" accept-charset="UTF-8" method="post"><input type="hidden" name="authenticity_token" value="0vVsGzUwwaP5h_hX6bItC6hrudL5ZcktjHI6gKsj7iC4YfgxEmUpivoz4ODPirpkpUZBFXCqZZwYhmQFayYt4g" autocomplete="off" />
60+
<form class="new_user" id="new_user_session_small" action="/users/login?return_to=%2Fseries%2F1728802%3Fview_adult%3Dtrue" accept-charset="UTF-8" method="post"><input type="hidden" name="authenticity_token" value="RzvRCzYiHAtKRUv5NM8ECtRVKysFFyOC30bFMjyW2OXrmOANrb7obQPjd7pRXVjqz6ruQS7rUecguhpQI6rWBg" autocomplete="off" />
6161
<dl>
6262
<dt><label for="user_session_login_small">Username or email:</label></dt>
6363
<dd><input autocomplete="on" id="user_session_login_small" type="text" name="user[login]" /></dd>
@@ -281,13 +281,13 @@ <h6 class="landmark heading">Series</h6>
281281
<dd class="comments"><a href="/works/23977417?show_comments=true#comments">27</a></dd>
282282

283283
<dt class="kudos">Kudos:</dt>
284-
<dd class="kudos"><a href="/works/23977417#kudos">565</a></dd>
284+
<dd class="kudos"><a href="/works/23977417#kudos">567</a></dd>
285285

286286
<dt class="bookmarks">Bookmarks:</dt>
287287
<dd class="bookmarks"><a href="/works/23977417/bookmarks">83</a></dd>
288288

289289
<dt class="hits">Hits:</dt>
290-
<dd class="hits">8,337</dd>
290+
<dd class="hits">8,375</dd>
291291

292292
</dl>
293293

@@ -363,13 +363,13 @@ <h6 class="landmark heading">Series</h6>
363363
<dd class="comments"><a href="/works/24121558?show_comments=true#comments">20</a></dd>
364364

365365
<dt class="kudos">Kudos:</dt>
366-
<dd class="kudos"><a href="/works/24121558#kudos">427</a></dd>
366+
<dd class="kudos"><a href="/works/24121558#kudos">429</a></dd>
367367

368368
<dt class="bookmarks">Bookmarks:</dt>
369-
<dd class="bookmarks"><a href="/works/24121558/bookmarks">100</a></dd>
369+
<dd class="bookmarks"><a href="/works/24121558/bookmarks">101</a></dd>
370370

371371
<dt class="hits">Hits:</dt>
372-
<dd class="hits">8,051</dd>
372+
<dd class="hits">8,120</dd>
373373

374374
</dl>
375375

@@ -445,13 +445,13 @@ <h6 class="landmark heading">Series</h6>
445445
<dd class="comments"><a href="/works/24597715?show_comments=true#comments">17</a></dd>
446446

447447
<dt class="kudos">Kudos:</dt>
448-
<dd class="kudos"><a href="/works/24597715#kudos">1,122</a></dd>
448+
<dd class="kudos"><a href="/works/24597715#kudos">1,129</a></dd>
449449

450450
<dt class="bookmarks">Bookmarks:</dt>
451451
<dd class="bookmarks"><a href="/works/24597715/bookmarks">119</a></dd>
452452

453453
<dt class="hits">Hits:</dt>
454-
<dd class="hits">11,734</dd>
454+
<dd class="hits">11,788</dd>
455455

456456
</dl>
457457

@@ -483,7 +483,7 @@ <h4 class="heading">About the Archive</h4>
483483
<li><a href="/tos">Terms of Service</a></li>
484484
<li><a href="/content">Content Policy</a></li>
485485
<li><a href="/privacy">Privacy Policy</a></li>
486-
<li><a href="/dmca">DMCA Policy</a> </li>
486+
<li><a href="/takedown">DMCA &amp; TIDA Policies</a> </li>
487487
<li><a href="https://www.otwstatus.org">Site Status</a></li>
488488
</ul>
489489
</li>
@@ -498,7 +498,7 @@ <h4 class="heading">Contact Us</h4>
498498
<h4 class="heading">Development</h4>
499499
<ul class="menu">
500500
<li>
501-
<a href="https://github.com/otwcode/otwarchive/commits/v0.9.471.1">otwarchive v0.9.471.1</a>
501+
<a href="https://github.com/otwcode/otwarchive/commits/v0.9.474.3">otwarchive v0.9.474.3</a>
502502
</li>
503503
<li><a href="/known_issues">Known Issues</a></li>
504504
<li>
@@ -565,7 +565,7 @@ <h4 class="heading">Development</h4>
565565
}
566566

567567
$j(document).ready(function() {
568-
if (localStorage.getItem("accepted_tos") !== "20241119" && Cookies.get("accepted_tos") !== "20241119") {
568+
if ((!isSupported() || localStorage.getItem("accepted_tos") !== "20241119") && Cookies.get("accepted_tos") !== "20241119") {
569569
$j("body").prepend("<div id=\"tos_prompt\" class=\"hidden\">\n <h2 class=\"heading\">\n <span>Archive of Our Own<\/span>\n <\/h2>\n <div class=\"agreement\">\n <p>\n On the Archive of Our Own (AO3), users can create works, bookmarks, comments, tags, and other <a href=\"/tos_faq#define_content\">Content<\/a>. Any information you publish on AO3 may be accessible by the public, AO3 users, and/or AO3 personnel. Be mindful when sharing personal information, including but not limited to your name, email, age, location, personal relationships, gender or sexual identity, racial or ethnic background, religious or political views, and/or account usernames for other sites.\n <\/p>\n <p>\n To learn more, check out our <a href=\"/tos\">Terms of Service<\/a>, including the <a href=\"/content\">Content Policy<\/a> and <a href=\"/privacy\">Privacy Policy<\/a>.\n <\/p>\n\n <p class=\"confirmation\">\n <input type=\"checkbox\" id=\"tos_agree\" />\n <label for=\"tos_agree\">I have read &amp; understood the 2024 Terms of Service, including the Content Policy and Privacy Policy.<\/label>\n <\/p>\n\n <p class=\"confirmation\">\n <input type=\"checkbox\" id=\"data_processing_agree\" />\n <label for=\"data_processing_agree\">By checking this box, you consent to the processing of your personal data in the United States and other jurisdictions in connection with our provision of AO3 and its related services to you. You acknowledge that the data privacy laws of such jurisdictions may differ from those provided in your jurisdiction. For more information about how your personal data will be processed, please refer to our Privacy Policy.<\/label>\n <\/p>\n\n <p class=\"submit\">\n <button name=\"button\" type=\"button\" disabled=\"disabled\" id=\"accept_tos\">I agree/consent to these Terms<\/button>\n <\/p>\n\n <\/div>\n<\/div>\n\n<script>\n//<![CDATA[\n\n \$j(document).ready(function() {\n var body = document.body;\n var container = \$j(\"#tos_prompt\");\n var outer = document.getElementById(\"outer\");\n var button = document.getElementById(\"accept_tos\");\n var tosCheckbox = document.getElementById(\"tos_agree\");\n var dataProcessingCheckbox = document.getElementById(\"data_processing_agree\");\n\n dataProcessingCheckbox.onclick = checkboxClicked;\n tosCheckbox.onclick = checkboxClicked;\n button.onclick = acceptTOSPrompt;\n\n setTimeout(showTOSPrompt, 1500);\n\n function showTOSPrompt() {\n body.style.overflow = \"hidden\";\n \$j.when(container.fadeIn(500)).done(function() {\n outer.style.visibility = \"hidden\";\n outer.setAttribute(\"aria-hidden\", \"true\");\n });\n }\n\n function checkboxClicked() {\n button.disabled = !tosCheckbox.checked || !dataProcessingCheckbox.checked;\n }\n\n function acceptTOSPrompt() {\n acceptTOS();\n body.style.overflow = \"\";\n outer.removeAttribute(\"style\");\n outer.removeAttribute(\"aria-hidden\");\n \$j.when(container.fadeOut(500)).done(function() {\n container.remove();\n });\n }\n });\n\n//]]]]><![CDATA[>\n<\/script>");
570570
}
571571
});
@@ -588,5 +588,5 @@ <h4 class="heading">Development</h4>
588588
</script>
589589

590590

591-
<script>(function(){function c(){var b=a.contentDocument||a.contentWindow.document;if(b){var d=b.createElement('script');d.innerHTML="window.__CF$cv$params={r:'9e75d6287d86d639',t:'MTc3NTM2MzYyNg=='};var a=document.createElement('script');a.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';document.getElementsByTagName('head')[0].appendChild(a);";b.getElementsByTagName('head')[0].appendChild(d)}}if(document.body){var a=document.createElement('iframe');a.height=1;a.width=1;a.style.position='absolute';a.style.top=0;a.style.left=0;a.style.border='none';a.style.visibility='hidden';document.body.appendChild(a);if('loading'!==document.readyState)c();else if(window.addEventListener)document.addEventListener('DOMContentLoaded',c);else{var e=document.onreadystatechange||function(){};document.onreadystatechange=function(b){e(b);'loading'!==document.readyState&&(document.onreadystatechange=e,c())}}}})();</script></body>
591+
<script>(function(){function c(){var b=a.contentDocument||a.contentWindow.document;if(b){var d=b.createElement('script');d.innerHTML="window.__CF$cv$params={r:'9f9690d2ffe082e7',t:'MTc3ODM5MTE3MQ=='};var a=document.createElement('script');a.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';document.getElementsByTagName('head')[0].appendChild(a);";b.getElementsByTagName('head')[0].appendChild(d)}}if(document.body){var a=document.createElement('iframe');a.height=1;a.width=1;a.style.position='absolute';a.style.top=0;a.style.left=0;a.style.border='none';a.style.visibility='hidden';document.body.appendChild(a);if('loading'!==document.readyState)c();else if(window.addEventListener)document.addEventListener('DOMContentLoaded',c);else{var e=document.onreadystatechange||function(){};document.onreadystatechange=function(b){e(b);'loading'!==document.readyState&&(document.onreadystatechange=e,c())}}}})();</script></body>
592592
</html>

0 commit comments

Comments
Β (0)