Skip to content

Commit 817ec29

Browse files
authored
Merge pull request #4943 from JetBrains/e2e-educational-test
[Meta: Move pages to NextJS] add E2E `/educational/` test
2 parents 7875e09 + 2774739 commit 817ec29

30 files changed

+816
-81
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ generated
5050

5151
/reports*
5252
/data/page_views_map.json
53+
test-results

playwright.config.js

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

playwright.config.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
const MAX_DIFF_PIXEL_RATIO = 0.025 as const;
4+
5+
export default defineConfig({
6+
forbidOnly: !!process.env.CI,
7+
retries: process.env.CI ? 2 : 0,
8+
reporter: process.env.CI ? 'dot' : 'list',
9+
snapshotDir: 'test/snapshots',
10+
expect: {
11+
toMatchSnapshot: { maxDiffPixelRatio: MAX_DIFF_PIXEL_RATIO },
12+
toHaveScreenshot: { maxDiffPixelRatio: MAX_DIFF_PIXEL_RATIO }
13+
},
14+
use: {
15+
baseURL: process.env.BASE_URL || 'http://localhost:9000',
16+
trace: 'off'
17+
},
18+
projects: [
19+
{
20+
name: 'chromium',
21+
use: { ...devices['Desktop Chrome'] }
22+
}
23+
]
24+
});

static/js/ktl-component/courses/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {TeachMap} from '../teach/components/teach-map/teach-map.jsx';
1212
const Courses = ({universities, path}) => {
1313
const [activeIndex, setActiveIndex] = useState(0);
1414
return (
15-
<div>
15+
<div data-test="teach-courses">
1616
<TeachTopMenu path={path} />
1717

1818
<section className="ktl-layout ktl-layout--center">

static/js/ktl-component/teach/components/teach-map/teach-map.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const TeachMap = ({className}) => {
2222
const items = data.map(university => {
2323
return {
2424
...university,
25-
id: `${university.title}-${university.location}`
25+
id: `${university.title}-${university.location}-${university.geo.lat}-${university.geo.lng}`
2626
}
2727
});
2828
setUniversities(items)

static/js/ktl-component/teach/index.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import './style.scss';
1515
import {SubscriptionForm} from './components/subscription-form';
1616
import {TeachMap} from './components/teach-map/teach-map.jsx';
1717
import {SlackIcon} from "@rescui/icons";
18-
import Button from "@rescui/button";
18+
import { Button } from "@rescui/button";
1919
import { TeachLaunchCourse } from "./components/teach-launch-course";
2020

2121
import { useTextStyles } from '@rescui/typography';
@@ -41,7 +41,7 @@ const Teach = (props) => {
4141
rel="noopener"
4242
className="teach-cta-block-button"
4343
>
44-
Join Educators Сommunity
44+
Join Educators Community
4545
</Button>
4646

4747
<Button mode="outline" href="why-teach-kotlin.html" className="teach-cta-block-button">
@@ -121,7 +121,7 @@ const Teach = (props) => {
121121
rel="noopener"
122122
className="teach-cta-block-button"
123123
>
124-
Join Educators Сommunity
124+
Join Educators Community
125125
</Button>
126126

127127
<Button size="l" mode="outline" href="why-teach-kotlin.html" className="teach-cta-block-button">

static/js/ktl-component/why-teach/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import quotes from './quotes.json';
1313
export const WhyTeach = ({path}) => {
1414

1515
return (
16-
<div className="teach-wrapper">
16+
<div className="teach-wrapper" data-test="teach-why-teach-page">
1717
<TeachTopMenu path={path}/>
1818

1919
<div className="ktl-layout ktl-layout--center">

test/e2e/api-references-template-customization.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import { expect, test } from '@playwright/test';
1+
import { expect, Page, test } from '@playwright/test';
22
import { ApiReferencePage } from '../page/api-reference-page';
33

44
const pagesWithCustomizedTemplates = [
55
{
66
name: 'kotlinx.coroutines index',
7-
getInstance: (page) => new ApiReferencePage(page, '/api/kotlinx.coroutines/'),
7+
getInstance: (page: Page) => new ApiReferencePage(page, '/api/kotlinx.coroutines/'),
88
},
99
{
1010
name: 'kotlinx-coroutines-core module',
11-
getInstance: (page) => new ApiReferencePage(page, '/api/kotlinx.coroutines/kotlinx-coroutines-core/'),
11+
getInstance: (page: Page) => new ApiReferencePage(page, '/api/kotlinx.coroutines/kotlinx-coroutines-core/'),
1212
},
1313
{
1414
name: 'kotlinx-serialization index',
15-
getInstance: (page) => new ApiReferencePage(page, '/api/kotlinx.serialization/'),
15+
getInstance: (page: Page) => new ApiReferencePage(page, '/api/kotlinx.serialization/'),
1616
},
1717
{
1818
name: 'kotlinx-serialization-core module',
19-
getInstance: (page) => new ApiReferencePage(page, '/api/kotlinx.serialization/kotlinx-serialization-core/'),
19+
getInstance: (page: Page) => new ApiReferencePage(page, '/api/kotlinx.serialization/kotlinx-serialization-core/'),
2020
},
2121
];
2222

test/e2e/teach/courses.spec.ts

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import { expect, test } from '@playwright/test';
2+
import { CoursesPage } from '../../page/teach/courses-page';
3+
import { closeExternalBanners } from '../utils';
4+
import { testSelector } from '../../utils';
5+
import { checkTeachCta, checkTeachMap, checkTeachNav } from './utils';
6+
7+
test.describe('Courses page appearance and functionality', async () => {
8+
test.beforeEach(async ({ page, context, baseURL }) => {
9+
const coursesPage = new CoursesPage(page);
10+
await coursesPage.init();
11+
await closeExternalBanners(context, page, baseURL);
12+
});
13+
14+
test('Should load the courses page correctly', async ({ page }) => {
15+
// Check if the page title is correct
16+
expect(await page.title()).toBe('List of Courses');
17+
18+
// Check if the main content is visible
19+
const mainContent = page.locator(testSelector('teach-courses'));
20+
await expect(mainContent).toBeVisible();
21+
22+
// Check if the page heading is correct
23+
const title = mainContent.locator('h1');
24+
await expect(title).toBeVisible();
25+
26+
expect(await title.textContent()).toBe('Universities That Teach Kotlin');
27+
});
28+
29+
test('Should have working navigation buttons', async ({ page }) => {
30+
await checkTeachNav(page, 'List of Courses');
31+
});
32+
33+
test('Should have working tab navigation', async ({ page }) => {
34+
// Check if the tab list is visible
35+
const tabList = page.locator(testSelector('tab-list'));
36+
await expect(tabList).toBeVisible();
37+
38+
// Check if both tabs are present
39+
const tableViewTab = tabList.getByRole('tab', { name: 'Table view', exact: true });
40+
await expect(tableViewTab).toBeVisible();
41+
42+
const mapViewTab = tabList.getByRole('tab', { name: 'Map view', exact: true });
43+
await expect(mapViewTab).toBeVisible();
44+
45+
await expect(tableViewTab).toHaveAttribute('data-test', 'tab tab-selected');
46+
await expect(mapViewTab).toHaveAttribute('data-test', 'tab');
47+
48+
// CoursesList should be visible in the table view
49+
await expect(page.locator('.ktl-courses-list')).toBeVisible();
50+
51+
// Switch to the map view
52+
await mapViewTab.click();
53+
54+
// Map view should now be active
55+
await expect(tableViewTab).toHaveAttribute('data-test', 'tab');
56+
await expect(mapViewTab).toHaveAttribute('data-test', 'tab tab-selected');
57+
58+
// TeachMap should be visible in the map view
59+
await expect(page.locator('.teach-map .gm-style')).toBeVisible();
60+
61+
// Switch back to the table view
62+
await tableViewTab.click();
63+
64+
// Table view should be active again
65+
await expect(tableViewTab).toHaveAttribute('data-test', 'tab tab-selected');
66+
await expect(mapViewTab).toHaveAttribute('data-test', 'tab');
67+
68+
// CoursesList should be visible again
69+
await expect(page.locator('.ktl-courses-list')).toBeVisible();
70+
});
71+
72+
test('Should display university list in table view', async ({ page }) => {
73+
// Make sure we're in a table view
74+
const tableViewTab = page.getByRole('tab', { name: 'Table view' });
75+
await tableViewTab.click();
76+
77+
// Check if the course list is visible
78+
const coursesList = page.locator('.ktl-courses-list');
79+
await expect(coursesList).toBeVisible();
80+
81+
// Check and verify the headers of the course list
82+
const headers = coursesList.locator('.ktl-courses-list-header .ktl-courses-list-cell');
83+
expect(await headers.count()).toBe(3);
84+
expect(await headers.nth(0).textContent()).toBe('University title');
85+
expect(await headers.nth(1).textContent()).toBe('Location');
86+
expect(await headers.nth(2).textContent()).toBe('Teaching Kotlin');
87+
88+
// Check if there are universities in the list
89+
const universities = coursesList.locator('.ktl-courses-list__item');
90+
expect(await universities.count()).toBeGreaterThan(0);
91+
expect(await universities.first().locator('.ktl-courses-list-cell').count())
92+
.toBe(3);
93+
});
94+
95+
test('Should display map with markers in map view', async ({ page }) => {
96+
// Switch to the map view
97+
const mapViewTab = page.getByRole('tab', { name: 'Map view' });
98+
await mapViewTab.click();
99+
100+
// Check if the map is visible
101+
const map = page.locator('.teach-map');
102+
await checkTeachMap(page, map);
103+
});
104+
105+
test('Should have action buttons for educators', checkTeachCta);
106+
});

0 commit comments

Comments
 (0)