ci: expand shared package validation and test coverage
- Add lint, formatting, vet, and publish workflow checks - Run Go database tests with PostgreSQL and add Java tests - Make consumer sync opt-in; update docs and Go dependency
This commit is contained in:
1 parent
937f51b4fb
commit
0ff94f9b10
107 files changed
+10124
-410
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/svelte';
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import NotificationStack from '../src/lib/components/NotificationStack.svelte';
|
||||
import { notifications, notify } from '../src/lib/notifications.svelte';
|
||||
|
||||
// The icon library compiles over a thousand components on import; the icons are not under test.
|
||||
vi.mock('@lucide/svelte', () => {
|
||||
const Icon = (): void => {};
|
||||
return { CircleAlert: Icon, CircleCheck: Icon, Info: Icon, OctagonAlert: Icon, X: Icon };
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
for (const entry of [...notifications.entries]) notifications.dismiss(entry.id);
|
||||
});
|
||||
|
||||
describe('NotificationStack', () => {
|
||||
it('renders each notification with its variant and message', async () => {
|
||||
render(NotificationStack);
|
||||
notify.success('Saved', 0);
|
||||
notify.error('Failed', 0);
|
||||
await waitFor(() => expect(screen.getByText('Saved')).toBeTruthy());
|
||||
expect(screen.getByText('Failed')).toBeTruthy();
|
||||
const variants = [...document.querySelectorAll('.sc-notification')].map((node) =>
|
||||
node.getAttribute('data-variant'),
|
||||
);
|
||||
expect(variants).toEqual(['success', 'error']);
|
||||
expect(screen.getByRole('status').getAttribute('aria-live')).toBe('polite');
|
||||
});
|
||||
|
||||
it('dismisses a notification from its close button', async () => {
|
||||
render(NotificationStack);
|
||||
notify.info('Dismiss me', 0);
|
||||
await waitFor(() => expect(screen.getByText('Dismiss me')).toBeTruthy());
|
||||
await fireEvent.click(screen.getByLabelText('Dismiss notification'));
|
||||
expect(notifications.entries).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user