fix(nav): replace static back-link hrefs with history.back() + fallback #303
@@ -1,6 +1,9 @@
|
||||
import AxeBuilder from '@axe-core/playwright';
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
// [data-hydrated] is set by +layout.svelte once SvelteKit's client-side hydration is complete.
|
||||
// Waiting on it ensures the component is interactive before we interact with it.
|
||||
|
||||
test.describe('BackButton — navigation', () => {
|
||||
test('returns to previous page via history when clicked', async ({ page }) => {
|
||||
// Navigate to persons list, then to a person detail
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<script lang="ts">
|
||||
import { m } from '$lib/paraglide/messages.js';
|
||||
let { class: cls = 'mb-4' }: { class?: string } = $props();
|
||||
</script>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => history.back()}
|
||||
class="group mb-4 inline-flex min-h-[44px] items-center text-xs font-bold tracking-widest text-ink-2 uppercase transition-colors outline-none hover:text-ink focus-visible:ring-2 focus-visible:ring-focus-ring"
|
||||
class="group {cls} inline-flex min-h-[44px] items-center text-xs font-bold tracking-widest text-ink-2 uppercase transition-colors outline-none hover:text-ink focus-visible:ring-2 focus-visible:ring-focus-ring"
|
||||
>
|
||||
<svg
|
||||
class="mr-2 h-4 w-4 transform transition-transform group-hover:-translate-x-1"
|
||||
|
||||
@@ -21,9 +21,16 @@ describe('BackButton', () => {
|
||||
backSpy.mockRestore();
|
||||
});
|
||||
|
||||
it('has min-h-[44px] for touch target compliance', async () => {
|
||||
it('applies mb-4 by default', async () => {
|
||||
render(BackButton);
|
||||
const btn = document.querySelector('button');
|
||||
expect(btn?.className).toContain('min-h-[44px]');
|
||||
expect(btn?.className).toContain('mb-4');
|
||||
});
|
||||
|
||||
it('applies custom class prop instead of default', async () => {
|
||||
render(BackButton, { props: { class: 'mr-3 md:hidden' } });
|
||||
const btn = document.querySelector('button');
|
||||
expect(btn?.className).toContain('mr-3');
|
||||
expect(btn?.className).not.toContain('mb-4');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ async function handleDelete() {
|
||||
|
||||
<DocumentEditLayout doc={doc} formId="update-form" formAction="?/update" formError={form?.error}>
|
||||
{#snippet topbar()}
|
||||
<BackButton />
|
||||
<BackButton class="" />
|
||||
|
||||
<p class="max-w-sm truncate text-center font-serif text-sm font-medium text-ink">
|
||||
{doc.title || doc.originalFilename}
|
||||
|
||||
@@ -15,7 +15,7 @@ const doc = $derived(data.document);
|
||||
|
||||
<DocumentEditLayout doc={doc} formId="save-form" formAction="?/save" formError={form?.error}>
|
||||
{#snippet topbar()}
|
||||
<BackButton />
|
||||
<BackButton class="" />
|
||||
|
||||
<p class="max-w-sm truncate text-center font-serif text-sm font-medium text-ink">
|
||||
{doc.title || doc.originalFilename}
|
||||
|
||||
Reference in New Issue
Block a user