mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 01:44:13 +00:00
fix(mobile): harden back gestures and repair CI regressions
Reflect the drag position in the sheet scrim and match back gestures to the reading direction. Keep Escape on the top overlay and update failing tests for the redesigned forms, navigation, and offline preparation. Remove dead exports and lower obsolete lint counts.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { describe, it, expect, vi, afterEach } from 'vitest';
|
||||
import { render, screen, fireEvent, act } from '@testing-library/react';
|
||||
import { render, screen, fireEvent, createEvent, act } from '@testing-library/react';
|
||||
import MSheet from '../../../src/mobile/components/MSheet';
|
||||
import { closeTopOverlay } from '../../../src/hooks/overlayStack';
|
||||
import { CustomDatePicker } from '../../../src/components/shared/CustomDateTimePicker';
|
||||
@@ -357,6 +357,8 @@ describe('MSheet', () => {
|
||||
fireEvent.touchMove(content, touch(140));
|
||||
fireEvent.touchMove(content, touch(300));
|
||||
expect(dialog.style.transform).toBe('translateY(160px)');
|
||||
const shade = document.querySelector<HTMLElement>('[data-m-scrim]')?.parentElement;
|
||||
expect(shade?.style.opacity).toBe('0.6');
|
||||
|
||||
fireEvent.touchEnd(content, touch(300));
|
||||
expect(onClose).toHaveBeenCalledTimes(1);
|
||||
@@ -375,6 +377,7 @@ describe('MSheet', () => {
|
||||
fireEvent.touchCancel(content, touch(300));
|
||||
|
||||
expect(dialog.style.transform).toBe('translateY(0px)');
|
||||
expect(document.querySelector<HTMLElement>('[data-m-scrim]')?.parentElement?.style.opacity).toBe('1');
|
||||
expect(onClose).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -430,9 +433,12 @@ describe('MSheet', () => {
|
||||
const dialog = screen.getByRole('dialog', { name: 'Form' });
|
||||
const strip = dialog.querySelector('.cursor-grab') as HTMLElement;
|
||||
|
||||
fireEvent.pointerDown(strip, { pointerId: 1, clientY: 100 });
|
||||
fireEvent.pointerMove(strip, { pointerId: 1, clientY: 160 });
|
||||
fireEvent.pointerUp(strip, { pointerId: 1, clientY: 160 });
|
||||
const down = createEvent.pointerDown(strip, { pointerId: 1, clientY: 100 });
|
||||
const move = createEvent.pointerMove(strip, { pointerId: 1, clientY: 160 });
|
||||
const up = createEvent.pointerUp(strip, { pointerId: 1, clientY: 160 });
|
||||
fireEvent(strip, Object.defineProperty(down, 'timeStamp', { value: 100 }));
|
||||
fireEvent(strip, Object.defineProperty(move, 'timeStamp', { value: 140 }));
|
||||
fireEvent(strip, Object.defineProperty(up, 'timeStamp', { value: 150 }));
|
||||
|
||||
expect(onClose).not.toHaveBeenCalled();
|
||||
expect(screen.getByRole('alertdialog')).toBeInTheDocument();
|
||||
@@ -589,8 +595,8 @@ describe('MSheet', () => {
|
||||
const root = panel().closest('[role="presentation"]') as HTMLElement;
|
||||
const scrim = root.querySelector('[data-m-scrim]') as HTMLElement;
|
||||
expect(scrim.className).toContain('m-fade-in');
|
||||
expect(scrim.className).toContain('pointer-events-none');
|
||||
expect(scrim.contains(panel())).toBe(false);
|
||||
expect(scrim.parentElement).toHaveClass('pointer-events-none');
|
||||
expect(scrim.parentElement?.contains(panel())).toBe(false);
|
||||
// No ancestor of the sheet animates its opacity.
|
||||
for (let el: HTMLElement | null = panel().parentElement; el; el = el.parentElement) {
|
||||
expect(el.className || '').not.toMatch(/\bm-fade-(in|out)\b/);
|
||||
|
||||
@@ -46,7 +46,7 @@ describe('form sheet chrome', () => {
|
||||
|
||||
it('FE-MOB-FORMSHEET-002: a long title wraps to a second line instead of being cut after one', () => {
|
||||
render(<Form />);
|
||||
const title = screen.getAllByText('Add expense').find((el) => el.tagName === 'DIV') as HTMLElement;
|
||||
const title = screen.getByRole('heading', { name: 'Add expense' });
|
||||
expect(title).toHaveClass('line-clamp-2');
|
||||
expect(title).not.toHaveClass('truncate');
|
||||
});
|
||||
@@ -87,7 +87,6 @@ describe('form sheet chrome', () => {
|
||||
expect(
|
||||
screen.getByRole('button', { name: /enter date manually|common\.datepicker\.enterManually/i })
|
||||
).toBeInTheDocument();
|
||||
expect(trigger.closest('.rounded-full')).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -122,11 +122,12 @@ describe('JourneyEntryCover sizes', () => {
|
||||
expect(screen.getByText('Kyoto, Japan').className).toContain('line-clamp-2');
|
||||
});
|
||||
|
||||
it("FE-MOB-LARGE-007: a card without a photo is the day's colour, not an empty grey", () => {
|
||||
it('FE-MOB-LARGE-007: a mobile card without a photo uses the neutral sheet surface', () => {
|
||||
render(<JourneyEntryCover entry={entry()} dayColor="#14b8a6" isActive={false} onClick={() => {}} tone="mobile" />);
|
||||
const card = screen.getByRole('button');
|
||||
expect(card.style.backgroundImage).toContain('rgba(20, 184, 166, 0.85)');
|
||||
expect(card.className).toContain('w-[136px]');
|
||||
expect(card).toHaveClass('bg-m-sheetop', 'text-m-ink');
|
||||
expect(card.style.backgroundImage).toBe('');
|
||||
expect(card.className).toContain('w-[144px]');
|
||||
expect(screen.getByText('Kyoto, Japan').className).toContain('truncate');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user