Skip to content

Commit

Permalink
chore(examples): Fix failing tests and improve stability of examples/…
Browse files Browse the repository at this point in the history
…helloworld-extester

Signed-off-by: Dominik Jelinek <[email protected]>
  • Loading branch information
djelinek authored and Lukas Grossmann committed Aug 1, 2024
1 parent f45adc4 commit 9161103
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ describe('Example extension view tests', () => {
this.timeout(15000);
// open the extensions view
const view = await (await new ActivityBar().getViewControl('Extensions'))?.openView();
await view?.getDriver().wait(async function () {
return (await view.getContent().getSections()).length > 0;
});

// we want to find the hello-world extension (this project)
// first we need a view section, best place to get started is the 'Installed' section
Expand All @@ -35,7 +38,10 @@ describe('Example extension view tests', () => {
// search for the extension, you can use any syntax vscode supports for the search field
// it is best to prepend @installed to the extension name if you don't want to see the results from marketplace
// also, getting the name directly from package.json seem like a good idea
helloExtension = (await extensions.findItem(`@installed ${pjson.displayName}`)) as ExtensionsViewItem;
await extensions.getDriver().wait(async function () {
helloExtension = (await extensions.findItem(`@installed ${pjson.displayName}`)) as ExtensionsViewItem;
return helloExtension !== undefined;
});
});

it('Check the extension info', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('Sample notifications tests', () => {
}
}

expect(await notification.getText()).equals('Hello World!');
expect(await notification.getText()).equals('Hello World, Test Project!');
expect(await notification.getType()).equals(NotificationType.Info);

// and we can manually dismiss the notification
Expand All @@ -72,7 +72,7 @@ describe('Sample notifications tests', () => {
}
}

expect(await notification.getText()).equals('Hello World!');
expect(await notification.getText()).equals('Hello World, Test Project!');
expect(await notification.getType()).equals(NotificationType.Info);

// this time we can clear all notifications
Expand Down
3 changes: 2 additions & 1 deletion examples/helloworld-extester/src/ui-test/statusBar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import { InputBox, StatusBar, VSBrowser } from 'vscode-extension-tester';
describe('Example status bar tests', () => {
let statusBar: StatusBar;

before(async () => {
before(async function () {
this.timeout(15_000);
statusBar = new StatusBar();
// most basic functions of status bar are only available when a file is opened
await VSBrowser.instance.openResources(path.join('src', 'ui-test', 'resources', 'problems.ts'));
Expand Down
3 changes: 2 additions & 1 deletion examples/helloworld-extester/src/ui-test/treeView.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ describe('Example tree view tests', () => {
let titlePart: ViewTitlePart;
let content: ViewContent;

before(async () => {
before(async function () {
this.timeout(15_000);
// we will be looking at the explorer view
// first we need to open a folder to get some items into the view
await VSBrowser.instance.openResources(path.join('src', 'ui-test', 'resources', 'test'));
Expand Down

0 comments on commit 9161103

Please sign in to comment.