feat(planner): J4 swap flow — action sheet + easiest-first suggestions #45

Merged
marcel merged 11 commits from feat/issue-29-swap-flow into master 2026-04-09 11:19:06 +02:00
2 changed files with 14 additions and 14 deletions
Showing only changes of commit 8e3256d960 - Show all commits

View File

@@ -39,7 +39,7 @@
<p
style="font-size: 10px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--orange-dark); margin: 0 0 4px 0; font-family: var(--font-sans);"
>
Replacing
Wird ersetzt
</p>
<span
data-testid="replacing-name"
@@ -53,7 +53,7 @@
<p
style="font-size: 10px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--color-text-muted); margin: 0 0 6px 0; font-family: var(--font-sans);"
>
Swap to (easiest first)
Ersetzen durch (einfachste zuerst)
</p>
<!-- Recipe list -->
@@ -98,7 +98,7 @@
onclick={() => onpick(recipe.id, recipe.name)}
style="background: none; border: none; cursor: pointer; font-size: 11px; font-weight: 500; color: var(--green); font-family: var(--font-sans); flex-shrink: 0;"
>
Pick
Wählen
</button>
</div>
{/each}
@@ -111,6 +111,6 @@
onclick={oncancel}
style="width: 100%; background: none; border: none; cursor: pointer; color: var(--color-text-muted); font-size: 13px; text-align: center; padding: 8px 0; font-family: var(--font-sans);"
>
Cancel
Abbrechen
</button>
{/if}

View File

@@ -20,7 +20,7 @@ const baseProps = {
describe('SwapSuggestionList', () => {
it('renders the Replacing banner', () => {
render(SwapSuggestionList, { props: baseProps });
expect(screen.getByText(/Replacing/i)).toBeTruthy();
expect(screen.getByText(/Wird ersetzt/i)).toBeTruthy();
});
it('renders old meal name with strikethrough', () => {
@@ -32,7 +32,7 @@ describe('SwapSuggestionList', () => {
it('renders the easiest-first eyebrow label', () => {
render(SwapSuggestionList, { props: baseProps });
expect(screen.getByText(/easiest first/i)).toBeTruthy();
expect(screen.getByText(/einfachste zuerst/i)).toBeTruthy();
});
it('renders all recipe names', () => {
@@ -42,11 +42,11 @@ describe('SwapSuggestionList', () => {
expect(screen.getByText('Mushroom risotto')).toBeTruthy();
});
it('clicking Pick calls onpick with recipeId and name', async () => {
it('clicking Wählen calls onpick with recipeId and name', async () => {
const onpick = vi.fn();
const user = userEvent.setup();
render(SwapSuggestionList, { props: { ...baseProps, onpick } });
const buttons = screen.getAllByRole('button', { name: /Pick/i });
const buttons = screen.getAllByRole('button', { name: /Wählen/i });
await user.click(buttons[0]);
expect(onpick).toHaveBeenCalledWith('r1', 'Quick carbonara');
});
@@ -68,21 +68,21 @@ describe('SwapSuggestionList', () => {
expect(screen.getByTestId('swap-empty-state')).toBeTruthy();
});
it('renders optional Cancel button when oncancel provided', () => {
it('renders optional Abbrechen button when oncancel provided', () => {
render(SwapSuggestionList, { props: { ...baseProps, oncancel: vi.fn() } });
expect(screen.getByRole('button', { name: /Cancel/i })).toBeTruthy();
expect(screen.getByRole('button', { name: /Abbrechen/i })).toBeTruthy();
});
it('does not render Cancel button when oncancel not provided', () => {
it('does not render Abbrechen button when oncancel not provided', () => {
render(SwapSuggestionList, { props: baseProps });
expect(screen.queryByRole('button', { name: /Cancel/i })).toBeNull();
expect(screen.queryByRole('button', { name: /Abbrechen/i })).toBeNull();
});
it('clicking Cancel calls oncancel', async () => {
it('clicking Abbrechen calls oncancel', async () => {
const oncancel = vi.fn();
const user = userEvent.setup();
render(SwapSuggestionList, { props: { ...baseProps, oncancel } });
await user.click(screen.getByRole('button', { name: /Cancel/i }));
await user.click(screen.getByRole('button', { name: /Abbrechen/i }));
expect(oncancel).toHaveBeenCalledOnce();
});
});