mirror of
https://github.com/bretzel-app/crumbs.git
synced 2026-10-12 20:06:57 +02:00
- Add docs/TESTING.md with 10 BDD testing best practices - Add createNote() helper to fixtures to DRY up state setup - Add createChecklistNote() helper in checklist tests - Rename scenario titles to describe outcomes, not actions - Replace imperative Given steps with createNote() helper - Fix fragile conditional in tag filtering test (silent pass) - Remove implementation details from Gherkin comments - Improve Given/When/Then rhythm consistency across all tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
35 lines
1.4 KiB
TypeScript
35 lines
1.4 KiB
TypeScript
import { test, expect, createNote } from './helpers/fixtures.js';
|
|
|
|
test.describe('Search', () => {
|
|
test('Scenario: Searching by title returns the matching note', async ({ authenticatedPage: page }) => {
|
|
// Given a note titled "Grocery Errands" and a note titled "Work Meeting" exist
|
|
await createNote(page, 'Grocery Errands');
|
|
await createNote(page, 'Work Meeting');
|
|
|
|
// When the user searches for "Grocery"
|
|
await page.getByTestId('search-input').fill('Grocery');
|
|
|
|
// Then "Grocery Errands" is visible in the results
|
|
await expect(page.getByText('Grocery Errands')).toBeVisible();
|
|
});
|
|
|
|
test('Scenario: Searching by content returns the matching note', async ({ authenticatedPage: page }) => {
|
|
// Given a note titled "Recipe" with content "Pasta with tomato sauce" exists
|
|
await createNote(page, 'Recipe', 'Pasta with tomato sauce');
|
|
|
|
// When the user searches for "tomato"
|
|
await page.getByTestId('search-input').fill('tomato');
|
|
|
|
// Then "Recipe" is visible in the results
|
|
await expect(page.getByText('Recipe')).toBeVisible();
|
|
});
|
|
|
|
test('Scenario: Searching for a nonexistent term yields no results', async ({ authenticatedPage: page }) => {
|
|
// When the user searches for a term that matches nothing
|
|
await page.getByTestId('search-input').fill('xyznonexistent');
|
|
|
|
// Then no notes are displayed
|
|
await expect(page.getByTestId('note-card')).toHaveCount(0);
|
|
});
|
|
});
|