Skip to content

Commit 8014cf2

Browse files
authored
fix: fix a setting error when the test target was not a SPEC file (#50)
## Proposed changes The “Run Tests” button on the top of the side panel does not work properly. ## Types of changes [//]: # 'What types of changes does your code introduce to WebdriverIO?' [//]: # '_Put an `x` in the boxes that apply_' - [ ] Polish (an improvement for an existing feature) - [X] Bugfix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update (improvements to the project's docs) - [ ] Internal updates (everything related to internal scripts, governance documentation and CI files) ## Checklist [//]: # "_Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._" - [X] I have read the [CONTRIBUTING](https://github.com/webdriverio/vscode-webdriverio/blob/main/CONTRIBUTION.md) doc - [X] I have added tests that prove my fix is effective or that my feature works - [ ] I have added the necessary documentation (if appropriate) - [ ] I have added proper type definitions for new commands (if appropriate) ## Further comments [//]: # 'If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...' ### Reviewers: @webdriverio/project-committers
1 parent 64c48ca commit 8014cf2

15 files changed

Lines changed: 383 additions & 331 deletions

File tree

e2e/assertions/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { MatcherContext } from 'expect'
22
import type { TreeItem } from 'wdio-vscode-service'
3-
import type { STATUS } from '../helpers.js'
3+
import type { STATUS } from '../helpers/index.ts'
44

55
export interface ExpectedTreeItem {
66
text: string

e2e/helpers/constants.ts

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { STATUS } from './index.ts'
2+
3+
function createExpectedNotRun(targetFramework: 'mocha' | 'jasmine') {
4+
return {
5+
text: 'wdio.conf.ts',
6+
status: STATUS.NOT_YET_RUN,
7+
children: [
8+
{
9+
text: `${targetFramework}.spec.ts`,
10+
status: STATUS.NOT_YET_RUN,
11+
children: [
12+
{
13+
text: 'Website Tests',
14+
status: STATUS.NOT_YET_RUN,
15+
children: [
16+
{ text: 'should be a pending test', status: STATUS.NOT_YET_RUN },
17+
{ text: 'should have the right title - WebdriverIO', status: STATUS.NOT_YET_RUN },
18+
{
19+
text: 'should have the right title - WebdriverJS Testpage',
20+
status: STATUS.NOT_YET_RUN,
21+
},
22+
{ text: 'should fail', status: STATUS.NOT_YET_RUN },
23+
],
24+
},
25+
],
26+
},
27+
],
28+
}
29+
}
30+
31+
function createExpectedRunAll(targetFramework: 'mocha' | 'jasmine') {
32+
return {
33+
text: 'wdio.conf.ts',
34+
status: STATUS.FAILED,
35+
children: [
36+
{
37+
text: `${targetFramework}.spec.ts`,
38+
status: STATUS.FAILED,
39+
children: [
40+
{
41+
text: 'Website Tests',
42+
status: STATUS.FAILED,
43+
children: [
44+
{ text: 'should be a pending test', status: STATUS.SKIPPED },
45+
{ text: 'should have the right title - WebdriverIO', status: STATUS.PASSED },
46+
{
47+
text: 'should have the right title - WebdriverJS Testpage',
48+
status: STATUS.PASSED,
49+
},
50+
{ text: 'should fail', status: STATUS.FAILED },
51+
],
52+
},
53+
],
54+
},
55+
],
56+
}
57+
}
58+
function createExpectedRunPartially(targetFramework: 'mocha' | 'jasmine') {
59+
return {
60+
text: 'wdio.conf.ts',
61+
status: STATUS.PASSED,
62+
children: [
63+
{
64+
text: `${targetFramework}.spec.ts`,
65+
status: STATUS.PASSED,
66+
children: [
67+
{
68+
text: 'Website Tests',
69+
status: STATUS.PASSED,
70+
children: [
71+
{ text: 'should be a pending test', status: STATUS.NOT_YET_RUN },
72+
{ text: 'should have the right title - WebdriverIO', status: STATUS.PASSED },
73+
{
74+
text: 'should have the right title - WebdriverJS Testpage',
75+
status: STATUS.NOT_YET_RUN,
76+
},
77+
{ text: 'should fail', status: STATUS.NOT_YET_RUN },
78+
],
79+
},
80+
],
81+
},
82+
],
83+
}
84+
}
85+
86+
export function createExpected(targetFramework: 'mocha' | 'jasmine') {
87+
return {
88+
notRun: [createExpectedNotRun(targetFramework)],
89+
runAll: [createExpectedRunAll(targetFramework)],
90+
runPartially: [createExpectedRunPartially(targetFramework)],
91+
}
92+
}

e2e/helpers/cucumber.ts

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
import { STATUS } from './index.ts'
2+
3+
export function createExpectedNotRun() {
4+
return {
5+
text: 'wdio.conf.ts',
6+
status: STATUS.NOT_YET_RUN,
7+
children: [
8+
{
9+
text: 'my-feature.feature',
10+
status: STATUS.NOT_YET_RUN,
11+
children: [
12+
{
13+
text: 'Example feature',
14+
status: STATUS.NOT_YET_RUN,
15+
children: [
16+
{
17+
text: 'Get title of website',
18+
status: STATUS.NOT_YET_RUN,
19+
children: [
20+
{
21+
text: 'Given I go on the website "https://webdriver.io"',
22+
status: STATUS.NOT_YET_RUN,
23+
},
24+
{
25+
text: 'Then should the title of the page be "WebdriverIO · Next-gen browser and mobile automation test framework for Node.js | WebdriverIO"',
26+
status: STATUS.NOT_YET_RUN,
27+
},
28+
],
29+
},
30+
{
31+
text: 'Business rule 1',
32+
status: STATUS.NOT_YET_RUN,
33+
children: [
34+
{
35+
text: 'Get title of website',
36+
status: STATUS.NOT_YET_RUN,
37+
children: [
38+
{
39+
text: 'Given I go on the website "https://github.com/"',
40+
status: STATUS.NOT_YET_RUN,
41+
},
42+
{
43+
text: 'Then should the title of the page be "GitHub · Build and ship software on a single, collaborative platform · GitHub"',
44+
status: STATUS.NOT_YET_RUN,
45+
},
46+
],
47+
},
48+
],
49+
},
50+
{
51+
text: 'Business rule 2',
52+
status: STATUS.NOT_YET_RUN,
53+
children: [
54+
{
55+
text: 'Data Tables',
56+
status: STATUS.NOT_YET_RUN,
57+
children: [
58+
{
59+
text: 'Given I go on the website "http://todomvc.com/examples/react/dist/"',
60+
status: STATUS.NOT_YET_RUN,
61+
},
62+
{
63+
text: 'When I add the following groceries',
64+
status: STATUS.NOT_YET_RUN,
65+
},
66+
{
67+
text: 'Then I should have a list of 4 items',
68+
status: STATUS.NOT_YET_RUN,
69+
},
70+
],
71+
},
72+
],
73+
},
74+
],
75+
},
76+
],
77+
},
78+
],
79+
}
80+
}
81+
82+
export function createExpectedRunPartially() {
83+
return {
84+
text: 'wdio.conf.ts',
85+
status: STATUS.PASSED,
86+
children: [
87+
{
88+
text: 'my-feature.feature',
89+
status: STATUS.PASSED,
90+
children: [
91+
{
92+
text: 'Example feature',
93+
status: STATUS.PASSED,
94+
children: [
95+
{
96+
text: 'Get title of website',
97+
status: STATUS.PASSED,
98+
children: [
99+
{
100+
text: 'Given I go on the website "https://webdriver.io"',
101+
status: STATUS.PASSED,
102+
},
103+
{
104+
text: 'Then should the title of the page be "WebdriverIO · Next-gen browser and mobile automation test framework for Node.js | WebdriverIO"',
105+
status: STATUS.PASSED,
106+
},
107+
],
108+
},
109+
{
110+
text: 'Business rule 1',
111+
status: STATUS.NOT_YET_RUN,
112+
children: [
113+
{
114+
text: 'Get title of website',
115+
status: STATUS.NOT_YET_RUN,
116+
children: [
117+
{
118+
text: 'Given I go on the website "https://github.com/"',
119+
status: STATUS.NOT_YET_RUN,
120+
},
121+
{
122+
text: 'Then should the title of the page be "GitHub · Build and ship software on a single, collaborative platform · GitHub"',
123+
status: STATUS.NOT_YET_RUN,
124+
},
125+
],
126+
},
127+
],
128+
},
129+
{
130+
text: 'Business rule 2',
131+
status: STATUS.NOT_YET_RUN,
132+
children: [
133+
{
134+
text: 'Data Tables',
135+
status: STATUS.NOT_YET_RUN,
136+
children: [
137+
{
138+
text: 'Given I go on the website "http://todomvc.com/examples/react/dist/"',
139+
status: STATUS.NOT_YET_RUN,
140+
},
141+
{
142+
text: 'When I add the following groceries',
143+
status: STATUS.NOT_YET_RUN,
144+
},
145+
{
146+
text: 'Then I should have a list of 4 items',
147+
status: STATUS.NOT_YET_RUN,
148+
},
149+
],
150+
},
151+
],
152+
},
153+
],
154+
},
155+
],
156+
},
157+
],
158+
}
159+
}
160+
export function createExpectedRunAll() {
161+
return {
162+
text: 'wdio.conf.ts',
163+
status: STATUS.PASSED,
164+
children: [
165+
{
166+
text: 'my-feature.feature',
167+
status: STATUS.PASSED,
168+
children: [
169+
{
170+
text: 'Example feature',
171+
status: STATUS.PASSED,
172+
children: [
173+
{
174+
text: 'Get title of website',
175+
status: STATUS.PASSED,
176+
children: [
177+
{
178+
text: 'Given I go on the website "https://webdriver.io"',
179+
status: STATUS.PASSED,
180+
},
181+
{
182+
text: 'Then should the title of the page be "WebdriverIO · Next-gen browser and mobile automation test framework for Node.js | WebdriverIO"',
183+
status: STATUS.PASSED,
184+
},
185+
],
186+
},
187+
{
188+
text: 'Business rule 1',
189+
status: STATUS.PASSED,
190+
children: [
191+
{
192+
text: 'Get title of website',
193+
status: STATUS.PASSED,
194+
children: [
195+
{
196+
text: 'Given I go on the website "https://github.com/"',
197+
status: STATUS.PASSED,
198+
},
199+
{
200+
text: 'Then should the title of the page be "GitHub · Build and ship software on a single, collaborative platform · GitHub"',
201+
status: STATUS.PASSED,
202+
},
203+
],
204+
},
205+
],
206+
},
207+
{
208+
text: 'Business rule 2',
209+
status: STATUS.PASSED,
210+
children: [
211+
{
212+
text: 'Data Tables',
213+
status: STATUS.PASSED,
214+
children: [
215+
{
216+
text: 'Given I go on the website "http://todomvc.com/examples/react/dist/"',
217+
status: STATUS.PASSED,
218+
},
219+
{
220+
text: 'When I add the following groceries',
221+
status: STATUS.PASSED,
222+
},
223+
{
224+
text: 'Then I should have a list of 4 items',
225+
status: STATUS.PASSED,
226+
},
227+
],
228+
},
229+
],
230+
},
231+
],
232+
},
233+
],
234+
},
235+
],
236+
}
237+
}
238+
239+
export function createCucumberExpected() {
240+
return {
241+
notRun: [createExpectedNotRun()],
242+
runAll: [createExpectedRunAll()],
243+
runPartially: [createExpectedRunPartially()],
244+
}
245+
}

e2e/helpers.ts renamed to e2e/helpers/index.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DefaultTreeSection } from 'wdio-vscode-service'
22
import type { StatusStrings } from 'assertions/index.ts'
3-
import type { TreeItem, Workbench, ViewControl, ViewContent, ViewItemAction } from 'wdio-vscode-service'
3+
import type { TreeItem, Workbench, ViewControl, ViewContent, ViewItemAction, ViewTitlePart } from 'wdio-vscode-service'
44

55
export const STATUS = {
66
NOT_YET_RUN: 'Not yet run',
@@ -56,7 +56,6 @@ export async function clickTreeItemButton(browser: WebdriverIO.Browser, target:
5656
}
5757
)
5858

59-
btn = await target.getActionButton(buttonLabel)
6059
await (btn!.elem as WebdriverIO.Element).click()
6160
}
6261

@@ -103,3 +102,16 @@ export async function clearAllTestResults(workbench: Workbench) {
103102
console.log(_error)
104103
}
105104
}
105+
106+
export async function clickTitleActionButton(titlePart: ViewTitlePart, label: string) {
107+
const elements = (await titlePart.elem.$$(
108+
(titlePart.locatorMap.ViewSection.actionConstructor as Function)()
109+
)) as WebdriverIO.Element[]
110+
111+
for (const element of elements) {
112+
if ((await element.getAttribute('aria-label')) === label) {
113+
await element.click()
114+
break
115+
}
116+
}
117+
}

0 commit comments

Comments
 (0)