mirror of
https://github.com/unraid/api.git
synced 2025-12-30 13:09:52 -06:00
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Improved component tests by integrating Pinia's testing utilities for more reliable store mocking and state management. - Updated test setup to streamline plugin usage and remove unnecessary configuration. - Enhanced test clarity by relying on store state changes and Vue's reactivity instead of manual mock updates. - Simplified test cases by focusing on passed props and standardized store mocking. - **Chores** - Updated test directory structure for better organization. - Added additional test mocks for dependencies. - **New Features** - Added comprehensive tests for the ColorSwitcher component, verifying UI elements and theme store interactions. - Introduced tests for the DevSettings component, confirming UI rendering and interaction behavior. - Added detailed tests for the DowngradeOs component covering store interactions and conditional UI rendering. - Added new test suites for DummyServerSwitcher component, ensuring correct rendering and reactive state updates. - Added new test suites for HeaderOsVersion component, validating version badge rendering and error state handling. - Added new test suite for the I18nHost component, validating internationalization context provisioning and error handling. - Added a comprehensive test suite for the Modal component, covering UI behavior, styling, and event handling. - Added new test suite for the Registration component, verifying rendering based on server state. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: mdatelle <mike@datelle.net>
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
/**
|
|
* DevSettings Component Test Coverage
|
|
*/
|
|
|
|
import { nextTick } from 'vue';
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import { CogIcon } from '@heroicons/vue/24/solid';
|
|
import { Button, PopoverContent, PopoverTrigger } from '@unraid/ui';
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
|
|
import DevSettings from '~/components/DevSettings.vue';
|
|
|
|
vi.mock('@unraid/ui', async (importOriginal) => {
|
|
const actual = await importOriginal<typeof import('@unraid/ui')>();
|
|
return {
|
|
...actual,
|
|
};
|
|
});
|
|
|
|
describe('DevSettings', () => {
|
|
it('renders the trigger button and hides content initially', () => {
|
|
const wrapper = mount(DevSettings, {
|
|
global: {
|
|
stubs: { DummyServerSwitcher: true },
|
|
},
|
|
});
|
|
|
|
const triggerButton = wrapper.findComponent(PopoverTrigger).findComponent(Button);
|
|
expect(triggerButton.exists()).toBe(true);
|
|
expect(triggerButton.findComponent(CogIcon).exists()).toBe(true);
|
|
|
|
expect(wrapper.findComponent(PopoverContent).exists()).toBe(true);
|
|
expect(wrapper.findComponent({ name: 'DummyServerSwitcher' }).exists()).toBe(false);
|
|
});
|
|
|
|
it('does not error when trigger button is clicked', async () => {
|
|
const wrapper = mount(DevSettings, {
|
|
global: {
|
|
stubs: { DummyServerSwitcher: true, PopoverContent: true },
|
|
},
|
|
});
|
|
const triggerButton = wrapper.findComponent(PopoverTrigger).findComponent(Button);
|
|
|
|
await triggerButton.trigger('click');
|
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
await nextTick();
|
|
|
|
// No assertion needed here, the test passes if no error is thrown during the click simulation.
|
|
});
|
|
});
|