Skip to content

Commit

Permalink
add playwright test
Browse files Browse the repository at this point in the history
  • Loading branch information
miya committed Aug 7, 2024
1 parent bfabf23 commit a3940ac
Showing 1 changed file with 181 additions and 1 deletion.
182 changes: 181 additions & 1 deletion apps/app/playwright/30-search/search.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, expect } from '@playwright/test';
import { test, expect, type Page } from '@playwright/test';

Check failure on line 1 in apps/app/playwright/30-search/search.spec.ts

View workflow job for this annotation

GitHub Actions / test-prod-node20 / run-playwright (chromium, 2/2)

[chromium] › 30-search/search.spec.ts:63:7 › Search all pages › Search all pages by tag is successfully loaded

3) [chromium] › 30-search/search.spec.ts:63:7 › Search all pages › Search all pages by tag is successfully loaded Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Test timeout of 30000ms exceeded.

Check failure on line 1 in apps/app/playwright/30-search/search.spec.ts

View workflow job for this annotation

GitHub Actions / test-prod-node20 / run-playwright (chromium, 2/2)

[chromium] › 30-search/search.spec.ts:63:7 › Search all pages › Search all pages by tag is successfully loaded

3) [chromium] › 30-search/search.spec.ts:63:7 › Search all pages › Search all pages by tag is successfully loaded Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Test timeout of 30000ms exceeded.

test('Search page with "q" param is successfully loaded', async({ page }) => {
// Navigate to the search page with query parameters
Expand Down Expand Up @@ -41,3 +41,183 @@ test('checkboxes behaviors', async({ page }) => {
// Unclick the select all checkbox
await page.getByTestId('cb-select').first().click({ force: true });
});


test('successfully loads /_private-legacy-pages', async({ page }) => {
await page.goto('/_private-legacy-pages');

// Confirm search result elements are visible
await expect(page.locator('[data-testid="search-result-base"]')).toBeVisible();
await expect(page.locator('[data-testid="search-result-private-legacy-pages"]')).toBeVisible();
});

test('Search all pages by word', async({ page }) => {
await page.goto('/');
await page.getByTestId('open-search-modal-button').click();
await expect(page.getByTestId('search-modal')).toBeVisible();
await page.locator('.form-control').fill('sand');
await expect(page.locator('.search-menu-item').first()).toBeVisible();
});

test.describe.serial('Search all pages', () => {
test('Search all pages by tag is successfully loaded', async({ page }) => {
await page.goto('/');

const tag = 'help';
const searchText = `tag:${tag}`;

// open Edit Tags Modal to add tag
await page.locator('.grw-side-contents-sticky-container').isVisible();
await page.locator('#edit-tags-btn-wrapper-for-tooltip').click();
await expect(page.locator('#edit-tag-modal')).toBeVisible();
await page.locator('.rbt-input-main').fill(tag);
await page.locator('#tag-typeahead-asynctypeahead-item-0').click();

Check failure on line 74 in apps/app/playwright/30-search/search.spec.ts

View workflow job for this annotation

GitHub Actions / test-prod-node20 / run-playwright (chromium, 2/2)

[chromium] › 30-search/search.spec.ts:63:7 › Search all pages › Search all pages by tag is successfully loaded

3) [chromium] › 30-search/search.spec.ts:63:7 › Search all pages › Search all pages by tag is successfully loaded Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: locator.click: Test timeout of 30000ms exceeded. Call log: - waiting for locator('#tag-typeahead-asynctypeahead-item-0') 72 | await expect(page.locator('#edit-tag-modal')).toBeVisible(); 73 | await page.locator('.rbt-input-main').fill(tag); > 74 | await page.locator('#tag-typeahead-asynctypeahead-item-0').click(); | ^ 75 | await page.getByTestId('tag-edit-done-btn').click(); 76 | 77 | // Search at /__w/growi/growi/apps/app/playwright/30-search/search.spec.ts:74:64
await page.getByTestId('tag-edit-done-btn').click();

// Search
await page.getByTestId('open-search-modal-button').click();
await expect(page.getByTestId('search-modal')).toBeVisible();
await page.locator('.form-control').fill(searchText);
await page.getByTestId('search-all-menu-item').click();

// Confirm search result elements are visible
const searchResultList = page.getByTestId('search-result-list');
await expect(searchResultList).toBeVisible();

Check failure on line 85 in apps/app/playwright/30-search/search.spec.ts

View workflow job for this annotation

GitHub Actions / test-prod-node20 / run-playwright (chromium, 2/2)

[chromium] › 30-search/search.spec.ts:63:7 › Search all pages › Search all pages by tag is successfully loaded

3) [chromium] › 30-search/search.spec.ts:63:7 › Search all pages › Search all pages by tag is successfully loaded Error: Timed out 7000ms waiting for expect(locator).toBeVisible() Locator: getByTestId('search-result-list') Expected: visible Received: <element(s) not found> Call log: - expect.toBeVisible with timeout 7000ms - waiting for getByTestId('search-result-list') 83 | // Confirm search result elements are visible 84 | const searchResultList = page.getByTestId('search-result-list'); > 85 | await expect(searchResultList).toBeVisible(); | ^ 86 | await expect(searchResultList.locator('li')).toHaveCount(1); 87 | }); 88 | at /__w/growi/growi/apps/app/playwright/30-search/search.spec.ts:85:36
await expect(searchResultList.locator('li')).toHaveCount(1);
});

test('Successfully order page search results by tag', async({ page }) => {
await page.goto('/');

await page.locator('.grw-tag-simple-bar').locator('a').click();

expect(page.getByTestId('search-result-base')).toBeVisible();
expect(page.getByTestId('search-result-list')).toBeVisible();
expect(page.getByTestId('search-result-content')).toBeVisible();
});
});

test.describe('Sort with dropdown', () => {
test.beforeEach(async({ page }) => {
await page.goto('/_search?q=sand');

await expect(page.getByTestId('search-result-base')).toBeVisible();
await expect(page.getByTestId('search-result-list')).toBeVisible();
await expect(page.getByTestId('search-result-content')).toBeVisible();

// open sort dropdown
await page.locator('.search-control').locator('button').first().click();
});

test('Open sort dropdown', async({ page }) => {
await expect(page.locator('.search-control .dropdown-menu.show')).toBeVisible();
});

test('Sort by relevance', async({ page }) => {
const dropdownMenu = page.locator('.search-control .dropdown-menu.show');

await expect(dropdownMenu).toBeVisible();
await dropdownMenu.locator('.dropdown-item').nth(0).click();


await expect(page.getByTestId('search-result-base')).toBeVisible();
await expect(page.getByTestId('search-result-list')).toBeVisible();
await expect(page.getByTestId('search-result-content')).toBeVisible();
});

test('Sort by creation date', async({ page }) => {
const dropdownMenu = page.locator('.search-control .dropdown-menu.show');

await expect(dropdownMenu).toBeVisible();
await dropdownMenu.locator('.dropdown-item').nth(1).click();


await expect(page.getByTestId('search-result-base')).toBeVisible();
await expect(page.getByTestId('search-result-list')).toBeVisible();
await expect(page.getByTestId('search-result-content')).toBeVisible();
});

test('Sort by last update date', async({ page }) => {
const dropdownMenu = page.locator('.search-control .dropdown-menu.show');

await expect(dropdownMenu).toBeVisible();
await dropdownMenu.locator('.dropdown-item').nth(2).click();


await expect(page.getByTestId('search-result-base')).toBeVisible();
await expect(page.getByTestId('search-result-list')).toBeVisible();
await expect(page.getByTestId('search-result-content')).toBeVisible();
});
});

test.describe('Search and use', () => {
test.beforeEach(async({ page }) => {
await page.goto('/_search?q=labels alerts cards blocks');

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 page.getByTestId('page-list-item-L').first().getByTestId('open-page-item-control-btn').click();
await expect(page.locator('.dropdown-menu.show')).toBeVisible();
});

test('Successfully the dropdown is opened', async({ page }) => {
await expect(page.locator('.dropdown-menu.show')).toBeVisible();
});

test('Successfully add bookmark', async({ page }) => {
const dropdonwMenu = page.locator('.dropdown-menu.show');

await expect(dropdonwMenu).toBeVisible();

// Add bookmark
await dropdonwMenu.getByTestId('add-bookmark-btn').click();

await expect(page.getByTestId('search-result-content').locator('.btn-bookmark.active').first()).toBeVisible();
});

test('Successfully open duplicate modal', async({ page }) => {
const dropdonwMenu = page.locator('.dropdown-menu.show');

await expect(dropdonwMenu).toBeVisible();

await dropdonwMenu.getByTestId('open-page-duplicate-modal-btn').click();

await expect(page.getByTestId('page-duplicate-modal')).toBeVisible();
});

test('Successfully open move/rename modal', async({ page }) => {
const dropdonwMenu = page.locator('.dropdown-menu.show');

await expect(dropdonwMenu).toBeVisible();

await dropdonwMenu.getByTestId('rename-page-btn').click();

await expect(page.getByTestId('page-rename-modal')).toBeVisible();
});

test('Successfully open delete modal', async({ page }) => {
const dropdonwMenu = page.locator('.dropdown-menu.show');

await expect(dropdonwMenu).toBeVisible();

await dropdonwMenu.getByTestId('open-page-delete-modal-btn').click();

await expect(page.getByTestId('page-delete-modal')).toBeVisible();
});
});

test('Search current tree by word is successfully loaded', async({ page }) => {
await page.goto('/');
const searchText = 'GROWI';

await page.getByTestId('open-search-modal-button').click();
await expect(page.getByTestId('search-modal')).toBeVisible();
await page.locator('.form-control').fill(searchText);
await page.getByTestId('search-prefix-menu-item').click();

await expect(page.getByTestId('search-result-base')).toBeVisible();
await expect(page.getByTestId('search-result-list')).toBeVisible();
await expect(page.getByTestId('search-result-content')).toBeVisible();
});

0 comments on commit a3940ac

Please sign in to comment.