Yuki Takei 2 месяцев назад
Родитель
Сommit
5d454d487c
1 измененных файлов с 30 добавлено и 20 удалено
  1. 30 20
      apps/app/playwright/30-search/search.spec.ts

+ 30 - 20
apps/app/playwright/30-search/search.spect.ts → apps/app/playwright/30-search/search.spec.ts

@@ -241,34 +241,37 @@ test('Search current tree by word is successfully loaded', async ({ page }) => {
 });
 
 test.describe('Search result navigation and repeated search', () => {
-  test('Search results redirect to page and repeated search works', async ({ page }) => {
-    // Issue 1: Clicking search result should navigate and update page content
-    // Step 1: Start from the home page
+  test('Repeated search works', async ({ page }) => {
+    // Step 1: Start from the home page and reload to clear any state
     await page.goto('/');
+    await page.reload();
 
     // 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 3: 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 4: Click on the first search result to navigate to a page
-    const firstResult = page.locator('.search-menu-item').first();
-    await firstResult.click();
+    // Step 4: 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();
+    await expect(page).toHaveURL(/\/_search\?q=sandbox/);
+
+    // Step 5: Click on the first search result to navigate to a page
+    const sandboxPageLink = page
+      .getByTestId('search-result-list')
+      .getByRole('link', { name: 'Sandbox' })
+      .first();
+    await sandboxPageLink.click();
+    await expect(page).toHaveTitle(/Sandbox/);
 
-    // Step 5: Verify that modal is closed and navigation completed
-    await expect(page.getByTestId('search-modal')).not.toBeVisible();
-    
-    // Step 6: Verify page content actually changed (not stuck on home page)
-    // Wait for the page to load - check that we're not on the home page anymore
-    await page.waitForLoadState('networkidle');
-    
-    // Verify URL changed from home page
-    await expect(page).not.toHaveURL('/');
+    // Step 6: Wait for leaving search results
+    await expect(page.getByTestId('search-result-base')).not.toBeVisible();
 
-    // Issue 2: Verify repeated search works from any page
     // Step 7: From the navigated page, open search modal again
     await page.getByTestId('open-search-modal-button').click();
     await expect(page.getByTestId('search-modal')).toBeVisible();
@@ -284,8 +287,15 @@ test.describe('Search result navigation and repeated search', () => {
     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/);
+
+    // Step 11: Click on the second search result to navigate to a page
+    const mathPageLink = page
+      .getByTestId('search-result-list')
+      .getByRole('link', { name: 'Math' })
+      .first();
+    await mathPageLink.click();
+    // and verify the page that is not Sandbox is loaded
+    await expect(page).not.toHaveTitle(/Sandbox/);
   });
 });