Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
johanbissemattsson committed Nov 12, 2024
1 parent 68f58ce commit f774fe3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
11 changes: 11 additions & 0 deletions packages/supersearch/e2e/supersearch.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { test, expect } from '@playwright/test';

test.beforeEach(async ({ page }) => {
await page.goto('/');
});

test('submits closest form on enter key press', async ({ page }) => {
await page.locator('form').getByRole('textbox').locator('div').fill('hello world')
await page.keyboard.press('Enter');
await expect(page).toHaveURL('/find?q=hello+world')
});
7 changes: 5 additions & 2 deletions packages/supersearch/src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<script lang="ts">
import SuperSearch from '$lib/components/SuperSearch.svelte';
let value = $state('');
let placeholder = $state('Search');
</script>

<SuperSearch {placeholder} />

<form action="find">
<SuperSearch bind:value {placeholder} />
<textarea {value} hidden readonly name="q" maxlength={2048}></textarea>
</form>
<label>Placeholder:<input type="text" bind:value={placeholder} /></label>
1 change: 1 addition & 0 deletions packages/supersearch/src/routes/find/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Another test route</h1>

0 comments on commit f774fe3

Please sign in to comment.