Skip to content

Commit

Permalink
--wip-- [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-h1 committed Dec 11, 2024
1 parent d188ec3 commit c29eb0c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
38 changes: 38 additions & 0 deletions e2e/blog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,42 @@ test.describe('blog', () => {
await expect(page.locator('h1').first()).toHaveText('Blog');
}
});

test('searches correctly', async () => {
const input = page.getByRole('textbox');

await input.fill('Vault');

const title = page.locator('[data-testid="post-title"]', {
hasText: 'Getting started with aws-vault',
});

await expect(title).toHaveText('Getting started with aws-vault');

const otherBlogPost = page.locator('[data-testid="post-title"]', {
hasText: 'Code linters and formatters',
});

await expect(otherBlogPost).not.toBeVisible();

await expect(page).toHaveURL(`${baseUrl}/blog?title=Vault`);
});

test('searches correctly via visting URL param', async () => {
await page.goto(`${baseUrl}/blog?title=playwright`);
const input = page.getByRole('textbox');

await expect(input).toHaveValue('playwright');

const playwrightBlogPost = page.locator('[data-testid="post-title"]', {
hasText: 'Getting started with Playwright UI testing',
});

await expect(playwrightBlogPost).toBeVisible();

const otherBlogPost = page.locator('[data-testid="post-title"]', {
hasText: 'Code linters and formatters',
});
await expect(otherBlogPost).not.toBeVisible();
});
});
1 change: 0 additions & 1 deletion src/app/blog/page.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Input from '@frontend/components/Input';
import PostItem from '@frontend/components/PostItem';
import Spacer from '@frontend/components/Spacer';
import { Post } from '@frontend/types/sanity';
import debounce from 'lodash/debounce';
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
import { ChangeEvent, useCallback, useState } from 'react';

Expand Down

0 comments on commit c29eb0c

Please sign in to comment.