Skip to content

Commit ecf5125

Browse files
committed
Add some tests
Signed-off-by: Cintia Sánchez García <[email protected]>
1 parent 7e875bd commit ecf5125

File tree

5 files changed

+97
-60
lines changed

5 files changed

+97
-60
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
import { waitForGuideData } from './utils/data';
4+
import { gotoExplore } from './utils/navigation';
5+
6+
test.describe('Explore page', () => {
7+
test('shows navigation and footer content', async ({ page }) => {
8+
await gotoExplore(page);
9+
10+
// Navigation bar
11+
await expect(page.getByRole('button', { name: 'Go to "Explore" page' }).first()).toBeVisible();
12+
await expect(page.getByRole('banner').getByText('Explore')).toBeVisible();
13+
await expect(page.getByRole('button', { name: 'Go to "Guide" page' })).toBeVisible();
14+
await expect(page.getByRole('button', { name: 'Go to "Stats" page' })).toBeVisible();
15+
await expect(page.getByRole('button', { name: 'Open "Embeddable view setup"' })).toBeVisible();
16+
await expect(page.getByRole('button', { name: 'Open Dropdown' })).toBeVisible();
17+
await expect(page.getByRole('button', { name: 'Go to "Games" page' })).toBeVisible();
18+
await expect(page.getByRole('banner').getByRole('link', { name: 'Open external link' })).toHaveAttribute(
19+
'href',
20+
'https://github.com/cncf/landscape2'
21+
);
22+
23+
// Footer
24+
await expect(page.getByRole('contentinfo')).toContainText('CNCF interactive landscapes generator');
25+
await expect(page.getByRole('contentinfo')).toContainText('Privacy Policy');
26+
await expect(page.getByRole('contentinfo')).toContainText('Terms of Use');
27+
});
28+
});

ui/webapp/tests/e2e/guide.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
import { waitForGuideData } from './utils/data';
4+
import { gotoExplore, gotoGuide } from './utils/navigation';
5+
6+
test.describe('Guide page', () => {
7+
test('loads guide content when navigating from the header', async ({ page }) => {
8+
await gotoExplore(page);
9+
await Promise.all([waitForGuideData(page), page.getByRole('button', { name: 'Go to "Guide" page' }).click()]);
10+
await expect(page).toHaveURL(/\/guide/);
11+
12+
// Guide headings
13+
await expect(page.getByRole('heading', { name: 'Category 1', exact: true })).toBeVisible();
14+
await expect(page.getByRole('heading', { name: 'Subcategory 1-1' })).toBeVisible();
15+
});
16+
17+
test('loads guide page', async ({ page }) => {
18+
await gotoGuide(page);
19+
20+
// Guide headings
21+
await expect(page.getByRole('heading', { name: 'Category 1', exact: true })).toBeVisible();
22+
await expect(page.getByRole('heading', { name: 'Subcategory 1-1' })).toBeVisible();
23+
});
24+
});

ui/webapp/tests/e2e/home.spec.ts

Lines changed: 0 additions & 58 deletions
This file was deleted.

ui/webapp/tests/e2e/stats.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
import { gotoExplore } from './utils/navigation';
4+
5+
test.describe('Stats page', () => {
6+
test('navigates to stats view from the header', async ({ page }) => {
7+
await gotoExplore(page);
8+
await page.getByRole('button', { name: 'Go to "Stats" page' }).click();
9+
await expect(page).toHaveURL(/\/stats$/);
10+
11+
// Subtitles in stats page
12+
await expect(page.getByText('Distribution by maturity')).toBeVisible();
13+
await expect(page.getByText('Accepted over time')).toBeVisible();
14+
await expect(page.getByText('Promotions')).toBeVisible();
15+
await expect(page.getByText('Security audits')).toBeVisible();
16+
await expect(page.getByText('Distribution by category, subcategory and TAG')).toBeVisible();
17+
await expect(page.getByText('Distribution by category', { exact: true })).toBeVisible();
18+
await expect(page.getByText('Memberships over time')).toBeVisible();
19+
await expect(page.getByText('Most popular languages')).toBeVisible();
20+
await expect(page.getByText('Activity')).toBeVisible();
21+
await expect(page.getByText('Licenses')).toBeVisible();
22+
await expect(page.getByText('Funding rounds', { exact: true })).toBeVisible();
23+
await expect(page.getByText('Acquisitions', { exact: true })).toBeVisible();
24+
});
25+
});

ui/webapp/tests/e2e/utils/navigation.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,29 @@ const registerTemplateRoutes = async (page: Page) => {
4141
]);
4242
};
4343

44-
// Navigate to the home page, registering template routes beforehand
45-
export const gotoHome = async (page: Page) => {
44+
// Navigate to the explore page, registering template routes beforehand
45+
export const gotoExplore = async (page: Page) => {
4646
await registerTemplateRoutes(page);
4747
await Promise.all([
4848
page.waitForResponse((response) => response.url().includes('/static/data/base.json') && response.ok()),
4949
page.goto('/'),
5050
]);
5151
};
52+
53+
// Navigate to the stats page, registering template routes beforehand
54+
export const gotoStats = async (page: Page) => {
55+
await registerTemplateRoutes(page);
56+
await Promise.all([
57+
page.waitForResponse((response) => response.url().includes('/static/data/stats.json') && response.ok()),
58+
page.goto('/stats'),
59+
]);
60+
};
61+
62+
// Navigate to the guide page, registering template routes beforehand
63+
export const gotoGuide = async (page: Page) => {
64+
await registerTemplateRoutes(page);
65+
await Promise.all([
66+
page.waitForResponse((response) => response.url().includes('/static/data/guide.json') && response.ok()),
67+
page.goto('/guide'),
68+
]);
69+
};

0 commit comments

Comments
 (0)