|
| 1 | +import { browser, expect } from '@wdio/globals' |
| 2 | +import { createWorkspaceExpected } from 'helpers/constants.ts' |
| 3 | + |
| 4 | +import { |
| 5 | + STATUS, |
| 6 | + clearAllTestResults, |
| 7 | + collapseAllTests, |
| 8 | + clickTitleActionButton, |
| 9 | + clickTreeItemButton, |
| 10 | + getTestingSection, |
| 11 | + openTestingView, |
| 12 | + waitForResolved, |
| 13 | + waitForTestStatus, |
| 14 | +} from '../helpers/index.ts' |
| 15 | +import type { SideBarView, ViewControl, Workbench } from 'wdio-vscode-service' |
| 16 | + |
| 17 | +const expected = createWorkspaceExpected() |
| 18 | + |
| 19 | +describe('VS Code Extension Testing with Workspace', function () { |
| 20 | + this.retries(3) |
| 21 | + let workbench: Workbench |
| 22 | + let testingViewControl: ViewControl |
| 23 | + let sideBarView: SideBarView<any> |
| 24 | + |
| 25 | + beforeEach(async function () { |
| 26 | + workbench = await browser.getWorkbench() |
| 27 | + testingViewControl = await openTestingView(workbench) |
| 28 | + sideBarView = workbench.getSideBar() |
| 29 | + |
| 30 | + const testingSection = await getTestingSection(sideBarView.getContent()) |
| 31 | + await collapseAllTests(testingSection) |
| 32 | + await browser.waitUntil(async () => (await testingSection.getVisibleItems()).length === 3) |
| 33 | + }) |
| 34 | + |
| 35 | + afterEach(async function () { |
| 36 | + await clearAllTestResults(workbench) |
| 37 | + }) |
| 38 | + |
| 39 | + it('should be displayed the testing screen at the sideBar', async function () { |
| 40 | + expect(await testingViewControl.getTitle()).toBe('Testing') |
| 41 | + expect(await sideBarView.getTitlePart().getTitle()).toBe('TESTING') |
| 42 | + }) |
| 43 | + |
| 44 | + it('should resolve defined tests correctly', async function () { |
| 45 | + const testingSection = await getTestingSection(sideBarView.getContent()) |
| 46 | + const items = await testingSection.getVisibleItems() |
| 47 | + |
| 48 | + await waitForResolved(browser, items[0]) |
| 49 | + |
| 50 | + expect(items.length).toBe(expected.notRun.length) |
| 51 | + |
| 52 | + /** |
| 53 | + * Because of the small screen size of the CI environment, |
| 54 | + * the tree is expanded and asserted per workspace. |
| 55 | + */ |
| 56 | + for (let index = 0; index < expected.notRun.length; index++) { |
| 57 | + await expect([items[index]]).toMatchTreeStructure([expected.notRun[index]]) |
| 58 | + |
| 59 | + await collapseAllTests(testingSection) |
| 60 | + } |
| 61 | + }) |
| 62 | + |
| 63 | + it('should run at top Level', async function () { |
| 64 | + const testingSection = await getTestingSection(sideBarView.getContent()) |
| 65 | + const items = await testingSection.getVisibleItems() |
| 66 | + |
| 67 | + await waitForResolved(browser, items[0]) |
| 68 | + |
| 69 | + await clickTitleActionButton(sideBarView.getTitlePart(), 'Run Tests') |
| 70 | + |
| 71 | + expect(items.length).toBe(expected.runAll.length) |
| 72 | + |
| 73 | + await waitForTestStatus(browser, items[0], STATUS.PASSED) |
| 74 | + await waitForTestStatus(browser, items[1], STATUS.FAILED) |
| 75 | + await waitForTestStatus(browser, items[2], STATUS.FAILED) |
| 76 | + |
| 77 | + /** |
| 78 | + * Because of the small screen size of the CI environment, |
| 79 | + * the tree is expanded and asserted per workspace. |
| 80 | + */ |
| 81 | + for (let index = 0; index < expected.runAll.length; index++) { |
| 82 | + await expect([items[index]]).toMatchTreeStructure([expected.runAll[index]]) |
| 83 | + |
| 84 | + await collapseAllTests(testingSection) |
| 85 | + } |
| 86 | + }) |
| 87 | + |
| 88 | + it('should run at not top Level', async function () { |
| 89 | + const testingSection = await getTestingSection(sideBarView.getContent()) |
| 90 | + const items = await testingSection.getVisibleItems() |
| 91 | + |
| 92 | + await waitForResolved(browser, items[0]) |
| 93 | + await waitForResolved(browser, items[0]) |
| 94 | + |
| 95 | + const target = await items[1] |
| 96 | + .getChildren() |
| 97 | + .then((items) => items[0].getChildren()) |
| 98 | + .then((items) => items[0].getChildren()) |
| 99 | + .then((items) => items[0].getChildren()) |
| 100 | + .then((items) => items[1]) |
| 101 | + |
| 102 | + await clickTreeItemButton(browser, target, 'Run Test') |
| 103 | + |
| 104 | + expect(items.length).toBe(expected.runPartially.length) |
| 105 | + await waitForTestStatus(browser, items[1], STATUS.PASSED) |
| 106 | + |
| 107 | + /** |
| 108 | + * Because of the small screen size of the CI environment, |
| 109 | + * the tree is expanded and asserted per workspace. |
| 110 | + */ |
| 111 | + for (let index = 0; index < expected.runPartially.length; index++) { |
| 112 | + await expect([items[index]]).toMatchTreeStructure([expected.runPartially[index]]) |
| 113 | + |
| 114 | + await collapseAllTests(testingSection) |
| 115 | + } |
| 116 | + }) |
| 117 | +}) |
0 commit comments