fix(plugins): type-specific trakt external id namespaces
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
59ccc90bc1
commit
9708fb5e70
@@ -61,7 +61,7 @@ describe("trakt pull", () => {
|
||||
const r = (await collect(plugin.pull!(ctx))).find((x) => x.key === "history:9001")!;
|
||||
if (r.kind !== "engagement") throw new Error("kind");
|
||||
expect(r.work.mediaType).toBe("movie");
|
||||
expect(r.work.externalIds).toEqual({ trakt: "1001", tmdb_movie: "329865", imdb: "tt2543164" });
|
||||
expect(r.work.externalIds).toEqual({ trakt_movie: "1001", tmdb_movie: "329865", imdb: "tt2543164" });
|
||||
expect(r.engagement.finishedAt).toEqual({ value: "2024-03-05T20:15:00.000Z", precision: "day" });
|
||||
});
|
||||
|
||||
@@ -71,11 +71,12 @@ describe("trakt pull", () => {
|
||||
if (r.kind !== "engagement") throw new Error("kind");
|
||||
expect(r.work.mediaType).toBe("episode");
|
||||
expect(r.work.position).toEqual({ season: 2, episode: 3 });
|
||||
expect(r.work.externalIds).toEqual({ trakt_episode: "5003", tvdb_episode: "7003", tmdb_episode: "8003", imdb: "tt0000003" });
|
||||
expect(r.work.parent?.mediaType).toBe("season");
|
||||
expect(r.work.parent?.position).toEqual({ season: 2 });
|
||||
const show = r.work.parent?.parent;
|
||||
expect(show?.mediaType).toBe("show");
|
||||
expect(show?.externalIds).toEqual({ tmdb_show: "80002", tvdb: "70002", imdb: "tt7000002", trakt: "2002" });
|
||||
expect(show?.externalIds).toEqual({ trakt_show: "2002", tmdb_show: "80002", tvdb_show: "70002", imdb: "tt7000002" });
|
||||
});
|
||||
|
||||
test("rating 8 becomes 80", async () => {
|
||||
@@ -132,6 +133,16 @@ describe("trakt pull", () => {
|
||||
expect(fx.calls[1]!.headers.get("authorization")).toBe("Bearer new-access");
|
||||
});
|
||||
|
||||
test("a failed refresh saves nothing and never calls /sync", async () => {
|
||||
const { fx, ctx } = await setup(
|
||||
{ ...fullRoutes, [`POST ${B}/oauth/token`]: () => new Response("{}", { status: 400 }) },
|
||||
{ ...FRESH, expiresAt: "2024-04-01T12:00:00.000Z" },
|
||||
);
|
||||
await expect(collect(plugin.pull!(ctx))).rejects.toThrow("400");
|
||||
expect(ctx.saved.credentials).toEqual([]);
|
||||
expect(fx.calls.map((c) => new URL(c.url).pathname)).toEqual(["/oauth/token"]);
|
||||
});
|
||||
|
||||
test("a token with more than 24h left is not refreshed", async () => {
|
||||
const { fx, ctx } = await setup(fullRoutes);
|
||||
await collect(plugin.pull!(ctx));
|
||||
|
||||
Reference in New Issue
Block a user