提交 b9c6595e 编写于 作者: J Joao

smoke

上级 0f34ab38
......@@ -28,6 +28,7 @@ describe('Git', () => {
// wait
await app.workbench.scm.refreshSCMViewlet();
await app.workbench.scm.waitForChange(c => c.name === 'app.js');
await app.workbench.scm.waitForChange(c => c.name === 'index.jade');
......
......@@ -5,11 +5,10 @@
import { SpectronApplication } from '../../spectron/application';
// var htmlparser = require('htmlparser2');
const VIEWLET = 'div[id="workbench.view.scm"]';
const SCM_INPUT = `${VIEWLET} .scm-editor textarea`;
const SCM_RESOURCE = `${VIEWLET} .monaco-list-row > .resource`;
const REFRESH_COMMAND = `div[id="workbench.parts.sidebar"] .actions-container a.action-label[title="Refresh"]`;
export interface Change {
name: string;
......@@ -31,14 +30,7 @@ export class SCM {
async waitForChange(func: (change: Change) => boolean): Promise<Change> {
return await this.spectron.client.waitFor(async () => {
const changes = await this.spectron.webclient.selectorExecute(SCM_RESOURCE,
div => (Array.isArray(div) ? div : [div]).map(div => {
const name = div.querySelector('.label-name') as HTMLElement;
const icon = div.querySelector('.decoration-icon') as HTMLElement;
return { name: name.textContent, type: icon.title };
})
) as Change[];
const changes = await this.getChanges();
for (const change of changes) {
if (func(change)) {
......@@ -50,6 +42,21 @@ export class SCM {
});
}
async refreshSCMViewlet(): Promise<any> {
await this.spectron.client.click(REFRESH_COMMAND);
}
async getChanges(): Promise<Change[]> {
return await this.spectron.webclient.selectorExecute(SCM_RESOURCE,
div => (Array.isArray(div) ? div : [div]).map(div => {
const name = div.querySelector('.label-name') as HTMLElement;
const icon = div.querySelector('.decoration-icon') as HTMLElement;
return { name: name.textContent, type: icon.title };
})
) as Change[];
}
// async getChanges(expectedCount: number): Promise<Change[]> {
// await this.spectron.client.waitForElements(SCM_RESOURCE, r => r.length === expectedCount);
......
......@@ -91,8 +91,10 @@ function toUri(path: string): string {
}
async function main(): Promise<void> {
console.log('*** Preparing smoketest setup...');
const keybindingsUrl = `https://raw.githubusercontent.com/Microsoft/vscode-docs/master/scripts/keybindings/doc.keybindings.${getKeybindingPlatform()}.json`;
console.log(`Fetching keybindings from ${keybindingsUrl}...`);
console.log('*** Fetching keybindings...');
await new Promise((c, e) => {
https.get(keybindingsUrl, res => {
......@@ -105,7 +107,7 @@ async function main(): Promise<void> {
});
if (!fs.existsSync(workspacePath)) {
console.log('Creating workspace file...');
console.log('*** Creating workspace file...');
const workspace = {
id: (Date.now() + Math.round(Math.random() * 1000)).toString(),
folders: [
......@@ -119,17 +121,19 @@ async function main(): Promise<void> {
}
if (!fs.existsSync(testRepoLocalDir)) {
console.log('Cloning test project repository...');
console.log('*** Cloning test project repository...');
cp.spawnSync('git', ['clone', testRepoUrl, testRepoLocalDir]);
} else {
console.log('Cleaning test project repository...');
console.log('*** Cleaning test project repository...');
cp.spawnSync('git', ['fetch'], { cwd: testRepoLocalDir });
cp.spawnSync('git', ['reset', '--hard', 'FETCH_HEAD'], { cwd: testRepoLocalDir });
cp.spawnSync('git', ['clean', '-xdf'], { cwd: testRepoLocalDir });
}
console.log('Running npm install...');
console.log('*** Running npm install...');
// cp.execSync('npm install', { cwd: testRepoLocalDir, stdio: 'inherit' });
console.log('*** Smoketest setup done!\n');
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册