test(channels): cover applySyncFilter + DataTable fixedLayout
- applySyncFilter: the fully/needsFull/all predicate the top chips drive (moved off the retired Sync column) — guards which channels show. - DataTable fixedLayout: asserts the colgroup + table-fixed appear only when opted in, with widths on fixed columns and none on fluid ones.
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
// @vitest-environment jsdom
|
||||
//
|
||||
// applySyncFilter is the sync-status pre-filter the top chips drive (R14 retired the Sync column and
|
||||
// folded its status into a Stored charm). It replaced a column `filter.test`, so it carries the exact
|
||||
// "fully" | "needsFull" | "" vocab + predicate — asserted here so a regression can't silently change
|
||||
// which channels the top chips show.
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { applySyncFilter } from "./channelColumns";
|
||||
import { type ManagedChannel } from "../lib/api";
|
||||
|
||||
const ch = (over: Partial<ManagedChannel>): ManagedChannel => ({
|
||||
id: "c",
|
||||
title: null,
|
||||
handle: null,
|
||||
thumbnail_url: null,
|
||||
subscriber_count: null,
|
||||
video_count: null,
|
||||
description: null,
|
||||
stored_videos: 0,
|
||||
last_video_at: null,
|
||||
total_duration_seconds: 0,
|
||||
count_normal: 0,
|
||||
count_short: 0,
|
||||
count_live: 0,
|
||||
priority: 0,
|
||||
hidden: false,
|
||||
deep_requested: false,
|
||||
deep_in_queue: false,
|
||||
tag_ids: [],
|
||||
details_synced: false,
|
||||
recent_synced: false,
|
||||
backfill_done: false,
|
||||
...over,
|
||||
});
|
||||
|
||||
const rows = [
|
||||
ch({ id: "fully", recent_synced: true, backfill_done: true }),
|
||||
ch({ id: "recentOnly", recent_synced: true, backfill_done: false }),
|
||||
ch({ id: "none", recent_synced: false, backfill_done: false }),
|
||||
];
|
||||
|
||||
describe("applySyncFilter", () => {
|
||||
it("returns every row for the empty/all value (and unknown values)", () => {
|
||||
expect(applySyncFilter(rows, "").map((r) => r.id)).toEqual(["fully", "recentOnly", "none"]);
|
||||
expect(applySyncFilter(rows, undefined)).toHaveLength(3);
|
||||
expect(applySyncFilter(rows, "bogus")).toHaveLength(3);
|
||||
});
|
||||
|
||||
it("'fully' keeps only channels with recent uploads AND full history in", () => {
|
||||
expect(applySyncFilter(rows, "fully").map((r) => r.id)).toEqual(["fully"]);
|
||||
});
|
||||
|
||||
it("'needsFull' keeps every channel whose back-catalogue is not done", () => {
|
||||
expect(applySyncFilter(rows, "needsFull").map((r) => r.id)).toEqual(["recentOnly", "none"]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user