Skip to content

[Meta: Move pages to NextJS] add E2E /educational/ test #4943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ generated

/reports*
/data/page_views_map.json
test-results
23 changes: 0 additions & 23 deletions playwright.config.js

This file was deleted.

24 changes: 24 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineConfig, devices } from '@playwright/test';

const MAX_DIFF_PIXEL_RATIO = 0.025 as const;

export default defineConfig({
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
reporter: process.env.CI ? 'dot' : 'list',
snapshotDir: 'test/snapshots',
expect: {
toMatchSnapshot: { maxDiffPixelRatio: MAX_DIFF_PIXEL_RATIO },
toHaveScreenshot: { maxDiffPixelRatio: MAX_DIFF_PIXEL_RATIO }
},
use: {
baseURL: process.env.BASE_URL || 'http://localhost:9000',
trace: 'off'
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] }
}
]
});
2 changes: 1 addition & 1 deletion static/js/ktl-component/courses/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {TeachMap} from '../teach/components/teach-map/teach-map.jsx';
const Courses = ({universities, path}) => {
const [activeIndex, setActiveIndex] = useState(0);
return (
<div>
<div data-test="teach-courses">
<TeachTopMenu path={path} />

<section className="ktl-layout ktl-layout--center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const TeachMap = ({className}) => {
const items = data.map(university => {
return {
...university,
id: `${university.title}-${university.location}`
id: `${university.title}-${university.location}-${university.geo.lat}-${university.geo.lng}`
}
});
setUniversities(items)
Expand Down
6 changes: 3 additions & 3 deletions static/js/ktl-component/teach/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import './style.scss';
import {SubscriptionForm} from './components/subscription-form';
import {TeachMap} from './components/teach-map/teach-map.jsx';
import {SlackIcon} from "@rescui/icons";
import Button from "@rescui/button";
import { Button } from "@rescui/button";
import { TeachLaunchCourse } from "./components/teach-launch-course";

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

<Button mode="outline" href="why-teach-kotlin.html" className="teach-cta-block-button">
Expand Down Expand Up @@ -121,7 +121,7 @@ const Teach = (props) => {
rel="noopener"
className="teach-cta-block-button"
>
Join Educators Сommunity
Join Educators Community
</Button>

<Button size="l" mode="outline" href="why-teach-kotlin.html" className="teach-cta-block-button">
Expand Down
2 changes: 1 addition & 1 deletion static/js/ktl-component/why-teach/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import quotes from './quotes.json';
export const WhyTeach = ({path}) => {

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

<div className="ktl-layout ktl-layout--center">
Expand Down
10 changes: 5 additions & 5 deletions test/e2e/api-references-template-customization.spec.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { expect, test } from '@playwright/test';
import { expect, Page, test } from '@playwright/test';
import { ApiReferencePage } from '../page/api-reference-page';

const pagesWithCustomizedTemplates = [
{
name: 'kotlinx.coroutines index',
getInstance: (page) => new ApiReferencePage(page, '/api/kotlinx.coroutines/'),
getInstance: (page: Page) => new ApiReferencePage(page, '/api/kotlinx.coroutines/'),
},
{
name: 'kotlinx-coroutines-core module',
getInstance: (page) => new ApiReferencePage(page, '/api/kotlinx.coroutines/kotlinx-coroutines-core/'),
getInstance: (page: Page) => new ApiReferencePage(page, '/api/kotlinx.coroutines/kotlinx-coroutines-core/'),
},
{
name: 'kotlinx-serialization index',
getInstance: (page) => new ApiReferencePage(page, '/api/kotlinx.serialization/'),
getInstance: (page: Page) => new ApiReferencePage(page, '/api/kotlinx.serialization/'),
},
{
name: 'kotlinx-serialization-core module',
getInstance: (page) => new ApiReferencePage(page, '/api/kotlinx.serialization/kotlinx-serialization-core/'),
getInstance: (page: Page) => new ApiReferencePage(page, '/api/kotlinx.serialization/kotlinx-serialization-core/'),
},
];

Expand Down
106 changes: 106 additions & 0 deletions test/e2e/teach/courses.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { expect, test } from '@playwright/test';
import { CoursesPage } from '../../page/teach/courses-page';
import { closeExternalBanners } from '../utils';
import { testSelector } from '../../utils';
import { checkTeachCta, checkTeachMap, checkTeachNav } from './utils';

test.describe('Courses page appearance and functionality', async () => {
test.beforeEach(async ({ page, context, baseURL }) => {
const coursesPage = new CoursesPage(page);
await coursesPage.init();
await closeExternalBanners(context, page, baseURL);
});

test('Should load the courses page correctly', async ({ page }) => {
// Check if the page title is correct
expect(await page.title()).toBe('List of Courses');

// Check if the main content is visible
const mainContent = page.locator(testSelector('teach-courses'));
await expect(mainContent).toBeVisible();

// Check if the page heading is correct
const title = mainContent.locator('h1');
await expect(title).toBeVisible();

expect(await title.textContent()).toBe('Universities That Teach Kotlin');
});

test('Should have working navigation buttons', async ({ page }) => {
await checkTeachNav(page, 'List of Courses');
});

test('Should have working tab navigation', async ({ page }) => {
// Check if the tab list is visible
const tabList = page.locator(testSelector('tab-list'));
await expect(tabList).toBeVisible();

// Check if both tabs are present
const tableViewTab = tabList.getByRole('tab', { name: 'Table view', exact: true });
await expect(tableViewTab).toBeVisible();

const mapViewTab = tabList.getByRole('tab', { name: 'Map view', exact: true });
await expect(mapViewTab).toBeVisible();

await expect(tableViewTab).toHaveAttribute('data-test', 'tab tab-selected');
await expect(mapViewTab).toHaveAttribute('data-test', 'tab');

// CoursesList should be visible in the table view
await expect(page.locator('.ktl-courses-list')).toBeVisible();

// Switch to the map view
await mapViewTab.click();

// Map view should now be active
await expect(tableViewTab).toHaveAttribute('data-test', 'tab');
await expect(mapViewTab).toHaveAttribute('data-test', 'tab tab-selected');

// TeachMap should be visible in the map view
await expect(page.locator('.teach-map .gm-style')).toBeVisible();

// Switch back to the table view
await tableViewTab.click();

// Table view should be active again
await expect(tableViewTab).toHaveAttribute('data-test', 'tab tab-selected');
await expect(mapViewTab).toHaveAttribute('data-test', 'tab');

// CoursesList should be visible again
await expect(page.locator('.ktl-courses-list')).toBeVisible();
});

test('Should display university list in table view', async ({ page }) => {
// Make sure we're in a table view
const tableViewTab = page.getByRole('tab', { name: 'Table view' });
await tableViewTab.click();

// Check if the course list is visible
const coursesList = page.locator('.ktl-courses-list');
await expect(coursesList).toBeVisible();

// Check and verify the headers of the course list
const headers = coursesList.locator('.ktl-courses-list-header .ktl-courses-list-cell');
expect(await headers.count()).toBe(3);
expect(await headers.nth(0).textContent()).toBe('University title');
expect(await headers.nth(1).textContent()).toBe('Location');
expect(await headers.nth(2).textContent()).toBe('Teaching Kotlin');

// Check if there are universities in the list
const universities = coursesList.locator('.ktl-courses-list__item');
expect(await universities.count()).toBeGreaterThan(0);
expect(await universities.first().locator('.ktl-courses-list-cell').count())
.toBe(3);
});

test('Should display map with markers in map view', async ({ page }) => {
// Switch to the map view
const mapViewTab = page.getByRole('tab', { name: 'Map view' });
await mapViewTab.click();

// Check if the map is visible
const map = page.locator('.teach-map');
await checkTeachMap(page, map);
});

test('Should have action buttons for educators', checkTeachCta);
});
Loading