mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge VS Code 1.21 source code (#1067)
* Initial VS Code 1.21 file copy with patches * A few more merges * Post npm install * Fix batch of build breaks * Fix more build breaks * Fix more build errors * Fix more build breaks * Runtime fixes 1 * Get connection dialog working with some todos * Fix a few packaging issues * Copy several node_modules to package build to fix loader issues * Fix breaks from master * A few more fixes * Make tests pass * First pass of license header updates * Second pass of license header updates * Fix restore dialog issues * Remove add additional themes menu items * fix select box issues where the list doesn't show up * formatting * Fix editor dispose issue * Copy over node modules to correct location on all platforms
This commit is contained in:
@@ -3,84 +3,79 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as cp from 'child_process';
|
||||
import { SpectronApplication } from '../../spectron/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"]';
|
||||
|
||||
describe('Git', () => {
|
||||
before(function () {
|
||||
this.app.suiteName = 'Git';
|
||||
export function setup() {
|
||||
describe('Git', () => {
|
||||
before(async function () {
|
||||
const app = this.app as SpectronApplication;
|
||||
app.suiteName = 'Git';
|
||||
});
|
||||
|
||||
it('reflects working tree changes', async function () {
|
||||
const app = this.app as SpectronApplication;
|
||||
|
||||
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.quickopen.openFile('index.jade');
|
||||
await app.workbench.editor.waitForTypeInEditor('index.jade', 'hello world');
|
||||
await app.workbench.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;
|
||||
|
||||
await app.workbench.scm.openSCMViewlet();
|
||||
await app.workbench.scm.openChange('app.js');
|
||||
await app.client.waitForElement(DIFF_EDITOR_LINE_INSERT);
|
||||
});
|
||||
|
||||
it('stages correctly', async function () {
|
||||
const app = this.app as SpectronApplication;
|
||||
|
||||
await app.workbench.scm.openSCMViewlet();
|
||||
|
||||
await app.workbench.scm.waitForChange('app.js', 'Modified');
|
||||
await app.workbench.scm.stage('app.js');
|
||||
|
||||
await app.workbench.scm.waitForChange('app.js', 'Index Modified');
|
||||
await app.workbench.scm.unstage('app.js');
|
||||
|
||||
await app.workbench.scm.waitForChange('app.js', 'Modified');
|
||||
});
|
||||
|
||||
it(`stages, commits changes and verifies outgoing change`, async function () {
|
||||
const app = this.app as SpectronApplication;
|
||||
|
||||
await app.workbench.scm.openSCMViewlet();
|
||||
|
||||
await app.workbench.scm.waitForChange('app.js', 'Modified');
|
||||
await app.workbench.scm.stage('app.js');
|
||||
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.workbench.quickopen.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↑');
|
||||
|
||||
cp.execSync('git reset --hard origin/master', { cwd: app.workspacePath });
|
||||
});
|
||||
});
|
||||
|
||||
it('reflects working tree changes', async function () {
|
||||
const app = this.app as SpectronApplication;
|
||||
|
||||
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.quickopen.openFile('index.jade');
|
||||
await app.workbench.editor.waitForTypeInEditor('index.jade', 'hello world');
|
||||
await app.workbench.saveOpenedFile();
|
||||
|
||||
await app.workbench.scm.refreshSCMViewlet();
|
||||
const appJs = await app.workbench.scm.waitForChange(c => c.name === 'app.js');
|
||||
const indexJade = await app.workbench.scm.waitForChange(c => c.name === 'index.jade');
|
||||
await app.screenCapturer.capture('changes');
|
||||
|
||||
assert.equal(appJs.name, 'app.js');
|
||||
assert.equal(appJs.type, 'Modified');
|
||||
|
||||
assert.equal(indexJade.name, 'index.jade');
|
||||
assert.equal(indexJade.type, 'Modified');
|
||||
});
|
||||
|
||||
it('opens diff editor', async function () {
|
||||
const app = this.app as SpectronApplication;
|
||||
|
||||
await app.workbench.scm.openSCMViewlet();
|
||||
const appJs = await app.workbench.scm.waitForChange(c => c.name === 'app.js');
|
||||
await app.workbench.scm.openChange(appJs);
|
||||
await app.client.waitForElement(DIFF_EDITOR_LINE_INSERT);
|
||||
});
|
||||
|
||||
it('stages correctly', async function () {
|
||||
const app = this.app as SpectronApplication;
|
||||
|
||||
await app.workbench.scm.openSCMViewlet();
|
||||
|
||||
const appJs = await app.workbench.scm.waitForChange(c => c.name === 'app.js' && c.type === 'Modified');
|
||||
await app.workbench.scm.stage(appJs);
|
||||
|
||||
const indexAppJs = await app.workbench.scm.waitForChange(c => c.name === 'app.js' && c.type === 'Index Modified');
|
||||
await app.workbench.scm.unstage(indexAppJs);
|
||||
|
||||
await app.workbench.scm.waitForChange(c => c.name === 'app.js' && c.type === 'Modified');
|
||||
});
|
||||
|
||||
it(`stages, commits changes and verifies outgoing change`, async function () {
|
||||
const app = this.app as SpectronApplication;
|
||||
|
||||
await app.workbench.scm.openSCMViewlet();
|
||||
|
||||
const appJs = await app.workbench.scm.waitForChange(c => c.name === 'app.js' && c.type === 'Modified');
|
||||
await app.workbench.scm.stage(appJs);
|
||||
await app.workbench.scm.waitForChange(c => c.name === 'app.js' && c.type === 'Index Modified');
|
||||
|
||||
await app.workbench.scm.commit('first commit');
|
||||
await app.client.waitForText(SYNC_STATUSBAR, ' 0↓ 1↑');
|
||||
|
||||
await app.workbench.quickopen.runCommand('Git: Stage All Changes');
|
||||
await app.workbench.scm.waitForChange(c => c.name === 'index.jade' && c.type === 'Index Modified');
|
||||
|
||||
await app.workbench.scm.commit('second commit');
|
||||
await app.client.waitForText(SYNC_STATUSBAR, ' 0↓ 2↑');
|
||||
|
||||
cp.execSync('git reset --hard origin/master', { cwd: app.workspacePath });
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { SpectronApplication } from '../../spectron/application';
|
||||
import { Viewlet } from '../workbench/viewlet';
|
||||
|
||||
@@ -13,14 +12,14 @@ const SCM_RESOURCE = `${VIEWLET} .monaco-list-row > .resource`;
|
||||
const SCM_RESOURCE_GROUP = `${VIEWLET} .monaco-list-row > .resource-group`;
|
||||
const REFRESH_COMMAND = `div[id="workbench.parts.sidebar"] .actions-container a.action-label[title="Refresh"]`;
|
||||
const COMMIT_COMMAND = `div[id="workbench.parts.sidebar"] .actions-container a.action-label[title="Commit"]`;
|
||||
const SCM_RESOURCE_CLICK = name => `${SCM_RESOURCE} .monaco-icon-label[title*="${name}"]`;
|
||||
const SCM_RESOURCE_GROUP_COMMAND_CLICK = name => `${SCM_RESOURCE_GROUP} .actions .action-label[title="${name}"]`;
|
||||
const SCM_RESOURCE_CLICK = (name: string) => `${SCM_RESOURCE} .monaco-icon-label[title*="${name}"] .label-name`;
|
||||
const SCM_RESOURCE_ACTION_CLICK = (name: string, actionName: string) => `${SCM_RESOURCE} .monaco-icon-label[title*="${name}"] .actions .action-label[title="${actionName}"]`;
|
||||
const SCM_RESOURCE_GROUP_COMMAND_CLICK = (name: string) => `${SCM_RESOURCE_GROUP} .actions .action-label[title="${name}"]`;
|
||||
|
||||
export interface Change {
|
||||
id: string;
|
||||
interface Change {
|
||||
name: string;
|
||||
type: string;
|
||||
actions: { id: string, title: string; }[];
|
||||
actions: string[];
|
||||
}
|
||||
|
||||
export class SCM extends Viewlet {
|
||||
@@ -34,64 +33,67 @@ export class SCM extends Viewlet {
|
||||
await this.spectron.client.waitForElement(SCM_INPUT);
|
||||
}
|
||||
|
||||
async waitForChange(func: (change: Change) => boolean): Promise<Change> {
|
||||
return await this.spectron.client.waitFor(async () => {
|
||||
const changes = await this.getChanges();
|
||||
return changes.filter(func)[0];
|
||||
}, void 0, 'Getting changes');
|
||||
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 refreshSCMViewlet(): Promise<any> {
|
||||
await this.spectron.client.click(REFRESH_COMMAND);
|
||||
}
|
||||
|
||||
async getChanges(): Promise<Change[]> {
|
||||
const result = await this.spectron.webclient.selectorExecute(SCM_RESOURCE,
|
||||
div => (Array.isArray(div) ? div : [div]).map(element => {
|
||||
const name = element.querySelector('.label-name') as HTMLElement;
|
||||
const icon = element.querySelector('.decoration-icon') as HTMLElement;
|
||||
const actionElementList = element.querySelectorAll('.actions .action-label');
|
||||
const actionElements: any[] = [];
|
||||
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;
|
||||
actionElements.push({ element, title: element.title });
|
||||
}
|
||||
for (let i = 0; i < actionElementList.length; i++) {
|
||||
const element = actionElementList.item(i) as HTMLElement;
|
||||
actions.push(element.title);
|
||||
}
|
||||
|
||||
return {
|
||||
name: name.textContent,
|
||||
type: (icon.title || ''),
|
||||
element,
|
||||
actionElements
|
||||
};
|
||||
})
|
||||
);
|
||||
return {
|
||||
name: name.textContent,
|
||||
type,
|
||||
actions
|
||||
};
|
||||
})
|
||||
.filter(change => {
|
||||
if (change.name !== name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return result.map(({ name, type, element, actionElements }) => {
|
||||
// const actions = actionElements.reduce((r, { element, title }) => r[title] = element.ELEMENT, {});
|
||||
const actions = actionElements.map(({ element, title }) => ({ id: element.ELEMENT, title }));
|
||||
return { name, type, id: element.ELEMENT, actions };
|
||||
});
|
||||
if (type && (change.type !== type)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}, name, type);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async openChange(change: Change): Promise<void> {
|
||||
await this.spectron.client.waitAndClick(SCM_RESOURCE_CLICK(change.name));
|
||||
async openChange(name: string): Promise<void> {
|
||||
await this.spectron.client.waitAndClick(SCM_RESOURCE_CLICK(name));
|
||||
}
|
||||
|
||||
async stage(change: Change): Promise<void> {
|
||||
const action = change.actions.filter(a => a.title === 'Stage Changes')[0];
|
||||
assert(action);
|
||||
await this.spectron.client.spectron.client.elementIdClick(action.id);
|
||||
async stage(name: string): Promise<void> {
|
||||
await this.spectron.client.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'));
|
||||
}
|
||||
|
||||
async unstage(change: Change): Promise<void> {
|
||||
const action = change.actions.filter(a => a.title === 'Unstage Changes')[0];
|
||||
assert(action);
|
||||
await this.spectron.client.spectron.client.elementIdClick(action.id);
|
||||
async unstage(name: string): Promise<void> {
|
||||
await this.spectron.client.waitAndClick(SCM_RESOURCE_ACTION_CLICK(name, 'Unstage Changes'));
|
||||
}
|
||||
|
||||
async commit(message: string): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user