-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #838 from zcervink/837
Create UI test for testing YAML custom tags
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} |