Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

test: cover StylePresetPicker + Loops label associations (#2522)

Adam Eivy15c0fdf87038
diff --git a/client/src/components/media/StylePresetPicker.test.jsx b/client/src/components/media/StylePresetPicker.test.jsx
new file mode 100644
index 0000000000..ae56823cb4
--- /dev/null
+++ b/client/src/components/media/StylePresetPicker.test.jsx
@@ -0,0 +1,36 @@
+import { describe, it, expect, vi } from 'vitest';
+import { render, screen } from '@testing-library/react';
+
+vi.mock('../../services/apiSystem', () => ({
+ listImageStylePresets: vi.fn(() => Promise.resolve([])),
+}));
+
+import StylePresetPicker from './StylePresetPicker';
+
+describe('StylePresetPicker label association', () => {
+ it('pairs the label with the select (htmlFor/id)', async () => {
+ render(<StylePresetPicker value={null} onChange={() => {}} />);
+ // findByLabelText both settles the async preset fetch and asserts the
+ // label→control association is wired.
+ const select = await screen.findByLabelText('Style preset');
+ expect(select.tagName).toBe('SELECT');
+ });
+
+ it('honors a custom label prop', async () => {
+ render(<StylePresetPicker value={null} onChange={() => {}} label="Cover style" />);
+ expect((await screen.findByLabelText('Cover style')).tagName).toBe('SELECT');
+ });
+
+ it('gives each instance a unique control id', async () => {
+ render(
+ <>
+ <StylePresetPicker value={null} onChange={() => {}} label="First" />
+ <StylePresetPicker value={null} onChange={() => {}} label="Second" />
+ </>
+ );
+ const a = await screen.findByLabelText('First');
+ const b = await screen.findByLabelText('Second');
+ expect(a.id).toBeTruthy();
+ expect(a.id).not.toBe(b.id);
+ });
+});
diff --git a/client/src/pages/Loops.test.jsx b/client/src/pages/Loops.test.jsx
new file mode 100644
index 0000000000..c7195da960
--- /dev/null
+++ b/client/src/pages/Loops.test.jsx
@@ -0,0 +1,32 @@
+import { describe, it, expect, vi } from 'vitest';
+import { render, screen } from '@testing-library/react';
+
+vi.mock('../services/api', () => ({
+ getLoops: vi.fn(() => Promise.resolve([])),
+ getLoopProviders: vi.fn(() => Promise.resolve({ providers: [] })),
+ createLoop: vi.fn(() => Promise.resolve({})),
+ stopLoop: vi.fn(() => Promise.resolve({})),
+ resumeLoop: vi.fn(() => Promise.resolve({})),
+ deleteLoop: vi.fn(() => Promise.resolve({})),
+ triggerLoop: vi.fn(() => Promise.resolve({})),
+}));
+
+vi.mock('../services/socket', () => ({
+ default: { on: vi.fn(), off: vi.fn(), emit: vi.fn() },
+}));
+
+vi.mock('../hooks/useAutoRefetch', () => ({
+ useAutoRefetch: vi.fn(),
+}));
+
+import Loops from './Loops';
+
+describe('Loops new-loop form label associations', () => {
+ it('pairs the Interval label with the custom-interval input (htmlFor/id)', async () => {
+ render(<Loops />);
+ // getByLabelText only resolves when the <label> is wired to the control.
+ const input = await screen.findByLabelText('Interval');
+ expect(input.tagName).toBe('INPUT');
+ expect(input.getAttribute('placeholder')).toBe('custom');
+ });
+});