Files
Momento/memento-note/tests/search-quality.spec.ts
Sepehr Ramezani e4d4e23dc7 chore: clean up repo for public release
- Remove BMAD framework, IDE configs, dev screenshots, test files,
  internal docs, and backup files
- Rename keep-notes/ to memento-note/
- Update all references from keep-notes to memento-note
- Add Apache 2.0 license with Commons Clause (non-commercial restriction)
- Add clean .gitignore and .env.docker.example
2026-04-20 22:48:06 +02:00

64 lines
2.6 KiB
TypeScript

import { test, expect } from '@playwright/test';
test.describe('Search Quality Tests', () => {
test.beforeEach(async ({ page }) => {
// 1. Go to Home
await page.goto('/');
// Handle Login if redirected (Mock behavior or real login)
if (page.url().includes('login')) {
// Assuming a simple dev login or we need to bypass.
// For this environment, let's try to just continue or fail explicitly if stuck.
console.log('Redirected to login. Please ensure you are logged in for tests.');
}
});
test('should find notes by semantic concept', async ({ page }) => {
// Clean up existing notes to avoid noise? (Optional, better to just create unique ones)
const timestamp = Date.now();
const techTitle = `React Tech ${timestamp}`;
const foodTitle = `Italian Food ${timestamp}`;
// 2. Create Tech Note
await page.getByPlaceholder('Take a note...').click();
await page.getByPlaceholder('Title').fill(techTitle);
await page.getByPlaceholder('Take a note...').fill('Hooks, useEffect, State management, Components logic.');
await page.getByRole('button', { name: 'Close' }).click();
await expect(page.getByText(techTitle)).toBeVisible();
// 3. Create Food Note
await page.getByPlaceholder('Take a note...').click();
await page.getByPlaceholder('Title').fill(foodTitle);
await page.getByPlaceholder('Take a note...').fill('Tomato sauce, Basil, Parmesan cheese, boiling water.');
await page.getByRole('button', { name: 'Close' }).click();
await expect(page.getByText(foodTitle)).toBeVisible();
// Wait a bit for potential async indexing (even if server action is awaited, good practice)
await page.waitForTimeout(2000);
// 4. Search for "Coding" (Semantic match for React)
const searchInput = page.getByPlaceholder('Search');
await searchInput.fill('Coding');
await searchInput.press('Enter');
// Allow time for search results
await page.waitForTimeout(1000);
// Assertions
// Tech note should be visible
await expect(page.getByText(techTitle)).toBeVisible();
// Food note should NOT be visible (or at least ranked lower/hidden if filtering is strict)
await expect(page.getByText(foodTitle)).toBeHidden();
// 5. Search for "Cooking" (Semantic match for Food)
await searchInput.fill('');
await searchInput.fill('Cooking dinner');
await searchInput.press('Enter');
await page.waitForTimeout(1000);
await expect(page.getByText(foodTitle)).toBeVisible();
await expect(page.getByText(techTitle)).toBeHidden();
});
});