Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/assertions/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { MatcherContext } from 'expect'
import type { BottomBarPanel, TreeItem, Workbench } from 'wdio-vscode-service'
import type { STATUS } from '../helpers/index.ts'
import type { STATUS } from '../helpers/index.js'

export interface ExpectedTreeItem {
text: string
Expand Down
10 changes: 8 additions & 2 deletions e2e/helpers/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import * as cucumber from './cucumber.ts'
import { STATUS } from './index.ts'
import * as cucumber from './cucumber.js'

export const STATUS = {
NOT_YET_RUN: 'Not yet run',
PASSED: 'Passed',
FAILED: 'Failed',
SKIPPED: 'Skipped',
} as const

function createExpectedNotRun(targetFramework: 'mocha' | 'jasmine') {
return {
Expand Down
2 changes: 1 addition & 1 deletion e2e/helpers/cucumber.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STATUS } from './index.ts'
import { STATUS } from './constants.js'

export function createExpectedNotRun() {
return {
Expand Down
7 changes: 1 addition & 6 deletions e2e/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import { DefaultTreeSection } from 'wdio-vscode-service'
import type { StatusStrings } from 'assertions/index.ts'
import type { TreeItem, Workbench, ViewControl, ViewContent, ViewItemAction, ViewTitlePart } from 'wdio-vscode-service'

export const STATUS = {
NOT_YET_RUN: 'Not yet run',
PASSED: 'Passed',
FAILED: 'Failed',
SKIPPED: 'Skipped',
} as const
export { STATUS } from './constants.js'

export async function openTestingView(workbench: Workbench) {
const activityBar = workbench.getActivityBar()
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/basic.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { browser, expect } from '@wdio/globals'
import { createExpected } from 'helpers/constants.ts'
import { createExpected } from 'helpers/constants.js'

import {
STATUS,
Expand All @@ -11,7 +11,7 @@ import {
openTestingView,
waitForResolved,
waitForTestStatus,
} from '../helpers/index.ts'
} from '../helpers/index.js'

import type { SideBarView, ViewControl, Workbench } from 'wdio-vscode-service'

Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/basicCucumber.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { browser, expect } from '@wdio/globals'

import { createCucumberExpected } from '../helpers/cucumber.ts'
import { createCucumberExpected } from '../helpers/cucumber.js'
import {
STATUS,
clearAllTestResults,
Expand All @@ -11,7 +11,7 @@ import {
openTestingView,
waitForResolved,
waitForTestStatus,
} from '../helpers/index.ts'
} from '../helpers/index.js'

import type { SideBarView, ViewControl, Workbench } from 'wdio-vscode-service'

Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/basicWorkspace.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { browser, expect } from '@wdio/globals'
import { createWorkspaceExpected } from 'helpers/constants.ts'
import { createWorkspaceExpected } from 'helpers/constants.js'

import {
STATUS,
Expand All @@ -11,7 +11,7 @@ import {
openTestingView,
waitForResolved,
waitForTestStatus,
} from '../helpers/index.ts'
} from '../helpers/index.js'
import type { SideBarView, ViewControl, Workbench } from 'wdio-vscode-service'

const expected = createWorkspaceExpected()
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/envEnable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
openTestingView,
waitForResolved,
waitForTestStatus,
} from '../helpers/index.ts'
} from '../helpers/index.js'

import type { SideBarView, Workbench } from 'wdio-vscode-service'

Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/updateConfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
openTestingView,
waitForResolved,
waitForTestStatus,
} from '../helpers/index.ts'
} from '../helpers/index.js'

import type { SideBarView, Workbench } from 'wdio-vscode-service'

Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/updateErrorConfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
openTestingView,
waitForResolved,
waitForTestStatus,
} from '../helpers/index.ts'
} from '../helpers/index.js'

import type { SideBarView, Workbench } from 'wdio-vscode-service'

Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/updateErrorSpec.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
openTestingView,
waitForResolved,
waitForTestStatus,
} from '../helpers/index.ts'
} from '../helpers/index.js'

import type { SideBarView, Workbench } from 'wdio-vscode-service'

Expand Down
162 changes: 162 additions & 0 deletions e2e/tests/updateSettings.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import { browser, expect } from '@wdio/globals'
import { sleep } from 'wdio-vscode-service'

import {
STATUS,
clearAllTestResults,
clickTreeItemButton,
collapseAllTests,
getTestingSection,
openTestingView,
waitForResolved,
waitForTestStatus,
} from '../helpers/index.js'

import type { SideBarView, TextEditor, Workbench } from 'wdio-vscode-service'

describe('VS Code Extension Testing (Update config)', function () {
let workbench: Workbench
let sideBarView: SideBarView<any>
let orgSettings: string

before(async function () {
workbench = await browser.getWorkbench()
const tab = await getSettingTextEditor(workbench)
orgSettings = await tab.getText()
await workbench.getEditorView().closeAllEditors()
})

beforeEach(async function () {
workbench = await browser.getWorkbench()
await openTestingView(workbench)
sideBarView = workbench.getSideBar()

const testingSection = await getTestingSection(sideBarView.getContent())
await collapseAllTests(testingSection)

await browser.waitUntil(async () => (await testingSection.getVisibleItems()).length === 1)
})

afterEach(async function () {
await clearAllTestResults(workbench)
})

after(async function () {
const tab = await getSettingTextEditor(workbench)
await tab.clearText()
await tab.setText(JSON.stringify(JSON.parse(orgSettings), null, 2))
await tab.save()

await workbench.getEditorView().closeAllEditors()
})

it('should be resolved the defined tests after settings changed', async function () {
const testingSection = await getTestingSection(sideBarView.getContent())
const items = await testingSection.getVisibleItems()

await waitForResolved(browser, items[0])

await expect(items).toMatchTreeStructure([
{
text: 'wdio.conf.ts',
status: STATUS.NOT_YET_RUN,
children: [
{
text: 'before.spec.ts',
status: STATUS.NOT_YET_RUN,
children: [
{
text: 'Before Tests',
status: STATUS.NOT_YET_RUN,
children: [{ text: 'TEST BEFORE 1', status: STATUS.NOT_YET_RUN }],
},
],
},
{
text: 'sample.spec.ts',
status: STATUS.NOT_YET_RUN,
children: [
{
text: 'Sample 1',
status: STATUS.NOT_YET_RUN,
children: [{ text: 'TEST SAMPLE 1', status: STATUS.NOT_YET_RUN }],
},
],
},
],
},
])

// Emulate the changing configuration
const settings = JSON.parse(orgSettings)
settings['webdriverio.configFilePattern'] = ['**/webdriverio.conf.ts']

const tab = await getSettingTextEditor(workbench)
await tab.clearText()
await tab.setText(JSON.stringify(settings, null, 2))
await tab.save()

await workbench.getEditorView().closeAllEditors()
await sleep(1500)

await waitForResolved(browser, items[0])

await expect(items).toMatchTreeStructure([
{
text: 'webdriverio.conf.ts',
status: STATUS.NOT_YET_RUN,
children: [
{
text: 'after.test.ts',
status: STATUS.NOT_YET_RUN,
children: [
{
text: 'After Tests',
status: STATUS.NOT_YET_RUN,
children: [{ text: 'TEST AFTER 1', status: STATUS.NOT_YET_RUN }],
},
],
},
],
},
])
})

it('should run tests successfully after changing the settings', async function () {
const testingSection = await getTestingSection(sideBarView.getContent())
const items = await testingSection.getVisibleItems()

await waitForResolved(browser, items[0])

await clickTreeItemButton(browser, items[0], 'Run Test')

await waitForTestStatus(browser, items[0], STATUS.PASSED)

await expect(items).toMatchTreeStructure([
{
text: 'webdriverio.conf.ts',
status: STATUS.PASSED,
children: [
{
text: 'after.test.ts',
status: STATUS.PASSED,
children: [
{
text: 'After Tests',
status: STATUS.PASSED,
children: [{ text: 'TEST AFTER 1', status: STATUS.PASSED }],
},
],
},
],
},
])
})
})

async function getSettingTextEditor(workbench: Workbench) {
await workbench.executeCommand('Preferences: Open User Settings (JSON)')
await sleep(1500)
const editorView = workbench.getEditorView()
return (await editorView.openEditor('settings.json')) as TextEditor
}
2 changes: 1 addition & 1 deletion e2e/tests/updateSpec.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
openTestingView,
waitForResolved,
waitForTestStatus,
} from '../helpers/index.ts'
} from '../helpers/index.js'

import type { SideBarView, Workbench } from 'wdio-vscode-service'

Expand Down
8 changes: 4 additions & 4 deletions e2e/tests/workerIdleTimeout.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { browser, expect } from '@wdio/globals'

import { createCucumberExpected } from '../helpers/cucumber.ts'
import { createCucumberExpected } from '../helpers/cucumber.js'
import {
STATUS,
clearAllTestResults,
Expand All @@ -10,7 +10,7 @@ import {
openTestingView,
waitForResolved,
waitForTestStatus,
} from '../helpers/index.ts'
} from '../helpers/index.js'

import type { SideBarView, ViewControl, Workbench } from 'wdio-vscode-service'

Expand Down Expand Up @@ -56,7 +56,7 @@ describe(`VS Code Extension Testing with ${targetFramework}`, function () {
it('should shutdown the work process after idle timeout was reached', async function () {
await new Promise((resolve) => setTimeout(resolve, 2000))

await expect(workbench).hasExpectedLog(/Worker#0 process shutdown gracefully/)
await expect(workbench).hasExpectedLog(/Worker#1 process shutdown gracefully/)

const bottomBar = workbench.getBottomBar()
const outputView = await bottomBar.openOutputView()
Expand All @@ -75,7 +75,7 @@ describe(`VS Code Extension Testing with ${targetFramework}`, function () {
await waitForTestStatus(browser, items[0], STATUS.PASSED)

// assert that start work process
await expect(workbench).hasExpectedLog(/\[#1\] Worker process started successfully/)
await expect(workbench).hasExpectedLog(/\[#2\] Worker process started successfully/)

// assert that run test successfully
await expect(items).toMatchTreeStructure(expected.runAll)
Expand Down
2 changes: 1 addition & 1 deletion e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"types": ["node", "@wdio/globals/types", "@wdio/mocha-framework", "wdio-vscode-service"],
"skipLibCheck": true,
"noEmit": true,
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"experimentalDecorators": true,
"noFallthroughCasesInSwitch": true
}
}
3 changes: 2 additions & 1 deletion e2e/wdioSmoke.conf.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createBaseConfig } from './wdio.conf.ts'
import { createBaseConfig } from './wdio.conf.js'

type TestTargets = 'config' | 'timeout' | 'env'

Expand All @@ -13,6 +13,7 @@ function defineSmokePrams(target: TestTargets) {
'./tests/updateSpec.spec.ts',
'./tests/updateErrorSpec.spec.ts',
'./tests/updateErrorConfig.spec.ts',
'./tests/updateSettings.spec.ts',
],
workspace: '../samples/smoke/update-config',
settings: {},
Expand Down
9 changes: 9 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,13 @@ export default wdioEslint.config([
files: ['e2e/**/*.spec.ts'],
...mochaPlugin.configs.recommended,
},
{
/**
* for extension of wdio-vscode-service
*/
files: ['e2e/pageobjects/**/*.ts'],
rules: {
'@typescript-eslint/no-unsafe-declaration-merging': 'off',
},
},
])
Loading