fix(web/test): MobileNavDrawer inert + integrations Save mocks Test first

MobileNavDrawer: Svelte 5 + jsdom binds `inert` as a property, not always
an attribute. Mirror the QueueDrawer.test.ts pattern that accepts either.

Integrations Save tests: Per commit bca8622 (Save runs Test first), the
two existing Save tests need to mock testLidarrConnection before clicking
Save — otherwise the Test step returns undefined, fails the ok check,
and putLidarrConfig is never reached. The newer 'Lidarr first-time
setup' suite already does this; just bringing the older two tests in
line. Also wrapped the assertions in waitFor since the put-config call
now resolves async after the test promise.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-09 21:21:04 -04:00
parent 3ffd9beca0
commit 084c202654
2 changed files with 26 additions and 13 deletions
@@ -30,7 +30,11 @@ describe('MobileNavDrawer', () => {
render(MobileNavDrawer);
const aside = screen.getByLabelText('Main navigation');
expect(aside.getAttribute('aria-hidden')).toBe('true');
expect(aside.hasAttribute('inert')).toBe(true);
// Svelte 5 + jsdom binds `inert` as a property, not always as an
// attribute. Mirror the pattern used in QueueDrawer.test.ts.
const inertProp = (aside as unknown as { inert?: boolean }).inert === true;
const inertAttr = aside.hasAttribute('inert');
expect(inertProp || inertAttr).toBe(true);
});
it('flips to visible when mobileNav opens', async () => {
@@ -198,28 +198,37 @@ function providerCard(providerName: string): HTMLElement {
describe('/admin/integrations', () => {
test('Save calls putLidarrConfig with empty api_key when input is blank', async () => {
setup();
// Save now runs Test first (commit bca8622); mock both endpoints. The
// test response also has to match enough of the existing config that
// the Save handler treats it as a valid passthrough.
(testLidarrConnection as ReturnType<typeof vi.fn>).mockResolvedValueOnce(testResponseOk);
(putLidarrConfig as ReturnType<typeof vi.fn>).mockResolvedValueOnce(cfgConnected);
await fireEvent.click(within(lidarrSection()).getByRole('button', { name: /save changes/i }));
expect(putLidarrConfig).toHaveBeenCalledWith(
expect.objectContaining({
enabled: true,
base_url: 'http://lidarr.local',
api_key: '',
default_quality_profile_id: 1,
default_root_folder_path: '/music'
})
);
await waitFor(() => {
expect(putLidarrConfig).toHaveBeenCalledWith(
expect.objectContaining({
enabled: true,
base_url: 'http://lidarr.local',
api_key: '',
default_quality_profile_id: 1,
default_root_folder_path: '/music'
})
);
});
});
test('Save with new api_key sends the typed value', async () => {
setup();
const apiInput = screen.getByPlaceholderText(/saved — leave empty to keep/i);
await fireEvent.input(apiInput, { target: { value: 'newkey' } });
(testLidarrConnection as ReturnType<typeof vi.fn>).mockResolvedValueOnce(testResponseOk);
(putLidarrConfig as ReturnType<typeof vi.fn>).mockResolvedValueOnce(cfgConnected);
await fireEvent.click(within(lidarrSection()).getByRole('button', { name: /save changes/i }));
expect(putLidarrConfig).toHaveBeenCalledWith(
expect.objectContaining({ api_key: 'newkey' })
);
await waitFor(() => {
expect(putLidarrConfig).toHaveBeenCalledWith(
expect.objectContaining({ api_key: 'newkey' })
);
});
});
test('Test connection renders Lidarr version on success', async () => {