Migrate & test

This commit is contained in:
Zoe Roux 2025-03-10 18:56:30 +01:00
parent 2cebdcd63e
commit f6b10738da
No known key found for this signature in database
5 changed files with 1548 additions and 1 deletions

View File

@ -0,0 +1 @@
ALTER TABLE "kyoo"."entries" ADD COLUMN "available_since" timestamp with time zone;

File diff suppressed because it is too large Load Diff

View File

@ -106,6 +106,13 @@
"when": 1741601145901, "when": 1741601145901,
"tag": "0014_staff", "tag": "0014_staff",
"breakpoints": true "breakpoints": true
},
{
"idx": 15,
"version": "7",
"when": 1741623934941,
"tag": "0015_news",
"breakpoints": true
} }
] ]
} }

View File

@ -129,3 +129,28 @@ export const getUnknowns = async (opts: {
const body = await resp.json(); const body = await resp.json();
return [resp, body] as const; return [resp, body] as const;
}; };
export const getNews = async ({
langs,
...opts
}: {
filter?: string;
limit?: number;
after?: string;
query?: string;
langs?: string;
preferOriginal?: boolean;
}) => {
const resp = await app.handle(
new Request(buildUrl("news", opts), {
method: "GET",
headers: langs
? {
"Accept-Language": langs,
}
: {},
}),
);
const body = await resp.json();
return [resp, body] as const;
};

View File

@ -1,5 +1,11 @@
import { beforeAll, describe, expect, it } from "bun:test"; import { beforeAll, describe, expect, it } from "bun:test";
import { createSerie, createVideo, getEntries, getExtras } from "tests/helpers"; import {
createSerie,
createVideo,
getEntries,
getExtras,
getNews,
} from "tests/helpers";
import { expectStatus } from "tests/utils"; import { expectStatus } from "tests/utils";
import { db } from "~/db"; import { db } from "~/db";
import { shows, videos } from "~/db/schema"; import { shows, videos } from "~/db/schema";
@ -48,6 +54,21 @@ describe("Get entries", () => {
part: madeInAbyssVideo.part, part: madeInAbyssVideo.part,
}); });
}); });
it("Get new videos", async () => {
const [resp, body] = await getNews({ langs: "en" });
expectStatus(resp, body).toBe(200);
expect(body.items).toBeArrayOfSize(1);
expect(body.items[0].slug).toBe("made-in-abyss-s1e13");
expect(body.items[0].videos).toBeArrayOfSize(1);
expect(body.items[0].videos[0]).toMatchObject({
path: madeInAbyssVideo.path,
slug: madeInAbyssVideo.slug,
version: madeInAbyssVideo.version,
rendering: madeInAbyssVideo.rendering,
part: madeInAbyssVideo.part,
});
});
}); });
describe("Get extra", () => { describe("Get extra", () => {