mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 09:08:46 +00:00
smoke: make editor tests more reliable
This commit is contained in:
parent
40af684bc9
commit
5fffacbb46
2 changed files with 14 additions and 18 deletions
|
@ -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');
|
||||
});
|
||||
});
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue