style(13-03): apply Prettier formatting across repo
Mechanical reformat — no logic changes. 398 files changed, 19125 insertions(+), 16457 deletions(-). Prettier 3.8.4 with .prettierrc (singleQuote:true, semi:true, tabWidth:2, trailingComma:all, printWidth:100). Isolated per D-13-08 for reviewability.
This commit is contained in:
@@ -7,8 +7,8 @@
|
||||
* - onClose (the sheet-close prop) is NOT called when the dialog opens
|
||||
*/
|
||||
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { render, screen, fireEvent } from '@testing-library/react'
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
|
||||
// ── Module mocks ──────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -20,7 +20,7 @@ vi.mock('../hooks/usePushSubscription.js', () => ({
|
||||
setEnabled: vi.fn(),
|
||||
})),
|
||||
readNotificationsEnabled: vi.fn(() => false),
|
||||
}))
|
||||
}));
|
||||
|
||||
// ── Minimal Notification stub (jsdom lacks it) ────────────────────────────────
|
||||
|
||||
@@ -30,60 +30,60 @@ beforeEach(() => {
|
||||
value: { permission: 'denied' },
|
||||
writable: true,
|
||||
configurable: true,
|
||||
})
|
||||
});
|
||||
} else {
|
||||
Object.defineProperty(globalThis.Notification, 'permission', {
|
||||
value: 'denied',
|
||||
writable: true,
|
||||
configurable: true,
|
||||
})
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// ── Import component (after mocks) ────────────────────────────────────────────
|
||||
|
||||
import { SettingsSheet } from './SettingsSheet.js'
|
||||
import { SettingsSheet } from './SettingsSheet.js';
|
||||
|
||||
// ── Tests ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
describe('SettingsSheet — "How to enable" wiring (UAT-05-T4)', () => {
|
||||
it('clicking "How to enable" opens the InstructionSheet dialog and does NOT call onClose', () => {
|
||||
const onCloseSpy = vi.fn()
|
||||
render(<SettingsSheet isOpen={true} onClose={onCloseSpy} />)
|
||||
const onCloseSpy = vi.fn();
|
||||
render(<SettingsSheet isOpen={true} onClose={onCloseSpy} />);
|
||||
|
||||
// No instruction dialog yet
|
||||
expect(screen.queryByRole('dialog', { name: /re-enable notifications/i })).toBeNull()
|
||||
expect(screen.queryByRole('dialog', { name: /re-enable notifications/i })).toBeNull();
|
||||
|
||||
// Click the "How to enable" button
|
||||
const howToEnableBtn = screen.getByText('How to enable')
|
||||
fireEvent.click(howToEnableBtn)
|
||||
const howToEnableBtn = screen.getByText('How to enable');
|
||||
fireEvent.click(howToEnableBtn);
|
||||
|
||||
// The InstructionSheet dialog should now be visible
|
||||
const instructionDialog = screen.getByRole('dialog', { name: /re-enable notifications/i })
|
||||
expect(instructionDialog).toBeDefined()
|
||||
const instructionDialog = screen.getByRole('dialog', { name: /re-enable notifications/i });
|
||||
expect(instructionDialog).toBeDefined();
|
||||
|
||||
// The heading inside the dialog
|
||||
expect(screen.getByText('How to enable notifications')).toBeDefined()
|
||||
expect(screen.getByText('How to enable notifications')).toBeDefined();
|
||||
|
||||
// onClose (sheet close prop) must NOT have been called
|
||||
expect(onCloseSpy).not.toHaveBeenCalled()
|
||||
})
|
||||
expect(onCloseSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('InstructionSheet "Done" button closes the instruction dialog without calling sheet onClose', () => {
|
||||
const onCloseSpy = vi.fn()
|
||||
render(<SettingsSheet isOpen={true} onClose={onCloseSpy} />)
|
||||
const onCloseSpy = vi.fn();
|
||||
render(<SettingsSheet isOpen={true} onClose={onCloseSpy} />);
|
||||
|
||||
// Open the instruction sheet
|
||||
fireEvent.click(screen.getByText('How to enable'))
|
||||
expect(screen.getByRole('dialog', { name: /re-enable notifications/i })).toBeDefined()
|
||||
fireEvent.click(screen.getByText('How to enable'));
|
||||
expect(screen.getByRole('dialog', { name: /re-enable notifications/i })).toBeDefined();
|
||||
|
||||
// Click Done — closes the instruction sheet
|
||||
fireEvent.click(screen.getByText('Done'))
|
||||
fireEvent.click(screen.getByText('Done'));
|
||||
|
||||
// Instruction dialog should be gone
|
||||
expect(screen.queryByRole('dialog', { name: /re-enable notifications/i })).toBeNull()
|
||||
expect(screen.queryByRole('dialog', { name: /re-enable notifications/i })).toBeNull();
|
||||
|
||||
// Sheet onClose must NOT have been called
|
||||
expect(onCloseSpy).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
expect(onCloseSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user