|
| 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 | +}); |
0 commit comments