Add unit tests for channel utilities and configure testing environment

- Created a new test file `channels.test.ts` to cover utilities related to channel configurations and targets.
- Implemented tests for normalizing and grouping selected channels by type, as well as building channel targets from account data and cron history.
- Mocked necessary dependencies to isolate tests and ensure accurate results.
- Updated `vite.config.ts` to set up the testing environment with jsdom and enable global variables for tests.
This commit is contained in:
duanshuwen
2026-04-18 16:12:49 +08:00
parent ee72cf7261
commit ef46c73c3e
26 changed files with 4056 additions and 186 deletions

View File

@@ -0,0 +1,39 @@
type ChannelConfigActionsProps = {
cancelLabel: string;
confirmLabel: string;
onClose: () => void;
onConfirm: () => void;
disabled?: boolean;
submitting?: boolean;
};
export default function ChannelConfigActions({
cancelLabel,
confirmLabel,
onClose,
onConfirm,
disabled,
submitting,
}: ChannelConfigActionsProps) {
return (
<div className="flex items-center justify-end gap-3 pt-1">
<button
type="button"
className="h-[40px] rounded-full bg-[#EDECE4] px-5 text-[13px] font-semibold text-[#4B4B4B] transition-colors hover:bg-[#E5E4DC] disabled:cursor-not-allowed disabled:opacity-60 dark:bg-[#222225] dark:text-gray-200"
onClick={onClose}
disabled={disabled || submitting}
>
{cancelLabel}
</button>
<button
type="button"
className="h-[40px] rounded-full bg-[#2B7FFF] px-5 text-[13px] font-semibold text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60"
onClick={onConfirm}
disabled={disabled || submitting}
>
{submitting ? `${confirmLabel}...` : confirmLabel}
</button>
</div>
);
}