| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673 |
- // @vitest-environment jsdom
- // 跨窗口自动完成提示抑制:一个窗口播放后,其他窗口不得再播放(Tooltip/撒花)。
- // 覆盖 store 广播/接收、hook 创建期抑制、history/read 提前上报与撒花 arm 清理。
- import { act, renderHook, waitFor } from "@testing-library/react";
- import { createElement, type ReactNode } from "react";
- import { beforeEach, describe, expect, it, vi } from "vitest";
- import type { BroadcastMessage, IBroadcastService, IUsageStatsService } from "@zcode/services";
- import type { CodingPlanResetStatusSnapshot, ZCodeAccountAccess } from "@zcode/shared";
- import { StoreContext } from "@/store/StoreProvider.js";
- const mocks = vi.hoisted(() => ({
- services: null as { usageStatsService: IUsageStatsService } | null,
- toast: vi.fn(),
- }));
- vi.mock("@/hooks/useWorkspaceServices.js", () => ({
- useOptionalBaseWorkspaceServices: () => mocks.services,
- }));
- vi.mock("@/i18n/IntlProvider.js", () => ({
- useZCodeIntl: () => ({
- intl: { formatMessage: ({ id }: { id: string }) => id },
- locale: "zh-CN",
- }),
- }));
- vi.mock("@/components/ui/toast.js", () => ({
- toast: mocks.toast,
- }));
- import { useCodingPlanQuotaResetUi } from "@/hooks/useCodingPlanQuotaResetUi.js";
- import { coordinateCodingPlanQuotaResetAutoPlay } from "@/chat-input-toolbar/codingPlanQuotaResetAutoPlay.js";
- import { pruneCodingPlanQuotaResetConfettiArms } from "@/lib/codingPlanQuotaResetUi.js";
- import { CODING_PLAN_QUOTA_RESET_AUTO_PLAYED_CHANNEL } from "@/store/codingPlanQuotaResetState.js";
- import { createZCodeStore } from "@/store/index.js";
- import type { ZCodeStore } from "@/store/index.js";
- const TEST_ACCOUNT_ACCESS: ZCodeAccountAccess = {
- type: "zhipu-account",
- family: "bigmodel",
- planKind: "individual-coding-plan",
- };
- type BroadcastListener = (message: BroadcastMessage) => void;
- function createBroadcastHarness({
- claimStatus = "acquired",
- }: {
- claimStatus?: "acquired" | "busy" | "committed";
- } = {}) {
- const listeners = new Set<BroadcastListener>();
- const send = vi.fn(async () => undefined);
- const acquireClaim = vi.fn(async (key: string) =>
- claimStatus === "acquired"
- ? { status: "acquired" as const, lease: { key, token: "claim-token" } }
- : claimStatus === "busy"
- ? { status: "busy" as const, retryAfterMs: 100 }
- : { status: "committed" as const },
- );
- const commitClaim = vi.fn(async () => undefined);
- const releaseClaim = vi.fn(async () => undefined);
- const tryClaim = vi.fn(async () => false);
- const service = {
- send,
- acquireClaim,
- commitClaim,
- releaseClaim,
- tryClaim,
- onMessage: (listener: BroadcastListener) => {
- listeners.add(listener);
- return { dispose: () => listeners.delete(listener) };
- },
- } as unknown as IBroadcastService;
- return {
- service,
- send,
- acquireClaim,
- commitClaim,
- releaseClaim,
- tryClaim,
- emit: (message: BroadcastMessage) => {
- for (const listener of listeners) {
- listener(message);
- }
- },
- };
- }
- function automaticCompletedEntry(completedAt: number, observedAt: number | null) {
- return {
- status: "completed" as const,
- opportunityCount: 0,
- opportunityExpiresAt: null,
- startedAt: null,
- completedAt,
- observedAt,
- quotaOverridePending: true,
- nextResetAt: completedAt + 5 * 60 * 60 * 1_000,
- idempotencyKey: null,
- error: null,
- };
- }
- function manualCompletedEntry(completedAt: number, startedAt: number) {
- return { ...automaticCompletedEntry(completedAt, null), startedAt };
- }
- function status(
- overrides: Partial<CodingPlanResetStatusSnapshot> = {},
- ): CodingPlanResetStatusSnapshot {
- return {
- availableFiveHourResets: [],
- availableWeekResets: [],
- latestFiveHourResetHistory: null,
- latestWeekResetHistory: null,
- hasUnreadHistory: false,
- ...overrides,
- };
- }
- function createUsageStatsService(overrides: Partial<IUsageStatsService> = {}): IUsageStatsService {
- return {
- getAppUsageSnapshot: vi.fn(),
- getCodingPlanUsageSnapshot: vi.fn(),
- getCodingPlanResetStatus: vi.fn(async () => status()),
- requestCodingPlanResetOpportunity: vi.fn(async () => ({
- granted: false,
- nextTryAt: null,
- })),
- useCodingPlanReset: vi.fn(async () => ({ used: true as const })),
- markCodingPlanResetHistoryRead: vi.fn(async () => undefined),
- getSnapshot: vi.fn(),
- getEntitlementSnapshot: vi.fn(),
- ...overrides,
- };
- }
- function wrapperFor(store: ZCodeStore) {
- return ({ children }: { children: ReactNode }) =>
- createElement(StoreContext.Provider, { value: store }, children);
- }
- describe("coding plan quota reset autoplay broadcast (store)", () => {
- it("status 写入只记录 observation,非 Composer 入口不占用播放资格", () => {
- const harness = createBroadcastHarness();
- const store = createZCodeStore(harness.service);
- act(() => {
- store
- .getState()
- .setCodingPlanQuotaResetUiEntry(
- "src",
- "FIVE_HOUR",
- automaticCompletedEntry(1_000, 2_000),
- 0,
- );
- });
- expect(store.getState().codingPlanQuotaResetAutoPlayedBySource.src).toBeUndefined();
- expect(harness.acquireClaim).not.toHaveBeenCalled();
- expect(harness.send).not.toHaveBeenCalled();
- });
- it("Composer reservation winner 在 commit 前不写 played、不广播", async () => {
- const harness = createBroadcastHarness();
- const store = createZCodeStore(harness.service);
- act(() => {
- store
- .getState()
- .setCodingPlanQuotaResetUiEntry(
- "src",
- "FIVE_HOUR",
- automaticCompletedEntry(1_000, 2_000),
- 0,
- );
- });
- const attempt = await store
- .getState()
- .reserveCodingPlanQuotaResetAutoPlay("src", "FIVE_HOUR", 1_000);
- expect(attempt).toEqual({
- status: "reserved",
- reservation: expect.objectContaining({
- sourceKey: "src",
- resetType: "FIVE_HOUR",
- completedAt: 1_000,
- }),
- });
- expect(harness.acquireClaim).toHaveBeenCalledWith(
- "coding-plan-reset-autoplay:src:FIVE_HOUR:1000",
- );
- expect(store.getState().codingPlanQuotaResetAutoPlayedBySource.src).toBeUndefined();
- expect(harness.send).not.toHaveBeenCalled();
- if (attempt.status !== "reserved") {
- throw new Error("expected reservation");
- }
- expect(store.getState().commitCodingPlanQuotaResetAutoPlay(attempt.reservation)).toBe(true);
- expect(store.getState().codingPlanQuotaResetAutoPlayedBySource.src?.fiveHour).toBe(1_000);
- expect(harness.commitClaim).toHaveBeenCalledWith(attempt.reservation.lease);
- expect(harness.send).toHaveBeenCalledWith({
- channel: CODING_PLAN_QUOTA_RESET_AUTO_PLAYED_CHANNEL,
- payload: { sourceKey: "src", resetType: "FIVE_HOUR", completedAt: 1_000 },
- });
- expect(store.getState().codingPlanQuotaResetUiBySource.src?.fiveHour?.observedAt).toBe(2_000);
- });
- it("Composer acquire busy 保留 observed_at,不把占用误当成 played", async () => {
- const harness = createBroadcastHarness({ claimStatus: "busy" });
- const store = createZCodeStore(harness.service);
- act(() => {
- store
- .getState()
- .setCodingPlanQuotaResetUiEntry("src", "WEEK", automaticCompletedEntry(3_000, 4_000), 0);
- });
- await expect(
- store.getState().reserveCodingPlanQuotaResetAutoPlay("src", "WEEK", 3_000),
- ).resolves.toEqual({ status: "retry", retryAfterMs: 100 });
- expect(store.getState().codingPlanQuotaResetAutoPlayedBySource.src).toBeUndefined();
- expect(store.getState().codingPlanQuotaResetUiBySource.src?.week?.observedAt).toBe(4_000);
- expect(harness.send).not.toHaveBeenCalled();
- });
- it("reservation 释放时不写 played,后续窗口仍可继续争抢", async () => {
- const harness = createBroadcastHarness();
- const store = createZCodeStore(harness.service);
- act(() => {
- store
- .getState()
- .setCodingPlanQuotaResetUiEntry("src", "WEEK", automaticCompletedEntry(3_000, 4_000), 0);
- });
- const attempt = await store
- .getState()
- .reserveCodingPlanQuotaResetAutoPlay("src", "WEEK", 3_000);
- if (attempt.status !== "reserved") {
- throw new Error("expected reservation");
- }
- await store.getState().releaseCodingPlanQuotaResetAutoPlay(attempt.reservation);
- expect(harness.releaseClaim).toHaveBeenCalledWith(attempt.reservation.lease);
- expect(store.getState().codingPlanQuotaResetAutoPlayedBySource.src).toBeUndefined();
- expect(store.getState().codingPlanQuotaResetUiBySource.src?.week?.observedAt).toBe(4_000);
- expect(harness.send).not.toHaveBeenCalled();
- });
- it("手动完成不会被 claim 成自动播放", async () => {
- const harness = createBroadcastHarness();
- const store = createZCodeStore(harness.service);
- act(() => {
- store
- .getState()
- .setCodingPlanQuotaResetUiEntry("src", "FIVE_HOUR", manualCompletedEntry(1_000, 900), 0);
- });
- await expect(
- store.getState().reserveCodingPlanQuotaResetAutoPlay("src", "FIVE_HOUR", 1_000),
- ).resolves.toEqual({ status: "blocked" });
- expect(harness.acquireClaim).not.toHaveBeenCalled();
- });
- it("收到跨窗口广播后抑制本窗口正在等待 claim 的同 used_at 自动完成", () => {
- const harness = createBroadcastHarness();
- const store = createZCodeStore(harness.service);
- act(() => {
- store
- .getState()
- .setCodingPlanQuotaResetUiEntry(
- "src",
- "FIVE_HOUR",
- automaticCompletedEntry(1_000, Date.now()),
- 0,
- );
- harness.emit({
- channel: CODING_PLAN_QUOTA_RESET_AUTO_PLAYED_CHANNEL,
- payload: {
- sourceKey: "src",
- resetType: "FIVE_HOUR",
- completedAt: 1_000,
- },
- sourceWindowId: 7,
- });
- });
- expect(store.getState().codingPlanQuotaResetUiBySource.src?.fiveHour?.observedAt).toBeNull();
- expect(store.getState().codingPlanQuotaResetAutoPlayedBySource.src?.fiveHour).toBe(1_000);
- });
- it("本地回声(无 sourceWindowId)不抑制 winner 的播放", async () => {
- const harness = createBroadcastHarness();
- const store = createZCodeStore(harness.service);
- act(() => {
- store
- .getState()
- .setCodingPlanQuotaResetUiEntry(
- "src",
- "FIVE_HOUR",
- automaticCompletedEntry(1_000, Date.now()),
- 0,
- );
- });
- const attempt = await store
- .getState()
- .reserveCodingPlanQuotaResetAutoPlay("src", "FIVE_HOUR", 1_000);
- if (attempt.status !== "reserved") {
- throw new Error("expected reservation");
- }
- store.getState().commitCodingPlanQuotaResetAutoPlay(attempt.reservation);
- act(() => {
- harness.emit({
- channel: CODING_PLAN_QUOTA_RESET_AUTO_PLAYED_CHANNEL,
- payload: {
- sourceKey: "src",
- resetType: "FIVE_HOUR",
- completedAt: 1_000,
- },
- });
- });
- expect(
- store.getState().codingPlanQuotaResetUiBySource.src?.fiveHour?.observedAt,
- ).not.toBeNull();
- });
- it("旧广播晚到不会把较新的 played 记录回退", () => {
- const harness = createBroadcastHarness();
- const store = createZCodeStore(harness.service);
- act(() => {
- store.setState({
- codingPlanQuotaResetAutoPlayedBySource: {
- src: { fiveHour: 2_000, week: null },
- },
- });
- harness.emit({
- channel: CODING_PLAN_QUOTA_RESET_AUTO_PLAYED_CHANNEL,
- payload: {
- sourceKey: "src",
- resetType: "FIVE_HOUR",
- completedAt: 1_000,
- },
- sourceWindowId: 7,
- });
- });
- expect(store.getState().codingPlanQuotaResetAutoPlayedBySource.src?.fiveHour).toBe(2_000);
- });
- it("used_at 不匹配的广播只合并 played 记录,不改写 entry", () => {
- const harness = createBroadcastHarness();
- const store = createZCodeStore(harness.service);
- act(() => {
- store
- .getState()
- .setCodingPlanQuotaResetUiEntry(
- "src",
- "WEEK",
- automaticCompletedEntry(5_000, Date.now()),
- 0,
- );
- harness.emit({
- channel: CODING_PLAN_QUOTA_RESET_AUTO_PLAYED_CHANNEL,
- payload: { sourceKey: "src", resetType: "WEEK", completedAt: 9_999 },
- sourceWindowId: 7,
- });
- });
- const entry = store.getState().codingPlanQuotaResetUiBySource.src?.week;
- expect(entry?.completedAt).toBe(5_000);
- expect(entry?.observedAt).not.toBeNull();
- expect(store.getState().codingPlanQuotaResetAutoPlayedBySource.src?.week).toBe(9_999);
- });
- it("非法 payload 的广播被忽略", () => {
- const harness = createBroadcastHarness();
- const store = createZCodeStore(harness.service);
- expect(() => {
- act(() => {
- harness.emit({
- channel: CODING_PLAN_QUOTA_RESET_AUTO_PLAYED_CHANNEL,
- payload: { sourceKey: "src" },
- sourceWindowId: 7,
- });
- harness.emit({
- channel: CODING_PLAN_QUOTA_RESET_AUTO_PLAYED_CHANNEL,
- payload: { sourceKey: "src", resetType: "BAD", completedAt: 1 },
- sourceWindowId: 7,
- });
- });
- }).not.toThrow();
- expect(store.getState().codingPlanQuotaResetAutoPlayedBySource).toEqual({});
- });
- });
- describe("coordinateCodingPlanQuotaResetAutoPlay", () => {
- it("reservation 返回前组件已卸载时只 release,不 commit played", async () => {
- const reservation = {
- sourceKey: "src",
- resetType: "FIVE_HOUR" as const,
- completedAt: 1_000,
- lease: { key: "claim-key", token: "claim-token" },
- };
- let resolveAttempt!: (attempt: { status: "reserved"; reservation: typeof reservation }) => void;
- const reserve = vi.fn(
- () =>
- new Promise<{ status: "reserved"; reservation: typeof reservation }>((resolve) => {
- resolveAttempt = resolve;
- }),
- );
- let current = true;
- const commit = vi.fn(() => true);
- const release = vi.fn(async () => undefined);
- const onCommitted = vi.fn();
- const pending = coordinateCodingPlanQuotaResetAutoPlay({
- reserve,
- isCurrent: () => current,
- commit,
- release,
- onCommitted,
- });
- current = false;
- resolveAttempt({ status: "reserved", reservation });
- await expect(pending).resolves.toEqual({ status: "released" });
- expect(release).toHaveBeenCalledWith(reservation);
- expect(commit).not.toHaveBeenCalled();
- expect(onCommitted).not.toHaveBeenCalled();
- });
- it("仍是当前候选时在同一展示边界 commit 并升级本组件状态", async () => {
- const reservation = {
- sourceKey: "src",
- resetType: "WEEK" as const,
- completedAt: 2_000,
- lease: { key: "claim-key", token: "claim-token" },
- };
- const commit = vi.fn(() => true);
- const release = vi.fn(async () => undefined);
- const onCommitted = vi.fn();
- await expect(
- coordinateCodingPlanQuotaResetAutoPlay({
- reserve: async () => ({ status: "reserved", reservation }),
- isCurrent: () => true,
- commit,
- release,
- onCommitted,
- }),
- ).resolves.toEqual({ status: "committed" });
- expect(commit).toHaveBeenCalledWith(reservation);
- expect(onCommitted).toHaveBeenCalledWith(reservation);
- expect(release).not.toHaveBeenCalled();
- });
- it("展示边界再次校验失败时 release reservation", async () => {
- const reservation = {
- sourceKey: "src",
- resetType: "WEEK" as const,
- completedAt: 2_000,
- lease: { key: "claim-key", token: "claim-token" },
- };
- const release = vi.fn(async () => undefined);
- const onCommitted = vi.fn();
- await expect(
- coordinateCodingPlanQuotaResetAutoPlay({
- reserve: async () => ({ status: "reserved", reservation }),
- isCurrent: () => true,
- commit: () => false,
- release,
- onCommitted,
- }),
- ).resolves.toEqual({ status: "released" });
- expect(release).toHaveBeenCalledWith(reservation);
- expect(onCommitted).not.toHaveBeenCalled();
- });
- });
- describe("coding plan quota reset autoplay broadcast (hook)", () => {
- beforeEach(() => {
- mocks.toast.mockReset();
- Object.defineProperty(document, "visibilityState", {
- configurable: true,
- value: "visible",
- });
- });
- it("played 记录已存在时,轮询进入完成态但不播放提示", async () => {
- const harness = createBroadcastHarness();
- const store = createZCodeStore(harness.service);
- const usedAt = 12_345;
- act(() => {
- store.setState({
- codingPlanQuotaResetAutoPlayedBySource: {
- src: { fiveHour: usedAt, week: null },
- },
- });
- });
- const getCodingPlanResetStatus = vi.fn(async () =>
- status({
- hasUnreadHistory: true,
- latestFiveHourResetHistory: { usedAt },
- }),
- );
- mocks.services = {
- usageStatsService: createUsageStatsService({
- getCodingPlanResetStatus,
- }),
- };
- const hook = renderHook(
- () =>
- useCodingPlanQuotaResetUi({
- sourceKey: "src",
- preferredProviderId: "p",
- accountAccess: TEST_ACCOUNT_ACCESS,
- }),
- { wrapper: wrapperFor(store) },
- );
- await waitFor(() => expect(hook.result.current.done).toBe(true));
- expect(hook.result.current.entry?.completedAt).toBe(usedAt);
- expect(hook.result.current.entry?.observedAt).toBeNull();
- expect(hook.result.current.statusVisible).toBe(false);
- expect(harness.send).not.toHaveBeenCalled();
- });
- it("Hook 观察完成后不自动占用,Composer 显式 claim 才播放", async () => {
- const harness = createBroadcastHarness();
- const store = createZCodeStore(harness.service);
- const usedAt = 23_456;
- mocks.services = {
- usageStatsService: createUsageStatsService({
- getCodingPlanResetStatus: vi.fn(async () =>
- status({
- hasUnreadHistory: true,
- latestFiveHourResetHistory: { usedAt },
- }),
- ),
- }),
- };
- const hook = renderHook(
- () =>
- useCodingPlanQuotaResetUi({
- sourceKey: "src",
- preferredProviderId: "p",
- accountAccess: TEST_ACCOUNT_ACCESS,
- }),
- { wrapper: wrapperFor(store) },
- );
- await waitFor(() => expect(hook.result.current.done).toBe(true));
- expect(harness.acquireClaim).not.toHaveBeenCalled();
- let attempt: Awaited<ReturnType<typeof hook.result.current.reserveAutomaticCompletion>>;
- await act(async () => {
- attempt = await hook.result.current.reserveAutomaticCompletion("FIVE_HOUR", usedAt);
- });
- expect(attempt!).toEqual(expect.objectContaining({ status: "reserved" }));
- expect(harness.acquireClaim).toHaveBeenCalledTimes(1);
- if (attempt!.status !== "reserved") {
- throw new Error("expected reservation");
- }
- expect(hook.result.current.commitAutomaticCompletion(attempt!.reservation)).toBe(true);
- expect(
- store.getState().codingPlanQuotaResetUiBySource.src?.fiveHour?.observedAt,
- ).not.toBeNull();
- });
- it("Hook acquire busy 时保留自动完成候选", async () => {
- const harness = createBroadcastHarness({ claimStatus: "busy" });
- const store = createZCodeStore(harness.service);
- const usedAt = 34_567;
- mocks.services = {
- usageStatsService: createUsageStatsService({
- getCodingPlanResetStatus: vi.fn(async () =>
- status({
- hasUnreadHistory: true,
- latestWeekResetHistory: { usedAt },
- }),
- ),
- }),
- };
- const hook = renderHook(
- () =>
- useCodingPlanQuotaResetUi({
- sourceKey: "src",
- preferredProviderId: "p",
- accountAccess: TEST_ACCOUNT_ACCESS,
- }),
- { wrapper: wrapperFor(store) },
- );
- await waitFor(() => expect(hook.result.current.week.done).toBe(true));
- let attempt: Awaited<ReturnType<typeof hook.result.current.reserveAutomaticCompletion>>;
- await act(async () => {
- attempt = await hook.result.current.reserveAutomaticCompletion("WEEK", usedAt);
- });
- expect(attempt!).toEqual({ status: "retry", retryAfterMs: 100 });
- expect(store.getState().codingPlanQuotaResetUiBySource.src?.week?.observedAt).not.toBeNull();
- });
- it("观察到未读完成后立即上报 history/read,不等待 entitlement 刷新", async () => {
- const harness = createBroadcastHarness();
- const store = createZCodeStore(harness.service);
- const usedAt = 45_678;
- const markCodingPlanResetHistoryRead = vi.fn(async () => undefined);
- mocks.services = {
- usageStatsService: createUsageStatsService({
- getCodingPlanResetStatus: vi.fn(async () =>
- status({
- hasUnreadHistory: true,
- latestFiveHourResetHistory: { usedAt },
- }),
- ),
- markCodingPlanResetHistoryRead,
- }),
- };
- renderHook(
- () =>
- useCodingPlanQuotaResetUi({
- sourceKey: "src",
- preferredProviderId: "p",
- accountAccess: TEST_ACCOUNT_ACCESS,
- // 永不 resolve:旧实现 await 刷新后才上报已读,此测试会超时失败。
- onEntitlementRefresh: () => new Promise<void>(() => {}),
- }),
- { wrapper: wrapperFor(store) },
- );
- await waitFor(() => expect(markCodingPlanResetHistoryRead).toHaveBeenCalledTimes(1));
- });
- });
- describe("pruneCodingPlanQuotaResetConfettiArms", () => {
- it("清除已被抑制或被新 used_at 取代的补播撒花 arm", () => {
- expect(
- pruneCodingPlanQuotaResetConfettiArms(
- { FIVE_HOUR: 100, WEEK: 200 },
- { FIVE_HOUR: null, WEEK: null },
- ),
- ).toEqual({ FIVE_HOUR: null, WEEK: null });
- expect(
- pruneCodingPlanQuotaResetConfettiArms(
- { FIVE_HOUR: 100, WEEK: 200 },
- { FIVE_HOUR: 300, WEEK: 200 },
- ),
- ).toEqual({ FIVE_HOUR: null, WEEK: 200 });
- const unchanged = { FIVE_HOUR: 100 as number | null, WEEK: null };
- expect(
- pruneCodingPlanQuotaResetConfettiArms(unchanged, {
- FIVE_HOUR: 100,
- WEEK: null,
- }),
- ).toBe(unchanged);
- });
- });
|