mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Add back isAvailable
for movies
This commit is contained in:
parent
bbbf7b32e0
commit
269003c25d
@ -88,6 +88,7 @@ export async function getShows({
|
||||
status: sql<MovieStatus>`${shows.status}`,
|
||||
airDate: shows.startAir,
|
||||
kind: sql<any>`${shows.kind}`,
|
||||
isAvailable: sql<boolean>`${shows.availableCount} != 0`,
|
||||
|
||||
poster: sql<Image>`coalesce(${showTranslations.poster}, ${poster})`,
|
||||
thumbnail: sql<Image>`coalesce(${showTranslations.thumbnail}, ${thumbnail})`,
|
||||
@ -138,6 +139,7 @@ export async function getShow(
|
||||
extras: {
|
||||
airDate: sql<string>`${shows.startAir}`.as("airDate"),
|
||||
status: sql<MovieStatus>`${shows.status}`.as("status"),
|
||||
isAvailable: sql<boolean>`${shows.availableCount} != 0`.as("isAvailable"),
|
||||
},
|
||||
where: and(isUuid(id) ? eq(shows.id, id) : eq(shows.slug, id), filters),
|
||||
with: {
|
||||
|
@ -59,7 +59,9 @@ export const Movie = t.Intersect([
|
||||
MovieTranslation,
|
||||
BaseMovie,
|
||||
DbMetadata,
|
||||
// t.Object({ isAvailable: t.Boolean() }),
|
||||
t.Object({
|
||||
isAvailable: t.Boolean(),
|
||||
}),
|
||||
]);
|
||||
export type Movie = Prettify<typeof Movie.static>;
|
||||
|
||||
|
@ -2,14 +2,15 @@ import { beforeAll, describe, expect, it } from "bun:test";
|
||||
import { expectStatus } from "tests/utils";
|
||||
import { seedMovie } from "~/controllers/seed/movies";
|
||||
import { db } from "~/db";
|
||||
import { shows } from "~/db/schema";
|
||||
import { bubble } from "~/models/examples";
|
||||
import { shows, videos } from "~/db/schema";
|
||||
import { bubble, bubbleVideo } from "~/models/examples";
|
||||
import { getMovie } from "../helpers";
|
||||
|
||||
let bubbleId = "";
|
||||
|
||||
beforeAll(async () => {
|
||||
await db.delete(shows);
|
||||
await db.insert(videos).values(bubbleVideo);
|
||||
const ret = await seedMovie(bubble);
|
||||
if (!("status" in ret)) bubbleId = ret.id;
|
||||
});
|
||||
@ -116,4 +117,21 @@ describe("Get movie", () => {
|
||||
});
|
||||
expect(resp.headers.get("Content-Language")).toBe("en");
|
||||
});
|
||||
it("With isAvailable", async () => {
|
||||
const [resp, body] = await getMovie(bubble.slug, {});
|
||||
|
||||
expectStatus(resp, body).toBe(200);
|
||||
expect(body.isAvailable).toBe(true);
|
||||
});
|
||||
it("With isAvailable=false", async () => {
|
||||
await seedMovie({
|
||||
...bubble,
|
||||
slug: "no-video",
|
||||
videos: [],
|
||||
});
|
||||
const [resp, body] = await getMovie("no-video", {});
|
||||
|
||||
expectStatus(resp, body).toBe(200);
|
||||
expect(body.isAvailable).toBe(false);
|
||||
});
|
||||
});
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { beforeAll, describe, expect, it } from "bun:test";
|
||||
import { createSerie, getSerie } from "tests/helpers";
|
||||
import { createSerie, createVideo, getSerie } from "tests/helpers";
|
||||
import { expectStatus } from "tests/utils";
|
||||
import { madeInAbyss } from "~/models/examples";
|
||||
import { madeInAbyss, madeInAbyssVideo } from "~/models/examples";
|
||||
|
||||
beforeAll(async () => {
|
||||
await createVideo(madeInAbyssVideo);
|
||||
await createSerie(madeInAbyss);
|
||||
});
|
||||
|
||||
@ -20,7 +21,6 @@ describe("Get seasons", () => {
|
||||
it("With a valid entryCount/availableCount", async () => {
|
||||
const [resp, body] = await getSerie(madeInAbyss.slug, { langs: "en" });
|
||||
|
||||
console.log(body)
|
||||
expectStatus(resp, body).toBe(200);
|
||||
expect(body.entriesCount).toBe(madeInAbyss.entries.length);
|
||||
expect(body.availableCount).toBe(1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user