Merge VS Code 1.23.1 (#1520)

This commit is contained in:
Matt Irvine
2018-06-05 11:24:51 -07:00
committed by GitHub
parent e3baf5c443
commit 0c58f09e59
3651 changed files with 74249 additions and 48599 deletions

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as cp from 'child_process';
import { SpectronApplication } from '../../spectron/application';
import { Application } from '../../application';
const DIFF_EDITOR_LINE_INSERT = '.monaco-diff-editor .editor.modified .line-insert';
const SYNC_STATUSBAR = 'div[id="workbench.parts.statusbar"] .statusbar-entry a[title$="Synchronize Changes"]';
@@ -12,39 +12,40 @@ const SYNC_STATUSBAR = 'div[id="workbench.parts.statusbar"] .statusbar-entry a[t
export function setup() {
describe('Git', () => {
before(async function () {
const app = this.app as SpectronApplication;
app.suiteName = 'Git';
const app = this.app as Application;
cp.execSync('git config user.name testuser', { cwd: app.workspacePath });
cp.execSync('git config user.email monacotools@microsoft.com', { cwd: app.workspacePath });
});
it('reflects working tree changes', async function () {
const app = this.app as SpectronApplication;
const app = this.app as Application;
await app.workbench.scm.openSCMViewlet();
await app.workbench.quickopen.openFile('app.js');
await app.workbench.editor.waitForTypeInEditor('app.js', '.foo{}');
await app.workbench.saveOpenedFile();
await app.workbench.editors.saveOpenedFile();
await app.workbench.quickopen.openFile('index.jade');
await app.workbench.editor.waitForTypeInEditor('index.jade', 'hello world');
await app.workbench.saveOpenedFile();
await app.workbench.editors.saveOpenedFile();
await app.workbench.scm.refreshSCMViewlet();
await app.workbench.scm.waitForChange('app.js', 'Modified');
await app.workbench.scm.waitForChange('index.jade', 'Modified');
await app.screenCapturer.capture('changes');
});
it('opens diff editor', async function () {
const app = this.app as SpectronApplication;
const app = this.app as Application;
await app.workbench.scm.openSCMViewlet();
await app.workbench.scm.openChange('app.js');
await app.client.waitForElement(DIFF_EDITOR_LINE_INSERT);
await app.code.waitForElement(DIFF_EDITOR_LINE_INSERT);
});
it('stages correctly', async function () {
const app = this.app as SpectronApplication;
const app = this.app as Application;
await app.workbench.scm.openSCMViewlet();
@@ -58,7 +59,7 @@ export function setup() {
});
it(`stages, commits changes and verifies outgoing change`, async function () {
const app = this.app as SpectronApplication;
const app = this.app as Application;
await app.workbench.scm.openSCMViewlet();
@@ -67,13 +68,13 @@ export function setup() {
await app.workbench.scm.waitForChange('app.js', 'Index Modified');
await app.workbench.scm.commit('first commit');
await app.client.waitForText(SYNC_STATUSBAR, ' 0↓ 1↑');
await app.code.waitForTextContent(SYNC_STATUSBAR, ' 0↓ 1↑');
await app.workbench.quickopen.runCommand('Git: Stage All Changes');
await app.workbench.runCommand('Git: Stage All Changes');
await app.workbench.scm.waitForChange('index.jade', 'Index Modified');
await app.workbench.scm.commit('second commit');
await app.client.waitForText(SYNC_STATUSBAR, ' 0↓ 2↑');
await app.code.waitForTextContent(SYNC_STATUSBAR, ' 0↓ 2↑');
cp.execSync('git reset --hard origin/master', { cwd: app.workspacePath });
});

View File

@@ -3,8 +3,10 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { SpectronApplication } from '../../spectron/application';
import { Viewlet } from '../workbench/viewlet';
import { Commands } from '../workbench/workbench';
import { IElement } from '../../vscode/driver';
import { findElement, findElements, Code } from '../../vscode/code';
const VIEWLET = 'div[id="workbench.view.scm"]';
const SCM_INPUT = `${VIEWLET} .scm-editor textarea`;
@@ -22,84 +24,61 @@ interface Change {
actions: string[];
}
function toChange(element: IElement): Change {
const name = findElement(element, e => /\blabel-name\b/.test(e.className))!;
const type = element.attributes['data-tooltip'] || '';
const actionElementList = findElements(element, e => /\baction-label\b/.test(e.className));
const actions = actionElementList.map(e => e.attributes['title']);
return {
name: name.textContent || '',
type,
actions
};
}
export class SCM extends Viewlet {
constructor(spectron: SpectronApplication) {
super(spectron);
constructor(code: Code, private commands: Commands) {
super(code);
}
async openSCMViewlet(): Promise<any> {
await this.spectron.runCommand('workbench.view.scm');
await this.spectron.client.waitForElement(SCM_INPUT);
await this.commands.runCommand('workbench.view.scm');
await this.code.waitForElement(SCM_INPUT);
}
waitForChange(name: string, type?: string): Promise<void> {
return this.spectron.client.waitFor(async () => {
const changes = await this.queryChanges(name, type);
return changes.length;
}, l => l > 0, 'Getting SCM changes') as Promise<any> as Promise<void>;
async waitForChange(name: string, type?: string): Promise<void> {
const func = (change: Change) => change.name === name && (!type || change.type === type);
await this.code.waitForElements(SCM_RESOURCE, true, elements => elements.some(e => func(toChange(e))));
}
async refreshSCMViewlet(): Promise<any> {
await this.spectron.client.click(REFRESH_COMMAND);
}
private async queryChanges(name: string, type?: string): Promise<Change[]> {
const result = await this.spectron.webclient.selectorExecute(SCM_RESOURCE, (div, name, type) => {
return (Array.isArray(div) ? div : [div])
.map(element => {
const name = element.querySelector('.label-name') as HTMLElement;
const type = element.getAttribute('data-tooltip') || '';
const actionElementList = element.querySelectorAll('.actions .action-label');
const actions: string[] = [];
for (let i = 0; i < actionElementList.length; i++) {
const element = actionElementList.item(i) as HTMLElement;
actions.push(element.title);
}
return {
name: name.textContent,
type,
actions
};
})
.filter(change => {
if (change.name !== name) {
return false;
}
if (type && (change.type !== type)) {
return false;
}
return true;
});
}, name, type);
return result;
await this.code.waitAndClick(REFRESH_COMMAND);
}
async openChange(name: string): Promise<void> {
await this.spectron.client.waitAndClick(SCM_RESOURCE_CLICK(name));
await this.code.waitAndClick(SCM_RESOURCE_CLICK(name));
}
async stage(name: string): Promise<void> {
await this.spectron.client.waitAndClick(SCM_RESOURCE_ACTION_CLICK(name, 'Stage Changes'));
await this.code.waitAndClick(SCM_RESOURCE_ACTION_CLICK(name, 'Stage Changes'));
}
async stageAll(): Promise<void> {
await this.spectron.client.waitAndClick(SCM_RESOURCE_GROUP_COMMAND_CLICK('Stage All Changes'));
await this.code.waitAndClick(SCM_RESOURCE_GROUP_COMMAND_CLICK('Stage All Changes'));
}
async unstage(name: string): Promise<void> {
await this.spectron.client.waitAndClick(SCM_RESOURCE_ACTION_CLICK(name, 'Unstage Changes'));
await this.code.waitAndClick(SCM_RESOURCE_ACTION_CLICK(name, 'Unstage Changes'));
}
async commit(message: string): Promise<void> {
await this.spectron.client.waitAndClick(SCM_INPUT);
await this.spectron.client.waitForActiveElement(SCM_INPUT);
await this.spectron.client.setValue(SCM_INPUT, message);
await this.spectron.client.waitAndClick(COMMIT_COMMAND);
await this.code.waitAndClick(SCM_INPUT);
await this.code.waitForActiveElement(SCM_INPUT);
await this.code.waitForSetValue(SCM_INPUT, message);
await this.code.waitAndClick(COMMIT_COMMAND);
}
}