Skip to content

Commit 58530d5

Browse files
committed
test: add base test for min-compiler-version at least.
1 parent 3a9781d commit 58530d5

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

tests/min-version.test.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { expect, test } from '@playwright/test';
2+
import { gotoHtmlWidget } from './utlis/server/playground';
3+
import { prepareNetwork, printlnCode } from './utlis';
4+
import { mockRunRequest, waitRunRequest } from './utlis/mocks/compiler';
5+
import { runButton } from './utlis/interactions';
6+
import {
7+
LOADER_SELECTOR,
8+
RESULT_SELECTOR,
9+
VERSION_SELECTOR,
10+
WIDGET_SELECTOR,
11+
} from './utlis/selectors';
12+
13+
test.describe('Minimum compiler version', () => {
14+
test.beforeEach(async ({ page, baseURL }) => {
15+
await prepareNetwork(page, baseURL); // offline mode
16+
});
17+
18+
test('with future release', async ({ page }) => {
19+
await gotoHtmlWidget(
20+
page,
21+
{ selector: 'code' },
22+
/* language=html */ `
23+
<code data-min-compiler-version='2.0.0'>${printlnCode(
24+
'Hello, world!',
25+
)}</code>
26+
`,
27+
);
28+
29+
const editor = page.locator(WIDGET_SELECTOR);
30+
await expect(editor).toHaveCount(1); // playground loaded
31+
await expect(page.locator('code')).not.toBeVisible(); // original node hided
32+
await expect(editor.locator(VERSION_SELECTOR)).toHaveText(
33+
'Running on v.2.0.0-alpha.3', // latest version marker
34+
);
35+
36+
const resolveRun = await mockRunRequest(page);
37+
38+
const [request] = await Promise.all([
39+
waitRunRequest(page),
40+
runButton(editor),
41+
]);
42+
43+
expect(request.url()).toContain('2.0.0-alpha.3');
44+
45+
await expect(editor.locator(LOADER_SELECTOR)).toBeVisible();
46+
47+
resolveRun({
48+
json: Object.freeze({
49+
errors: { 'File.kt': [] },
50+
exception: null,
51+
text: '<outStream>run code - done!\n</outStream>',
52+
}),
53+
});
54+
55+
await expect(editor.locator(RESULT_SELECTOR)).toBeVisible();
56+
});
57+
});

tests/utlis/mocks/versions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@
2323
{
2424
"version": "1.8.21",
2525
"latestStable": true
26+
},
27+
{
28+
"version": "2.0.0-alpha.3"
2629
}
2730
]

0 commit comments

Comments
 (0)