mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 10:24:05 +00:00
31859651d7
Every help screen checked against the v5 redesign. Tours is documented for the first time, as a screen of its own with twelve screens under it, and notifications get help of their own. All pictures are taken again on a realistic demo trip, with short loops where a still cannot show the motion. The English is plain and every language is written naturally rather than word for word. The switcher shows two levels at most, a screen's overview lists its sub-screens as cards above its guides, each wiki page is linked once, and the help sidebar is wider. Fixes found along the way: Save to Collection keeps a tour's route, a track dropped on the places column opens the Tours import, tour Share on desktop, the unsaved tour draft lives on the account, a route click no longer adds an end point, Trip places leaves the trip's tours out, Escape closes a stage's day menu, confirms before destructive deletes, DWD warnings sharing one id kept apart, a booking's date moves with it, and smaller fixes across notifications, bookings, the day plan, stays, Atlas, Collections, Vacay and the admin screens.
42 lines
1.7 KiB
TypeScript
42 lines
1.7 KiB
TypeScript
import { fireEvent, renderHook } from '@testing-library/react';
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
import { useTourUndoShortcut } from './useTourUndoShortcut';
|
|
|
|
function setup(overrides: Partial<Parameters<typeof useTourUndoShortcut>[0]> = {}) {
|
|
const undo = vi.fn();
|
|
const redo = vi.fn();
|
|
renderHook(() => useTourUndoShortcut({ enabled: true, canUndo: true, canRedo: true, undo, redo, ...overrides }));
|
|
return { undo, redo };
|
|
}
|
|
|
|
describe('useTourUndoShortcut', () => {
|
|
it('undoes on Ctrl+Z and Cmd+Z, redoes on Ctrl+Shift+Z and Ctrl+Y', () => {
|
|
const { undo, redo } = setup();
|
|
fireEvent.keyDown(document.body, { key: 'z', ctrlKey: true });
|
|
fireEvent.keyDown(document.body, { key: 'z', metaKey: true });
|
|
expect(undo).toHaveBeenCalledTimes(2);
|
|
fireEvent.keyDown(document.body, { key: 'Z', ctrlKey: true, shiftKey: true });
|
|
fireEvent.keyDown(document.body, { key: 'y', ctrlKey: true });
|
|
expect(redo).toHaveBeenCalledTimes(2);
|
|
});
|
|
|
|
it('leaves a text field its own history', () => {
|
|
const { undo } = setup();
|
|
const input = document.createElement('input');
|
|
document.body.append(input);
|
|
fireEvent.keyDown(input, { key: 'z', ctrlKey: true });
|
|
input.remove();
|
|
expect(undo).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('does nothing when closed, locked or without a step to take', () => {
|
|
const closed = setup({ enabled: false });
|
|
const empty = setup({ canUndo: false, canRedo: false });
|
|
fireEvent.keyDown(document.body, { key: 'z', ctrlKey: true });
|
|
fireEvent.keyDown(document.body, { key: 'y', ctrlKey: true });
|
|
expect(closed.undo).not.toHaveBeenCalled();
|
|
expect(empty.undo).not.toHaveBeenCalled();
|
|
expect(empty.redo).not.toHaveBeenCalled();
|
|
});
|
|
});
|