Skip to content

Commit c7e5d9a

Browse files
vrubezhnyclaude
andcommitted
[tests] Fix Run Command test
- Fix broken imports (src/... → relative paths) - Add suite timeout and existence assertions - Use waitForItemStable for reliable component detection - Improved componentCommands Public UI test Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com> Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent f025a4b commit c7e5d9a

3 files changed

Lines changed: 29 additions & 8 deletions

File tree

src/devfile/parallelCompositeCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* Licensed under the MIT License. See LICENSE file in the project root for license information.
44
*-----------------------------------------------------------------------------------------------*/
55

6-
import { ComponentWorkspaceFolder } from 'src/odo/workspace';
76
import { Command } from '../odo/componentTypeDescription';
7+
import { ComponentWorkspaceFolder } from '../odo/workspace';
88
import { DevfileCommandRunner } from './devfileCommandRunner';
99

1010
export class ParallelCompositeCommand {

test/integration/command.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import { EventEmitter, Terminal, window, workspace } from 'vscode';
1515
import { parse, stringify } from 'yaml';
1616
import { CommandText } from '../../src/base/command';
1717
import { CliChannel } from '../../src/cli';
18+
import { DevfileCommandRunner } from '../../src/devfile/devfileCommandRunner';
1819
import { Oc } from '../../src/oc/ocWrapper';
1920
import { Command } from '../../src/odo/command';
2021
import { OdoPreference } from '../../src/odo/odoPreference';
2122
import { Odo } from '../../src/odo/odoWrapper';
23+
import { ComponentWorkspaceFolder } from '../../src/odo/workspace';
2224
import { LoginUtil } from '../../src/util/loginUtil';
2325
import { YAML_STRINGIFY_OPTIONS } from '../../src/util/utils';
24-
import { ComponentWorkspaceFolder } from 'src/odo/workspace';
25-
import { DevfileCommandRunner } from '../../src/devfile/devfileCommandRunner';
2626

2727
const ODO = Odo.Instance;
2828

test/ui/suite/componentCommands.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ import {
1717
Workbench,
1818
} from 'vscode-extension-tester';
1919
import { parse } from 'yaml';
20-
import { itemExists } from '../common/conditions';
20+
import { waitForItemStable, warn } from '../common/conditions';
2121
import { VIEWS } from '../common/constants';
2222
import { reloadWindow } from '../common/overdrives';
2323
import { OpenshiftTerminalWebviewView } from '../common/ui/webviewView/openshiftTerminalWebviewView';
2424

2525
export function testComponentCommands(path: string) {
2626
describe('Component Commands', function () {
27+
this.timeout(30_000);
28+
2729
let view: SideBarView;
28-
let section: ViewSection;
2930
let commands: TreeItem[];
3031

3132
const componentName = 'nodejs-starter';
@@ -46,10 +47,15 @@ export function testComponentCommands(path: string) {
4647
}
4748

4849
// expect component is running
49-
section = await view.getContent().getSection(VIEWS.components);
5050
try {
51-
await itemExists(`${componentName} (dev running)`, section);
52-
} catch {
51+
const componentInDevName = `${componentName} (dev running)`;
52+
const item = await waitForItemStable(getSection, componentInDevName, true, 40_000);
53+
if (!item) {
54+
warn(`Component "${componentName}" not found or isn't running in Dev, skipping tests`);
55+
this.skip();
56+
}
57+
} catch (err) {
58+
warn('Error in before hook: "Component Commands":', err);
5359
this.skip();
5460
}
5561
});
@@ -70,7 +76,13 @@ export function testComponentCommands(path: string) {
7076
});
7177

7278
//get component
79+
const section = await getSection();
80+
expect(section).to.exist;
81+
7382
const components = await section.getVisibleItems();
83+
expect(components).to.exist;
84+
expect(components).to.have.length.greaterThan(0);
85+
7486
const component = components[0] as TreeItem;
7587
await component.expand();
7688

@@ -85,6 +97,11 @@ export function testComponentCommands(path: string) {
8597
actualCommands.push(await command.getLabel());
8698
}
8799
expect(actualCommands).to.include.members(expectedCommands);
100+
101+
// The sets of devfile component commands (expectedCommands) and actual component commands (actualCommands)
102+
// are to be the same
103+
expect(actualCommands).to.have.members(expectedCommands);
104+
88105
});
89106

90107
it('Command can be ran', async function () {
@@ -117,5 +134,9 @@ export function testComponentCommands(path: string) {
117134

118135
expect(terminalText).to.contain('Press any key to close this terminal');
119136
});
137+
138+
async function getSection(): Promise<ViewSection> {
139+
return await view.getContent().getSection(VIEWS.components);
140+
}
120141
});
121142
}

0 commit comments

Comments
 (0)