mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-02 17:26:24 +00:00
fix(client,sdk): the smaller silent failures, and a dead SDK test file
The SDK's parity suite had an unescaped apostrophe in an it() title, so the file did not parse and vitest reported it as "no tests". Both guards in it were dead - including the byte-identical egress-policy check the package's own notes call the worst possible bug in that module to lose. No CI job runs the SDK suite, so it landed quietly; the next npm publish would have failed on it, since prepublishOnly runs the tests. Also in the SDK: the dev preview answered trek:geolocation without checking the geolocation:read grant, so a plugin whose manifest is missing the permission works perfectly in dev and is dead once installed. That is the lenient direction, which is the one that ships broken plugins. Client side: the background-task poll never dismissed a 404'd import job and spun forever, "Update All" collapsed its busy flag after the first plugin settled, the lightbox had no cancellation so a slow signed URL rendered the wrong image, the plugin geolocation watch was torn down by any unrelated settings write, manual date entry accepted 31 February, cover previews were never revoked, and check-all issued one request per packing item.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// FE-COMP-TRIPFORM-001 to FE-COMP-TRIPFORM-082
|
||||
// FE-COMP-TRIPFORM-001 to FE-COMP-TRIPFORM-084
|
||||
import type { Mock } from 'vitest';
|
||||
import { render, screen, waitFor, fireEvent } from '../../../tests/helpers/render';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
@@ -1214,4 +1214,37 @@ describe('TripFormModal', () => {
|
||||
await waitFor(() => expect(staleResolved).toBe(true));
|
||||
expect(screen.queryByText('Stale failure')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-COMP-TRIPFORM-083: a closed modal fetches nothing until it is opened', async () => {
|
||||
// The trip planner keeps the modal mounted behind the page.
|
||||
const seen: string[] = [];
|
||||
server.use(
|
||||
http.get('/api/auth/users', () => { seen.push('users'); return HttpResponse.json({ users: [] }); }),
|
||||
http.get('/api/trips/:id/members', () => { seen.push('members'); return HttpResponse.json({ members: [] }); }),
|
||||
);
|
||||
const trip = buildTrip({ id: 5 });
|
||||
const { rerender } = render(<TripFormModal {...defaultProps} isOpen={false} trip={trip} />);
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 0));
|
||||
expect(seen).toEqual([]);
|
||||
|
||||
rerender(<TripFormModal {...defaultProps} isOpen trip={trip} />);
|
||||
await waitFor(() => expect(seen).toContain('users'));
|
||||
expect(seen).toContain('members');
|
||||
});
|
||||
|
||||
it('FE-COMP-TRIPFORM-084: staging another cover revokes the preview it replaces', async () => {
|
||||
const revokeObjectURL = vi.fn();
|
||||
const original = URL.revokeObjectURL;
|
||||
Object.defineProperty(URL, 'revokeObjectURL', { writable: true, configurable: true, value: revokeObjectURL });
|
||||
createObjectURL.mockReturnValueOnce('blob:first').mockReturnValueOnce('blob:second');
|
||||
render(<TripFormModal {...defaultProps} trip={null} />);
|
||||
|
||||
fireEvent.change(fileInput(), { target: { files: [pngFile()] } });
|
||||
await waitFor(() => expect(createObjectURL).toHaveBeenCalledTimes(1));
|
||||
fireEvent.change(fileInput(), { target: { files: [pngFile()] } });
|
||||
|
||||
await waitFor(() => expect(revokeObjectURL).toHaveBeenCalledWith('blob:first'));
|
||||
Object.defineProperty(URL, 'revokeObjectURL', { writable: true, configurable: true, value: original });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user