Răsfoiți Sursa

Add playwright test for search navigation and repeated search functionality

Co-authored-by: kouki-o <13145344+kouki-o@users.noreply.github.com>
copilot-swe-agent[bot] 2 luni în urmă
părinte
comite
de1fb4c9ef
1 a modificat fișierele cu 43 adăugiri și 0 ștergeri
  1. 43 0
      apps/app/playwright/30-search/search.spect.ts

+ 43 - 0
apps/app/playwright/30-search/search.spect.ts

@@ -239,3 +239,46 @@ test('Search current tree by word is successfully loaded', async ({ page }) => {
   await expect(page.getByTestId('search-result-list')).toBeVisible();
   await expect(page.getByTestId('search-result-list')).toBeVisible();
   await expect(page.getByTestId('search-result-content')).toBeVisible();
   await expect(page.getByTestId('search-result-content')).toBeVisible();
 });
 });
+
+test.describe('Search result navigation and repeated search', () => {
+  test('Search results redirect to page and repeated search works', async ({ page }) => {
+    // Issue 1 & 2: Search results navigation and repeated search functionality
+    // Step 1: Start from the home page
+    await page.goto('/');
+
+    // Step 2: Open search modal and search for "sandbox"
+    await page.getByTestId('open-search-modal-button').click();
+    await expect(page.getByTestId('search-modal')).toBeVisible();
+    await page.locator('.form-control').fill('sandbox');
+
+    // Step 3: Wait for search results to appear
+    await expect(page.locator('.search-menu-item').first()).toBeVisible();
+
+    // Step 4: Click on the first search result to navigate to a page
+    const firstResult = page.locator('.search-menu-item').first();
+    await firstResult.click();
+
+    // Step 5: Verify that modal is closed (navigation happened)
+    await expect(page.getByTestId('search-modal')).not.toBeVisible();
+
+    // Issue 2: Verify repeated search works from any page
+    // Step 6: From the navigated page, open search modal again
+    await page.getByTestId('open-search-modal-button').click();
+    await expect(page.getByTestId('search-modal')).toBeVisible();
+
+    // Step 7: Search for the same keyword ("sandbox")
+    await page.locator('.form-control').fill('sandbox');
+
+    // Step 8: Submit the search by clicking on "search in all" menu item
+    await expect(page.getByTestId('search-all-menu-item')).toBeVisible();
+    await page.getByTestId('search-all-menu-item').click();
+
+    // Step 9: Verify that the search page is displayed with results
+    await expect(page.getByTestId('search-result-base')).toBeVisible();
+    await expect(page.getByTestId('search-result-list')).toBeVisible();
+    await expect(page.getByTestId('search-result-content')).toBeVisible();
+
+    // Verify we're on the search page with the correct query
+    await expect(page).toHaveURL(/\/_search\?q=sandbox/);
+  });
+});