fix(housekeeping): preserve runtime import boundaries
This commit is contained in:
1 parent
b9c47aa89a
commit
1ae59bcc1a
7 files changed
+18
-22
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
anyCapability,
|
||||
type HousekeepingWidgetDefinition,
|
||||
ok,
|
||||
} from "../contracts";
|
||||
import { toHousekeepingWidgetOptions } from "./widget-options";
|
||||
|
||||
describe("toHousekeepingWidgetOptions", () => {
|
||||
it("projects provider definitions to a serializable client view model", () => {
|
||||
const load = vi.fn(async () => ok({ count: 1 }, "widget"));
|
||||
const definitions: readonly HousekeepingWidgetDefinition[] = [
|
||||
{
|
||||
id: "people.queue",
|
||||
owner: "people",
|
||||
capability: anyCapability("admin.users.view"),
|
||||
kind: "mandatory",
|
||||
load,
|
||||
},
|
||||
];
|
||||
|
||||
const options = toHousekeepingWidgetOptions(definitions);
|
||||
|
||||
expect(options).toEqual([{ id: "people.queue", kind: "mandatory" }]);
|
||||
expect(structuredClone(options)).toEqual(options);
|
||||
expect(options[0]).not.toHaveProperty("load");
|
||||
expect(load).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
import type {
|
||||
HousekeepingWidgetDefinition,
|
||||
HousekeepingWidgetKind,
|
||||
} from "../contracts";
|
||||
|
||||
export interface HousekeepingWidgetOption {
|
||||
readonly id: string;
|
||||
readonly kind: HousekeepingWidgetKind;
|
||||
}
|
||||
|
||||
export function toHousekeepingWidgetOptions(
|
||||
definitions: readonly HousekeepingWidgetDefinition[],
|
||||
): readonly HousekeepingWidgetOption[] {
|
||||
return definitions.map(({ id, kind }) => ({ id, kind }));
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import type { HousekeepingResult, HousekeepingWidgetKind } from "../contracts";
|
||||
import type { HousekeepingResult } from "../contracts";
|
||||
import type { HousekeepingPreferences } from "../preferences/schema";
|
||||
import type { HousekeepingWidgetOption } from "../preferences/widget-options";
|
||||
|
||||
export type HousekeepingPreferenceSaver = (
|
||||
preferences: HousekeepingPreferences,
|
||||
@@ -41,11 +42,6 @@ export interface WidgetSettingsLabels {
|
||||
readonly error: string;
|
||||
}
|
||||
|
||||
export interface HousekeepingWidgetOption {
|
||||
readonly id: string;
|
||||
readonly kind: HousekeepingWidgetKind;
|
||||
}
|
||||
|
||||
export function WidgetSettings({
|
||||
preferences: initialPreferences,
|
||||
widgets,
|
||||
|
||||
Reference in new issue
Block a user