@@ -11,18 +11,24 @@ import {
1111 waitForResolved ,
1212 waitForTestStatus ,
1313} from '../helpers/index.js'
14- import { SettingsEditor as ExtendSettingsEditor } from '../pageobjects/SettingsEditor.js'
1514
16- import type { SideBarView , ViewControl , Workbench } from 'wdio-vscode-service'
15+ import type { SideBarView , TextEditor , Workbench } from 'wdio-vscode-service'
1716
1817describe ( 'VS Code Extension Testing (Update config)' , function ( ) {
1918 let workbench : Workbench
2019 let sideBarView : SideBarView < any >
21- let testingVew : ViewControl
20+ let orgSettings : string
21+
22+ before ( async function ( ) {
23+ workbench = await browser . getWorkbench ( )
24+ const tab = await getSettingTextEditor ( workbench )
25+ orgSettings = await tab . getText ( )
26+ await workbench . getEditorView ( ) . closeAllEditors ( )
27+ } )
2228
2329 beforeEach ( async function ( ) {
2430 workbench = await browser . getWorkbench ( )
25- testingVew = await openTestingView ( workbench )
31+ await openTestingView ( workbench )
2632 sideBarView = workbench . getSideBar ( )
2733
2834 const testingSection = await getTestingSection ( sideBarView . getContent ( ) )
@@ -35,6 +41,15 @@ describe('VS Code Extension Testing (Update config)', function () {
3541 await clearAllTestResults ( workbench )
3642 } )
3743
44+ after ( async function ( ) {
45+ const tab = await getSettingTextEditor ( workbench )
46+ await tab . clearText ( )
47+ await tab . setText ( JSON . stringify ( JSON . parse ( orgSettings ) , null , 2 ) )
48+ await tab . save ( )
49+
50+ await workbench . getEditorView ( ) . closeAllEditors ( )
51+ } )
52+
3853 it ( 'should be resolved the defined tests after settings changed' , async function ( ) {
3954 const testingSection = await getTestingSection ( sideBarView . getContent ( ) )
4055 const items = await testingSection . getVisibleItems ( )
@@ -73,17 +88,16 @@ describe('VS Code Extension Testing (Update config)', function () {
7388 ] )
7489
7590 // Emulate the changing configuration
76- await workbench . openSettings ( )
77-
78- await testingVew . closeView ( )
79- await sleep ( 1500 )
91+ const settings = JSON . parse ( orgSettings )
92+ settings [ 'webdriverio.configFilePattern' ] = [ '**/webdriverio.conf.ts' ]
8093
81- const settingEditor = new ExtendSettingsEditor ( workbench )
82- const listSetting = await settingEditor . findListSetting ( 'Config File Pattern' , 'Webdriverio' )
83- await listSetting . editValue ( 0 , '**/webdriverio.conf.ts' )
94+ const tab = await getSettingTextEditor ( workbench )
95+ await tab . clearText ( )
96+ await tab . setText ( JSON . stringify ( settings , null , 2 ) )
97+ await tab . save ( )
8498
8599 await workbench . getEditorView ( ) . closeAllEditors ( )
86- await testingVew . openView ( )
100+ await sleep ( 1500 )
87101
88102 await waitForResolved ( browser , items [ 0 ] )
89103
@@ -139,3 +153,10 @@ describe('VS Code Extension Testing (Update config)', function () {
139153 ] )
140154 } )
141155} )
156+
157+ async function getSettingTextEditor ( workbench : Workbench ) {
158+ await workbench . executeCommand ( 'Preferences: Open User Settings (JSON)' )
159+ await sleep ( 1500 )
160+ const editorView = workbench . getEditorView ( )
161+ return ( await editorView . openEditor ( 'settings.json' ) ) as TextEditor
162+ }
0 commit comments