提交 5fffacbb 编写于 作者: S Sandeep Somavarapu

smoke: make editor tests more reliable

上级 40af684b
......@@ -28,12 +28,8 @@ describe('Editor', () => {
const references = await app.workbench.editor.findReferences('app', 7);
const countInTitle = await references.getCountFromTitle();
await app.screenCapturer.capture('References result');
assert.equal(countInTitle, 3, 'References count in widget title is not as expected.');
const referencesCount = await references.getCount();
assert.equal(referencesCount, 3, 'References count in tree is not as expected.');
await references.waitForReferencesCountInTitle(3);
await references.waitForReferencesCount(3);
await references.close();
});
......@@ -70,7 +66,7 @@ describe('Editor', () => {
await app.workbench.editor.gotoDefinition('express', 11);
assert.ok(await app.workbench.waitForActiveOpen('index.d.ts'), 'Tab opened when navigating to definition is not as expected.');
await app.workbench.waitForActiveOpen('index.d.ts');
});
it(`verifies that 'Peek Definition' works`, async function () {
......@@ -78,8 +74,6 @@ describe('Editor', () => {
const peek = await app.workbench.editor.peekDefinition('express', 11);
const definitionFilename = await peek.getFileNameFromTitle();
await app.screenCapturer.capture('Peek definition result');
assert.equal(definitionFilename, 'index.d.ts', 'Peek result is not as expected.');
await peek.waitForFile('index.d.ts');
});
});
\ No newline at end of file
......@@ -19,20 +19,22 @@ export class References {
await this.spectron.client.waitForElement(References.REFERENCES_WIDGET);
}
public async getCountFromTitle(): Promise<number> {
const titleCount = await this.spectron.client.waitForText(References.REFERENCES_TITLE_COUNT);
const matches = titleCount.match(/\d+/);
return matches ? parseInt(matches[0]) : 0;
public async waitForReferencesCountInTitle(count: number): Promise<void> {
await this.spectron.client.waitForText(References.REFERENCES_TITLE_COUNT, void 0, titleCount => {
const matches = titleCount.match(/\d+/);
return matches ? parseInt(matches[0]) === count : false;
});
}
public async getFileNameFromTitle(): Promise<string> {
return await this.spectron.client.waitForText(References.REFERENCES_TITLE_FILE_NAME);
public async waitForReferencesCount(count: number): Promise<void> {
await this.spectron.client.waitForElements(References.REFERENCES, result => result && result.length === count);
}
public async getCount(): Promise<number> {
return (await this.spectron.client.waitForElements(References.REFERENCES)).length;
public async waitForFile(file: string): Promise<void> {
await this.spectron.client.waitForText(References.REFERENCES_TITLE_FILE_NAME, file);
}
public async close(): Promise<void> {
await this.spectron.client.keys(['Escape', 'NULL']);
await this.spectron.client.waitForElement(References.REFERENCES_WIDGET, element => !element);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册