|
| 1 | +import { browser, expect } from '@wdio/globals' |
| 2 | + |
| 3 | +import { createCucumberExpected } from '../helpers/cucumber.ts' |
| 4 | +import { |
| 5 | + STATUS, |
| 6 | + clearAllTestResults, |
| 7 | + clickTitleActionButton, |
| 8 | + collapseAllTests, |
| 9 | + getTestingSection, |
| 10 | + openTestingView, |
| 11 | + waitForResolved, |
| 12 | + waitForTestStatus, |
| 13 | +} from '../helpers/index.ts' |
| 14 | + |
| 15 | +import type { SideBarView, ViewControl, Workbench } from 'wdio-vscode-service' |
| 16 | + |
| 17 | +const targetFramework = process.env.VSCODE_WDIO_E2E_SCENARIO || 'mocha' |
| 18 | + |
| 19 | +const expected = createCucumberExpected() |
| 20 | + |
| 21 | +describe(`VS Code Extension Testing with ${targetFramework}`, function () { |
| 22 | + this.retries(3) |
| 23 | + let workbench: Workbench |
| 24 | + let testingViewControl: ViewControl |
| 25 | + let sideBarView: SideBarView<any> |
| 26 | + |
| 27 | + beforeEach(async function () { |
| 28 | + workbench = await browser.getWorkbench() |
| 29 | + testingViewControl = await openTestingView(workbench) |
| 30 | + sideBarView = workbench.getSideBar() |
| 31 | + |
| 32 | + const testingSection = await getTestingSection(sideBarView.getContent()) |
| 33 | + await collapseAllTests(testingSection) |
| 34 | + |
| 35 | + await browser.waitUntil(async () => (await testingSection.getVisibleItems()).length === 1) |
| 36 | + }) |
| 37 | + |
| 38 | + afterEach(async function () { |
| 39 | + await clearAllTestResults(workbench) |
| 40 | + }) |
| 41 | + |
| 42 | + it('should be displayed the testing screen at the sideBar', async function () { |
| 43 | + expect(await testingViewControl.getTitle()).toBe('Testing') |
| 44 | + expect(await sideBarView.getTitlePart().getTitle()).toBe('TESTING') |
| 45 | + }) |
| 46 | + |
| 47 | + it('should resolve defined tests correctly', async function () { |
| 48 | + const testingSection = await getTestingSection(sideBarView.getContent()) |
| 49 | + const items = await testingSection.getVisibleItems() |
| 50 | + |
| 51 | + await waitForResolved(browser, items[0]) |
| 52 | + |
| 53 | + await expect(items).toMatchTreeStructure(expected.notRun) |
| 54 | + }) |
| 55 | + |
| 56 | + it('should shutdown the work process after idle timeout was reached', async function () { |
| 57 | + await new Promise((resolve) => setTimeout(resolve, 2000)) |
| 58 | + |
| 59 | + await expect(workbench).hasExpectedLog(/Worker#0 process shutdown gracefully/) |
| 60 | + |
| 61 | + const bottomBar = workbench.getBottomBar() |
| 62 | + const outputView = await bottomBar.openOutputView() |
| 63 | + await outputView.selectChannel('WebdriverIO') |
| 64 | + await outputView.clearText() |
| 65 | + }) |
| 66 | + |
| 67 | + it('should start work process and run test successfully', async function () { |
| 68 | + const testingSection = await getTestingSection(sideBarView.getContent()) |
| 69 | + const items = await testingSection.getVisibleItems() |
| 70 | + |
| 71 | + await waitForResolved(browser, items[0]) |
| 72 | + |
| 73 | + await clickTitleActionButton(sideBarView.getTitlePart(), 'Run Tests') |
| 74 | + |
| 75 | + await waitForTestStatus(browser, items[0], STATUS.PASSED) |
| 76 | + |
| 77 | + // assert that start work process |
| 78 | + await expect(workbench).hasExpectedLog(/\[#1\] Worker process started successfully/) |
| 79 | + |
| 80 | + // assert that run test successfully |
| 81 | + await expect(items).toMatchTreeStructure(expected.runAll) |
| 82 | + }) |
| 83 | +}) |
0 commit comments