From 39bb3c30173b0cfccedd03704f30f836e8df7644 Mon Sep 17 00:00:00 2001 From: sirin Date: Thu, 3 Oct 2024 09:52:11 +0700 Subject: [PATCH] Add tag filter and search test --- src/components/extendableCard.tsx | 5 ++++- tests/test-1.spec.ts | 20 +++++++++++++++----- tests/test-2.spec.ts | 23 +++++++++++++++++++++-- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/components/extendableCard.tsx b/src/components/extendableCard.tsx index fe85be5..f14665b 100644 --- a/src/components/extendableCard.tsx +++ b/src/components/extendableCard.tsx @@ -47,7 +47,10 @@ export function ExtendableCard(props: ExtendableCardProps) {
{props.tags.map((tag) => ( - + {tag} ))} diff --git a/tests/test-1.spec.ts b/tests/test-1.spec.ts index 23ccd59..8cbae1b 100644 --- a/tests/test-1.spec.ts +++ b/tests/test-1.spec.ts @@ -4,10 +4,20 @@ test.use({ storageState: './storageState.json' }); -test('test', async ({ page }) => { +test('Test search businesses', async ({ page }) => { await page.goto('http://127.0.0.1:3000/'); await page.getByLabel('Main').getByRole('img').click(); - await page.getByPlaceholder('Enter business name...').click(); - await page.getByPlaceholder('Enter business name...').fill('neon'); - await page.getByPlaceholder('Enter business name...').press('Enter'); -}); \ No newline at end of file + + const businessInput = page.getByPlaceholder('Enter business name...'); + await expect(businessInput).toBeVisible(); + await businessInput.fill('neon'); + await businessInput.press('Enter'); + + const heading = page.getByRole('heading', { name: 'Neon Solution, A dummy company' }); + await expect(heading).toBeVisible(); + await heading.click(); + + const fundSection = page.locator('div').filter({ hasText: /^Neon raising fund #1$/ }); + await expect(fundSection).toBeVisible(); + await fundSection.click(); +}); diff --git a/tests/test-2.spec.ts b/tests/test-2.spec.ts index 2e4a427..61d200a 100644 --- a/tests/test-2.spec.ts +++ b/tests/test-2.spec.ts @@ -4,8 +4,27 @@ test.use({ storageState: './storageState.json' }); -test('test', async ({ page }) => { +test('Test filter with tags', async ({ page }) => { await page.goto('http://127.0.0.1:3000/'); await page.getByRole('button', { name: 'Start Investing' }).click(); - await page.getByRole('heading', { name: 'Investment Opportunities' }).click(); + + await page.locator('button').filter({ hasText: 'Tags' }).click(); + await page.getByLabel('AI', { exact: true }).click(); + await page.locator('span#tag', { hasText: 'AI' }); + + await page.locator('button').filter({ hasText: 'AI' }).click(); + await page.getByLabel('Technology').click(); + await page.locator('span#tag', { hasText: 'Technology' }); + + await page.locator('button').filter({ hasText: 'Technology' }).click(); + await page.getByText('Consumer Electronics').click(); + await page.locator('span#tag', { hasText: 'Consumer Electronics' }); + + await page.locator('button').filter({ hasText: 'Consumer Electronics' }).click(); + await page.getByLabel('Software').click(); + await page.locator('span#tag', { hasText: 'Software' }); + + await page.locator('button').filter({ hasText: 'Software' }).click(); + await page.getByLabel('Internet').click(); + await page.locator('span#tag', { hasText: 'Internet' }); }); \ No newline at end of file