Skip to content

Commit 8734a7b

Browse files
fix current tests
1 parent 3585032 commit 8734a7b

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"scripts": {
3535
"build": "vite build",
3636
"test": "vitest",
37+
"test:update": "vitest -u",
3738
"dev": "vite build --watch",
3839
"coverage": "vitest run --coverage",
3940
"encode-mock-files": "ts-node-esm tests/mocks/scripts/encode-mock-files.mts",

src/page-loaders.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import {
2+
getSeriesUrl,
23
getTagUrl,
34
getTagWorksFeedAtomUrl,
45
getTagWorksFeedUrl,
56
getUserProfileUrl,
7+
getWorkIndexUrl,
68
getWorkUrl,
79
} from "./urls";
810

@@ -105,17 +107,21 @@ export const loadUserProfilePage = async ({
105107
export interface ChapterIndexPage extends CheerioAPI {
106108
kind: "ChapterIndexPage";
107109
}
108-
export const loadChaptersIndexPage = async ({ workId }: { workId: ArchiveId }) => {
110+
export const loadChaptersIndexPage = async ({
111+
workId,
112+
}: {
113+
workId: ArchiveId;
114+
}) => {
109115
return await fetchPage<ChapterIndexPage>({
110-
url: `https://archiveofourown.org/works/${workId}/navigate`,
116+
url: getWorkIndexUrl({ workId }),
111117
});
112118
};
113119

114120
export interface SeriesPage extends CheerioAPI {
115121
kind: "SeriesPage";
116122
}
117-
export const loadSeriesPage = async (seriesId: string) => {
123+
export const loadSeriesPage = async (seriesId: ArchiveId) => {
118124
return await fetchPage<SeriesPage>({
119-
url: `https://archiveofourown.org/series/${seriesId}`,
125+
url: getSeriesUrl({ seriesId }),
120126
});
121127
};

tests/tags.test.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getTag } from "src/index";
2-
import { describe, it, expect } from 'vitest';
2+
import { describe, it, expect } from "vitest";
33

44
describe("Tags/data", () => {
55
it("should fetch id data for canonical tags", async () => {
@@ -233,8 +233,8 @@ describe("Tags/parent", () => {
233233
const tag = await getTag({ tagName: "Sherlock Holmes" });
234234

235235
expect(tag.name).toBe("Sherlock Holmes");
236-
expect(tag.parentTags).toEqual(
237-
expect.arrayContaining([
236+
expect(tag.parentTags).toMatchInlineSnapshot(`
237+
[
238238
"221B Baker Towers",
239239
"A Study in Emerald - Neil Gaiman",
240240
"A Study in Terror (1965)",
@@ -251,8 +251,8 @@ describe("Tags/parent", () => {
251251
"Sherlock & Daughter (TV)",
252252
"Sherlock (TV)",
253253
"Sherlock Holmes & Related Fandoms",
254-
"Sherlock Holmes (1984 TV)",
255-
"Sherlock Holmes (Downey films)",
254+
"Sherlock Holmes (Downey Movies)",
255+
"Sherlock Holmes (Granada TV 1984)",
256256
"Sherlock Holmes (Radio 1989-2010 Coules)",
257257
"Sherlock Holmes (TV 1965)",
258258
"Sherlock Holmes - Arthur Conan Doyle",
@@ -266,13 +266,12 @@ describe("Tags/parent", () => {
266266
"Watson (TV 2025)",
267267
"Шерлок Холмс | Sherlock Holmes (TV 2013)",
268268
"名探偵ホームズ | Sherlock Hound",
269-
])
270-
);
269+
]
270+
`);
271271
});
272272
});
273273

274274
describe("Tags/sub", () => {
275-
276275
it("should fetch subtags", async () => {
277276
const tag = await getTag({ tagName: "Mind Palace" });
278277

tests/user.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,28 @@ describe("User/data", () => {
1717
joined: "2008-09-13",
1818
} satisfies Partial<User>);
1919
});
20-
// Fetches information about a user who filled in optional profile fields
21-
it("should fetch user data from optional profile fields", async () => {
20+
21+
it("should fetch HTML bio from profile fields", async () => {
2222
const astolat = await getUser({
2323
username: "astolat",
2424
});
2525

2626
expect(astolat.bioHtml).toMatchInlineSnapshot(
2727
`"<p>I <a href="https://astolat.dreamwidth.org/125056.html" rel="nofollow">built this city</a>.</p><p>I&apos;m also: <a href="https://astolat.tumblr.com" rel="nofollow">astolat @ Tumblr</a>, <a href="https://twitter.com/intimations" rel="nofollow">@intimations on Twitter</a>, <a href="https://www.youtube.com/user/astolatvids" rel="nofollow">astolatvids on YouTube</a>.</p><p><strong>Blanket Permission Policy</strong><br>I love transformative works based on my work. As long as it&apos;s noncommercial and credit is given, you don&apos;t need to ask permission. More than one person is welcome to podfic/translate/sequel/illustrate/etc any given story. Please post your work here and cite my original story as a related work, so I can link back!</p><p>You can look at my <a href="https://archiveofourown.org/users/astolat/related_works" rel="nofollow">Related Works</a> listing to see existing translations, podfics, and other related works.</p><p><strong>Warnings</strong><br>My work is labeled Choose Not To Warn unless I am confident it is safe. Most of my work is not! I do add more specific warnings sometimes, but my judgement may not align with yours. I don&apos;t tag exhaustively for every story element that appears in my work.</p><p><strong>Collections</strong><br>If you want to add one of my stories to a collection, please bookmark it and add your bookmark to the collection instead. I don&apos;t approve collection requests anymore because of abuse, sorry. :/</p><p><strong>Personal</strong><br>I&#x2019;m a pro writer IRL and my identity is a fairly open secret in fandom, but I prefer not crossing the streams. It&#x2019;s fine to ask about and share it privately, but please don&#x2019;t out me in public and googleable places. That includes comments and tumblr posts/comments! Thank you!</p><p><strong>Pronouns:</strong> she/her</p>"`
2828
);
29+
});
2930

31+
it("should fetch user data from optional profile fields", async () => {
3032
const franzeska = await getUser({
3133
username: "franzeska",
3234
});
3335

3436
expect(franzeska).toMatchObject({
3537
username: "Franzeska",
3638
id: "87",
37-
location: "Oakland",
38-
birthday: "1981-02-13",
39+
// Note: birthday and location were recently removed from AO3, but might still
40+
// be visible in other archives
41+
// TODO: use another archive to test this
3942
icon: expect.stringMatching(
4043
/^https:\/\/archiveofourown\.org\/rails\/active_storage\/representations\/proxy\/[^/]+\/[^/]+\/original\.jpg$/
4144
),

0 commit comments

Comments
 (0)