mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 18:34:09 +00:00
fix(tours): fit the merged tracks together after integration
Types, test expectations and helpers the seven tracks each changed on their own, brought in line with the integrated code. tours.service.ts and the tours repository grew past the size limit with every track and hand their row and write helpers to modules of their own.
This commit is contained in:
@@ -73,6 +73,11 @@ beforeEach(() => {
|
||||
seedStore(useSettingsStore, { settings: { distance_unit: 'metric' } });
|
||||
});
|
||||
|
||||
/** The last of the elements found: the card rendered most recently. */
|
||||
function lastOf<T>(items: T[]): T | undefined {
|
||||
return items[items.length - 1];
|
||||
}
|
||||
|
||||
describe('LegVariantsCard', () => {
|
||||
it('FE-TOUR-LEG-VARIANTS-CARD-001: names the section by its ends and lists each way with its figures', () => {
|
||||
renderCard(comparison());
|
||||
@@ -129,9 +134,9 @@ describe('LegVariantsCard', () => {
|
||||
expect(actions.apply).toHaveBeenCalledTimes(1);
|
||||
|
||||
renderCard(comparison({ selected: 'current' }));
|
||||
expect(screen.getAllByTestId('leg-variants-apply').at(-1)).toBeDisabled();
|
||||
expect(lastOf(screen.getAllByTestId('leg-variants-apply'))).toBeDisabled();
|
||||
renderCard(comparison({ selected: 'a' }), { isSaving: true });
|
||||
expect(screen.getAllByTestId('leg-variants-apply').at(-1)).toBeDisabled();
|
||||
expect(lastOf(screen.getAllByTestId('leg-variants-apply'))).toBeDisabled();
|
||||
});
|
||||
|
||||
it('FE-TOUR-LEG-VARIANTS-CARD-005: while a choice is checked the list stands still and the button says what happens', async () => {
|
||||
@@ -146,15 +151,15 @@ describe('LegVariantsCard', () => {
|
||||
renderCard(comparison({ phase: 'loading', variants: [way('current')] }));
|
||||
expect(screen.getByRole('status')).toHaveTextContent('Looking for other ways');
|
||||
renderCard(comparison({ phase: 'none', variants: [way('current')] }));
|
||||
expect(screen.getAllByRole('status').at(-1)).toHaveTextContent('The router knows no other way');
|
||||
expect(lastOf(screen.getAllByRole('status'))).toHaveTextContent('The router knows no other way');
|
||||
renderCard(comparison({ phase: 'failed', variants: [way('current')] }));
|
||||
expect(screen.getAllByRole('status').at(-1)).toHaveTextContent('The router did not answer');
|
||||
expect(lastOf(screen.getAllByRole('status'))).toHaveTextContent('The router did not answer');
|
||||
renderCard(comparison({ notice: 'notHeld' }));
|
||||
expect(screen.getAllByRole('status').at(-1)).toHaveTextContent('The router does not keep to this way');
|
||||
expect(lastOf(screen.getAllByRole('status'))).toHaveTextContent('The router does not keep to this way');
|
||||
renderCard(comparison({ notice: 'stale' }));
|
||||
expect(screen.getAllByRole('status').at(-1)).toHaveTextContent('The tour changed in the meantime');
|
||||
expect(lastOf(screen.getAllByRole('status'))).toHaveTextContent('The tour changed in the meantime');
|
||||
renderCard(comparison({ notice: 'failed' }));
|
||||
expect(screen.getAllByRole('status').at(-1)).toHaveTextContent('This way could not be checked');
|
||||
expect(lastOf(screen.getAllByRole('status'))).toHaveTextContent('This way could not be checked');
|
||||
});
|
||||
|
||||
it('FE-TOUR-LEG-VARIANTS-CARD-007: the overlay shows only while a section is compared; cancel, the cross and Escape close it', async () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// FE-TOUR-ROUND-HIKE-CARD-001 to FE-TOUR-ROUND-HIKE-CARD-009: the card over the planner map that
|
||||
// looks for round hikes out of a stop and takes one on purpose (RTE-03).
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { beforeEach, describe, expect, it } from 'vitest';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { fireEvent, render, screen, within } from '../../../../tests/helpers/render';
|
||||
import { seedStore } from '../../../../tests/helpers/store';
|
||||
import { idleRoundHikes } from '../../../../tests/helpers/tourPlannerStub';
|
||||
@@ -116,7 +116,7 @@ describe('RoundHikeCard', () => {
|
||||
expect(screen.getByLabelText('Distance')).toHaveValue('6.2');
|
||||
expect(screen.getByText('mi')).toBeInTheDocument();
|
||||
await userEvent.click(screen.getByTestId('round-hike-find'));
|
||||
expect(actions.find.mock.calls[0][0]).toBeCloseTo(9_978, 0);
|
||||
expect(vi.mocked(actions.find).mock.calls[0][0]).toBeCloseTo(9_978, 0);
|
||||
});
|
||||
|
||||
it('FE-TOUR-ROUND-HIKE-CARD-004: while it looks, the bar fills, the rounds found show and nothing can be taken yet', async () => {
|
||||
|
||||
Reference in New Issue
Block a user