Skip to content

bug(tests): SettingsTabs.test.tsx AdvancedTab failures — missing getGamdlCapabilities mock export #887

@Salem874

Description

@Salem874

Symptom

7 tests in `src/components/settings/tabs/SettingsTabs.test.tsx > AdvancedTab > *` fail with:

```
Error: [vitest] No "getGamdlCapabilities" export is defined on the "@/lib/tauri-commands" mock.
Did you forget to return it from "vi.mock"?
```

Failing tests:

  • `renders Use Wrapper toggle as unchecked when use_wrapper is false`
  • `hides wrapper detail controls when use_wrapper is false`
  • `shows wrapper detail controls when use_wrapper is true`
  • `updates settings store and reveals details when Use Wrapper is toggled on`
  • `renders Download Mode select with correct initial value and options`
  • `updates settings store when Download Mode is changed`
  • `renders Sentry toggle as unchecked when sentry_enabled is false`

Root cause

`AdvancedTab.tsx` calls `getGamdlCapabilities()` on mount (from the #853 GAMDL v3.6 wrapper-v2 work). The test mock at `SettingsTabs.test.tsx` defines `vi.mock("@/lib/tauri-commands")` with a return value that does NOT include the `getGamdlCapabilities` export. Result: the mounted component throws on first effect tick, and every dependent test fails.

Pre-existing — not caused by Dependabot bumps

Discovered while absorbing PRs #882 + #883 (vitest 4.1.6 → 4.1.7). Verified the failures reproduce on the pre-bump state too, so vitest 4.1.7 is not the cause. The mock has been broken since whatever commit added the `getGamdlCapabilities` call to `AdvancedTab.tsx` (likely #853 `f8de3c91` or related).

Fix shape

In `SettingsTabs.test.tsx`, extend the `vi.mock("@/lib/tauri-commands")` return value to include:

```ts
getGamdlCapabilities: vi.fn().mockResolvedValue({
wrapper_v2: false,
native_muxing: false,
aac_web_codec_rename: false,
music_video_remux_mode: true,
wrapper_m3u8_ip: false,
playlist_folder_template: false,
native_codec_priority: false,
ffmpeg_path: false,
}),
```

The mocked value should match the cache-empty default (everything false except music_video_remux_mode which defaults to true per the legacy CLI). Same shape as the production code's `AdvancedTab.tsx` `useState` initializer.

Estimated effort

~15 min. The fix is mechanical; the rest of the test suite continues to pass once the mock export is added.

Cross-link

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions