smoke test - add attribute for tabs to simplify lookup

This commit is contained in:
Benjamin Pasero 2020-02-04 14:50:47 +01:00
parent cfc452e466
commit a15803b9e7
4 changed files with 24 additions and 15 deletions

View file

@ -42,6 +42,7 @@ import { IFileService } from 'vs/platform/files/common/files';
import { withNullAsUndefined, assertAllDefined, assertIsDefined } from 'vs/base/common/types';
import { ILabelService } from 'vs/platform/label/common/label';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { basenameOrAuthority } from 'vs/base/common/resources';
interface IEditorInputLabel {
name?: string;
@ -941,7 +942,15 @@ export class TabsTitleControl extends TitleControl {
tabContainer.title = title;
// Label
tabLabelWidget.setResource({ name, description, resource: toResource(editor, { supportSideBySide: SideBySideEditor.MASTER }) }, { title, extraClasses: ['tab-label'], italic: !this.group.isPinned(editor) });
const resource = toResource(editor, { supportSideBySide: SideBySideEditor.MASTER });
tabLabelWidget.setResource({ name, description, resource }, { title, extraClasses: ['tab-label'], italic: !this.group.isPinned(editor) });
// Tests helper
if (resource) {
tabContainer.setAttribute('data-resource-name', basenameOrAuthority(resource));
} else {
tabContainer.removeAttribute('data-resource-name');
}
}
private redrawEditorActiveAndDirty(isGroupActive: boolean, editor: IEditorInput, tabContainer: HTMLElement, tabLabelWidget: IResourceLabel): void {

View file

@ -17,27 +17,27 @@ export class Editors {
}
}
async selectTab(tabName: string, untitled: boolean = false): Promise<void> {
await this.code.waitAndClick(`.tabs-container div.tab[aria-label="${tabName}, tab"]`);
await this.waitForEditorFocus(tabName, untitled);
async selectTab(fileName: string): Promise<void> {
await this.code.waitAndClick(`.tabs-container div.tab[data-resource-name$="${fileName}"]`);
await this.waitForEditorFocus(fileName);
}
async waitForActiveEditor(filename: string): Promise<any> {
const selector = `.editor-instance .monaco-editor[data-uri$="${filename}"] textarea`;
async waitForActiveEditor(fileName: string): Promise<any> {
const selector = `.editor-instance .monaco-editor[data-uri$="${fileName}"] textarea`;
return this.code.waitForActiveElement(selector);
}
async waitForEditorFocus(fileName: string, untitled: boolean = false): Promise<void> {
async waitForEditorFocus(fileName: string): Promise<void> {
await this.waitForActiveTab(fileName);
await this.waitForActiveEditor(fileName);
}
async waitForActiveTab(fileName: string, isDirty: boolean = false): Promise<void> {
await this.code.waitForElement(`.tabs-container div.tab.active${isDirty ? '.dirty' : ''}[aria-selected="true"][aria-label="${fileName}, tab"]`);
await this.code.waitForElement(`.tabs-container div.tab.active${isDirty ? '.dirty' : ''}[aria-selected="true"][data-resource-name$="${fileName}"]`);
}
async waitForTab(fileName: string, isDirty: boolean = false): Promise<void> {
await this.code.waitForElement(`.tabs-container div.tab${isDirty ? '.dirty' : ''}[aria-label="${fileName}, tab"]`);
await this.code.waitForElement(`.tabs-container div.tab${isDirty ? '.dirty' : ''}[data-resource-name$="${fileName}"]`);
}
async newUntitledFile(): Promise<void> {
@ -47,6 +47,6 @@ export class Editors {
await this.code.dispatchKeybinding('ctrl+n');
}
await this.waitForEditorFocus('Untitled-1', true);
await this.waitForEditorFocus('Untitled-1');
}
}

View file

@ -12,7 +12,7 @@ export function setup() {
await app.workbench.editors.newUntitledFile();
const untitled = 'Untitled-1';
const textToTypeInUntitled = untitled;
const textToTypeInUntitled = 'Hello from Untitled';
await app.workbench.editor.waitForTypeInEditor(untitled, textToTypeInUntitled);
const readmeMd = 'readme.md';
@ -25,8 +25,8 @@ export function setup() {
await app.workbench.editors.waitForActiveTab(readmeMd, true);
await app.workbench.editor.waitForEditorContents(readmeMd, c => c.indexOf(textToType) > -1);
await app.workbench.editors.waitForTab(untitled, true);
await app.workbench.editors.selectTab(untitled, true);
await app.workbench.editors.waitForTab(untitled);
await app.workbench.editors.selectTab(untitled);
await app.workbench.editor.waitForEditorContents(untitled, c => c.indexOf(textToTypeInUntitled) > -1);
});
});

View file

@ -66,7 +66,7 @@ export function setup(stableCodePath: string, testDataPath: string) {
await stableApp.workbench.editors.newUntitledFile();
const untitled = 'Untitled-1';
const textToTypeInUntitled = untitled;
const textToTypeInUntitled = 'Hello from Untitled';
await stableApp.workbench.editor.waitForTypeInEditor(untitled, textToTypeInUntitled);
const readmeMd = 'readme.md';
@ -86,7 +86,7 @@ export function setup(stableCodePath: string, testDataPath: string) {
await insidersApp.workbench.editor.waitForEditorContents(readmeMd, c => c.indexOf(textToType) > -1);
await insidersApp.workbench.editors.waitForTab(untitled, true);
await insidersApp.workbench.editors.selectTab(untitled, true);
await insidersApp.workbench.editors.selectTab(untitled);
await insidersApp.workbench.editor.waitForEditorContents(untitled, c => c.indexOf(textToTypeInUntitled) > -1);
await insidersApp.stop();