mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 18:04:18 +00:00
94c369b913
Journey Settings get "Prepare recorded days automatically" under GPX Tracks, off by default and set by the owner. With it on, the Dawarich background check also reads the linked trips of the journey for the owner and every editor with a connection of their own, within the same 400 day reach and windows as the trip sync, and only for new and changed stays: a trip the person travels on is not asked twice, and the stays of a trip they are not on are filed under no trip. Nothing is written into the journey; the stays wait at their day, and a stay taken over or left out is never offered again. Under the switch the caller sees when their stays were last fetched, or why not (no connection, no dated trip, background check off, the reason of the last failure beside the state still shown), with a "Fetch now" that the switch also runs when it is turned on. A day of the trips that is not final yet carries a dot on its take-over button, on the phone in the stay sheet, and the tooltip says whether it is still running, was fetched before it ended, was not fetched yet or shows an older state after a failed refresh. The day review says so for today too. Server: migration 046180 adds journeys.auto_prepare_recordings and journey_recording_prep (the last attempt, last success and last error per journey and person). JourneyRecordingPrepService in the journey domain lists the prepared trips and keeps the status; DawarichSyncService walks those trips in the same loop as the person's own and records each journey's outcome. GET /api/journeys/:id/recordings/prep answers the caller's status under a @trek/shared contract, the MCP tool get_journey_recording_prep reads the same, and update_journey takes auto_prepare_recordings like the PUT contract. The column stays out of the plugin output. All 27 locales carry the strings; the Journey, Dawarich and MCP tool wiki pages describe it.
69 lines
3.2 KiB
TypeScript
69 lines
3.2 KiB
TypeScript
// FE-JRN-DAY-IMPORT-BTN-001 to FE-JRN-DAY-IMPORT-BTN-005
|
|
//
|
|
// JRN-02: the day header's way into taking a day over with its stays.
|
|
// JRN-03: the mark of a prepared day that is not final yet.
|
|
import userEvent from '@testing-library/user-event';
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
import { render, screen } from '../../../tests/helpers/render';
|
|
import JourneyDayImportButton from './JourneyDayImportButton';
|
|
|
|
function renderButton(props: Partial<Parameters<typeof JourneyDayImportButton>[0]> = {}) {
|
|
const onOpen = vi.fn();
|
|
const view = render(
|
|
<JourneyDayImportButton pending={0} canTakeOver needsConnection={false} onOpen={onOpen} {...props} />
|
|
);
|
|
return { onOpen, ...view };
|
|
}
|
|
|
|
describe('JourneyDayImportButton', () => {
|
|
it('FE-JRN-DAY-IMPORT-BTN-001: counts the stays still waiting on the day and opens the take-over', async () => {
|
|
const { onOpen } = renderButton({ pending: 6 });
|
|
const button = screen.getByTestId('journey-day-import');
|
|
expect(button).toHaveTextContent('6');
|
|
expect(button).toHaveAccessibleName('6 stays to review');
|
|
await userEvent.click(button);
|
|
expect(onOpen).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it('FE-JRN-DAY-IMPORT-BTN-002: a day with nothing waiting still offers the take-over, without a number', () => {
|
|
renderButton();
|
|
const button = screen.getByTestId('journey-day-import');
|
|
expect(button).toHaveAccessibleName('Take over this day with its stays');
|
|
expect(button.textContent).toBe('');
|
|
});
|
|
|
|
it('FE-JRN-DAY-IMPORT-BTN-003: offline it stays dimmed and says why; without Dawarich or the right to edit it is not there', async () => {
|
|
const { onOpen, unmount } = renderButton({ canTakeOver: false, needsConnection: true, pending: 2 });
|
|
const button = screen.getByTestId('journey-day-import');
|
|
expect(button).toHaveAttribute('aria-disabled', 'true');
|
|
await userEvent.click(button);
|
|
expect(onOpen).not.toHaveBeenCalled();
|
|
unmount();
|
|
|
|
renderButton({ canTakeOver: false, needsConnection: false });
|
|
expect(screen.queryByTestId('journey-day-import')).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('FE-JRN-DAY-IMPORT-BTN-004: a prepared day still running carries a dot and says so after the count', () => {
|
|
renderButton({ pending: 6, prep: { state: 'running', failed: false, lastSuccessAt: null } });
|
|
expect(screen.getByTestId('journey-day-prep-unsettled')).toBeInTheDocument();
|
|
expect(screen.getByTestId('journey-day-import')).toHaveAccessibleName(
|
|
/^6 stays to review\s+The day is still running, more stays may follow\.$/
|
|
);
|
|
});
|
|
|
|
it('FE-JRN-DAY-IMPORT-BTN-005: a day fetched whole carries no dot, one whose refresh failed does', () => {
|
|
const { unmount } = renderButton({
|
|
prep: { state: 'complete', failed: false, lastSuccessAt: '2026-05-15T08:00:00Z' },
|
|
});
|
|
expect(screen.queryByTestId('journey-day-prep-unsettled')).not.toBeInTheDocument();
|
|
unmount();
|
|
|
|
renderButton({ prep: { state: 'complete', failed: true, lastSuccessAt: '2026-05-15T08:00:00Z' } });
|
|
expect(screen.getByTestId('journey-day-prep-unsettled')).toBeInTheDocument();
|
|
expect(screen.getByTestId('journey-day-import')).toHaveAccessibleName(
|
|
/The last refresh failed, this is the older state\./
|
|
);
|
|
});
|
|
});
|