Skip to content

Commit 4b9c061

Browse files
committed
ktl-812 chore: test api references footer customization
1 parent a557cf5 commit 4b9c061

File tree

5 files changed

+59
-2
lines changed

5 files changed

+59
-2
lines changed

dokka-templates/base.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</head>
3333
<body>
3434
<@header.display/>
35-
<div id="container">
35+
<div id="container" data-test="content">
3636
<div id="leftColumn">
3737
<div id="sideMenu"></div>
3838
</div>

dokka-templates/includes/footer.ftl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<#macro display>
2-
{% ktl_component "footer" %}
2+
<div data-test="footer">
3+
{% ktl_component "footer" %}
4+
</div>
35
</#macro>

playwright.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const config = {
55
retries: process.env.CI ? 0 : 0,
66
reporter: process.env.CI ? 'dot' : 'list',
77
maxFailures: process.env.CI ? 2 : 0,
8+
snapshotDir: 'test/snapshots',
89
use: {
910
baseURL: process.env.BASE_URL || 'http://localhost:9000',
1011
trace: 'off',

test/page/api-reference-page.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Page } from '@playwright/test';
2+
import { testSelector } from '../utils';
3+
import { BasePage } from './base-page';
4+
5+
export class ApiReferencePage implements BasePage {
6+
readonly page: Page;
7+
readonly url: string;
8+
9+
constructor(page, url) {
10+
this.page = page;
11+
this.url = url;
12+
}
13+
14+
async init() {
15+
await this.page.goto(this.url);
16+
17+
await this.page.waitForSelector(testSelector('content'));
18+
}
19+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { expect, test } from '@playwright/test';
2+
import { ApiReferencePage } from '../page/api-reference-page';
3+
import { testSelector } from '../utils';
4+
5+
const pagesWithCustomizedTemplates = [
6+
{
7+
name: 'kotlinx.coroutines index',
8+
getInstance: (page) => new ApiReferencePage(page, '/api/kotlinx.coroutines/'),
9+
},
10+
{
11+
name: 'kotlinx-coroutines-core module',
12+
getInstance: (page) => new ApiReferencePage(page, '/api/kotlinx.coroutines/kotlinx-coroutines-core/'),
13+
},
14+
{
15+
name: 'kotlinx-serialization index',
16+
getInstance: (page) => new ApiReferencePage(page, '/api/kotlinx.serialization/'),
17+
},
18+
{
19+
name: 'kotlinx-serialization-core module',
20+
getInstance: (page) => new ApiReferencePage(page, '/api/kotlinx.serialization/kotlinx-serialization-core/'),
21+
},
22+
];
23+
24+
test.describe('Check api references template customization', async () => {
25+
for (const pageWithCustomizedTemplate of pagesWithCustomizedTemplates) {
26+
test(`Check footer on the ${pageWithCustomizedTemplate.name} page`, async ({ page }) => {
27+
const currentPage = pageWithCustomizedTemplate.getInstance(page);
28+
await currentPage.init();
29+
30+
expect(await page.locator(testSelector('footer')).screenshot()).toMatchSnapshot(
31+
`${pageWithCustomizedTemplate.name}.footer.png`
32+
);
33+
});
34+
}
35+
});

0 commit comments

Comments
 (0)