|
| 1 | +import { browser, expect } from '@wdio/globals' |
| 2 | + |
| 3 | +import { |
| 4 | + STATUS, |
| 5 | + clearAllTestResults, |
| 6 | + clickTreeItemButton, |
| 7 | + collapseAllTests, |
| 8 | + getTestingSection, |
| 9 | + openTestingView, |
| 10 | + waitForResolved, |
| 11 | + waitForTestStatus, |
| 12 | +} from '../helpers/index.js' |
| 13 | +import { SettingsEditor as ExtendSettingsEditor } from '../pageobjects/SettingsEditor.js' |
| 14 | + |
| 15 | +import type { SideBarView, ViewControl, Workbench } from 'wdio-vscode-service' |
| 16 | + |
| 17 | +describe('VS Code Extension Testing (Update config)', function () { |
| 18 | + let workbench: Workbench |
| 19 | + let sideBarView: SideBarView<any> |
| 20 | + let testingVew: ViewControl |
| 21 | + |
| 22 | + beforeEach(async function () { |
| 23 | + workbench = await browser.getWorkbench() |
| 24 | + testingVew = await openTestingView(workbench) |
| 25 | + sideBarView = workbench.getSideBar() |
| 26 | + |
| 27 | + const testingSection = await getTestingSection(sideBarView.getContent()) |
| 28 | + await collapseAllTests(testingSection) |
| 29 | + |
| 30 | + await browser.waitUntil(async () => (await testingSection.getVisibleItems()).length === 1) |
| 31 | + }) |
| 32 | + |
| 33 | + afterEach(async function () { |
| 34 | + await clearAllTestResults(workbench) |
| 35 | + }) |
| 36 | + |
| 37 | + it('should be resolved the defined tests after configuration changed', async function () { |
| 38 | + const testingSection = await getTestingSection(sideBarView.getContent()) |
| 39 | + const items = await testingSection.getVisibleItems() |
| 40 | + |
| 41 | + await waitForResolved(browser, items[0]) |
| 42 | + |
| 43 | + await expect(items).toMatchTreeStructure([ |
| 44 | + { |
| 45 | + text: 'wdio.conf.ts', |
| 46 | + status: STATUS.NOT_YET_RUN, |
| 47 | + children: [ |
| 48 | + { |
| 49 | + text: 'before.spec.ts', |
| 50 | + status: STATUS.NOT_YET_RUN, |
| 51 | + children: [ |
| 52 | + { |
| 53 | + text: 'Before Tests', |
| 54 | + status: STATUS.NOT_YET_RUN, |
| 55 | + children: [{ text: 'TEST BEFORE 1', status: STATUS.NOT_YET_RUN }], |
| 56 | + }, |
| 57 | + ], |
| 58 | + }, |
| 59 | + { |
| 60 | + text: 'sample.spec.ts', |
| 61 | + status: STATUS.NOT_YET_RUN, |
| 62 | + children: [ |
| 63 | + { |
| 64 | + text: 'Sample 1', |
| 65 | + status: STATUS.NOT_YET_RUN, |
| 66 | + children: [{ text: 'TEST SAMPLE 1', status: STATUS.NOT_YET_RUN }], |
| 67 | + }, |
| 68 | + ], |
| 69 | + }, |
| 70 | + ], |
| 71 | + }, |
| 72 | + ]) |
| 73 | + |
| 74 | + // Emulate the changing configuration |
| 75 | + await workbench.openSettings() |
| 76 | + |
| 77 | + await testingVew.closeView() |
| 78 | + const setting2 = new ExtendSettingsEditor(workbench) |
| 79 | + const listSetting = await setting2.findListSetting('Config File Pattern', 'Webdriverio') |
| 80 | + await listSetting.editValue(0, '**/webdriverio.conf.ts') |
| 81 | + |
| 82 | + await workbench.getEditorView().closeAllEditors() |
| 83 | + await testingVew.openView() |
| 84 | + |
| 85 | + await waitForResolved(browser, items[0]) |
| 86 | + |
| 87 | + await expect(items).toMatchTreeStructure([ |
| 88 | + { |
| 89 | + text: 'webdriverio.conf.ts', |
| 90 | + status: STATUS.NOT_YET_RUN, |
| 91 | + children: [ |
| 92 | + { |
| 93 | + text: 'after.test.ts', |
| 94 | + status: STATUS.NOT_YET_RUN, |
| 95 | + children: [ |
| 96 | + { |
| 97 | + text: 'After Tests', |
| 98 | + status: STATUS.NOT_YET_RUN, |
| 99 | + children: [{ text: 'TEST AFTER 1', status: STATUS.NOT_YET_RUN }], |
| 100 | + }, |
| 101 | + ], |
| 102 | + }, |
| 103 | + ], |
| 104 | + }, |
| 105 | + ]) |
| 106 | + }) |
| 107 | + |
| 108 | + it('should run tests successfully after changing the settings', async function () { |
| 109 | + const testingSection = await getTestingSection(sideBarView.getContent()) |
| 110 | + const items = await testingSection.getVisibleItems() |
| 111 | + |
| 112 | + await waitForResolved(browser, items[0]) |
| 113 | + |
| 114 | + await clickTreeItemButton(browser, items[0], 'Run Test') |
| 115 | + |
| 116 | + await waitForTestStatus(browser, items[0], STATUS.PASSED) |
| 117 | + |
| 118 | + await expect(items).toMatchTreeStructure([ |
| 119 | + { |
| 120 | + text: 'webdriverio.conf.ts', |
| 121 | + status: STATUS.PASSED, |
| 122 | + children: [ |
| 123 | + { |
| 124 | + text: 'after.test.ts', |
| 125 | + status: STATUS.PASSED, |
| 126 | + children: [ |
| 127 | + { |
| 128 | + text: 'After Tests', |
| 129 | + status: STATUS.PASSED, |
| 130 | + children: [{ text: 'TEST AFTER 1', status: STATUS.PASSED }], |
| 131 | + }, |
| 132 | + ], |
| 133 | + }, |
| 134 | + ], |
| 135 | + }, |
| 136 | + ]) |
| 137 | + }) |
| 138 | +}) |
0 commit comments