Skip to content

Commit

Permalink
Merge pull request #838 from zcervink/837
Browse files Browse the repository at this point in the history
Create UI test for testing YAML custom tags
  • Loading branch information
msivasubramaniaan authored Oct 18, 2022
2 parents fa9251e + 291dca9 commit 8306618
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/ui-test/allTestsSuite.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { extensionUIAssetsTest } from './extensionUITest';
import { contentAssistSuggestionTest } from './contentAssistTest';
import { customTagsTest } from './customTagsTest';

describe('VSCode YAML - UI tests', () => {
extensionUIAssetsTest();
contentAssistSuggestionTest();
customTagsTest();
});
58 changes: 58 additions & 0 deletions test/ui-test/customTagsTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { By, WebDriver, VSBrowser, Key, TextEditor, Workbench, InputBox, ContentAssist } from 'vscode-extension-tester';

/**
* @author Zbynek Cervinka <[email protected]>
*/
export function customTagsTest(): void {
describe("Verify extension's custom tags", () => {
it('YAML custom tags works as expected', async function () {
this.timeout(30000);

let driver: WebDriver = VSBrowser.instance.driver;
const settingsEditor = await new Workbench().openSettings();
const setting = await settingsEditor.findSetting('Custom Tags', 'Yaml');
await setting.findElement(By.className('edit-in-settings-button')).click();

await delay(2000);
await driver.actions().sendKeys(' "customTag1"').perform();
await driver.actions().sendKeys(Key.chord(TextEditor.ctlKey, 's')).perform();

driver = VSBrowser.instance.driver;
await driver.actions().sendKeys(Key.F1).perform();

let input = await InputBox.create();
await input.setText('>new file');
await input.confirm();
await input.confirm();

await driver.actions().sendKeys(Key.chord(TextEditor.ctlKey, 's')).perform();
input = await InputBox.create();
await input.setText('~/customTagsTestFile.yaml');
await input.confirm();

await delay(2000);
await driver.actions().sendKeys('custom').perform();

const contentAssist: ContentAssist | void = await new TextEditor().toggleContentAssist(true);

// find if an item with given label is present in the content assist
if (contentAssist instanceof ContentAssist) {
const hasItem = await contentAssist.hasItem('customTag1');
if (!hasItem) {
throw new Error("The 'customTag1' custom tag did not appear in the content assist's suggestion list.");
}
} else {
throw new Error("The 'customTag1' custom tag did not appear in the content assist's suggestion list.");
}
});

afterEach(async function () {
const { exec } = await require('child_process');
exec('rm ~/customTagsTestFile.yaml');
});
});
}

function delay(milliseconds: number): Promise<number> {
return new Promise((resolve) => setTimeout(resolve, milliseconds));
}

0 comments on commit 8306618

Please sign in to comment.