parent
aeec6c67a6
commit
b4ee7df0e7
@ -0,0 +1,195 @@ |
||||
import { spawn, ChildProcess } from "child_process" |
||||
|
||||
export async function getBranches(path: string): Promise<string> { |
||||
return new Promise((resolve, reject) => { |
||||
const git = spawn('git', ['branch'], { cwd: path }) |
||||
let branches = '' |
||||
git.stdout.on('data', function (data) { |
||||
console.log('stdout git branches', data.toString()) |
||||
branches += data.toString() |
||||
}) |
||||
git.stderr.on('data', function (data) { |
||||
console.log('stderr git branches', data.toString()) |
||||
reject(data.toString()) |
||||
}) |
||||
git.on('close', function () { |
||||
resolve(branches) |
||||
}) |
||||
}) |
||||
} |
||||
|
||||
export async function getGitLog(path: string): Promise<string> { |
||||
return new Promise((resolve, reject) => { |
||||
const git = spawn('git', ['log'], { cwd: path }) |
||||
let logs = '' |
||||
git.stdout.on('data', function (data) { |
||||
logs += data.toString() |
||||
}) |
||||
git.stderr.on('err', function (data) { |
||||
reject(data.toString()) |
||||
}) |
||||
git.on('close', function () { |
||||
resolve(logs) |
||||
}) |
||||
}) |
||||
} |
||||
|
||||
export async function cloneOnServer(repo: string, path: string) { |
||||
console.log('cloning', repo, path) |
||||
return new Promise((resolve, reject) => { |
||||
const git = spawn('rm -rf bare && git', ['clone', repo], { cwd: path, shell: true, detached: true }); |
||||
|
||||
git.stdout.on('data', function (data) { |
||||
console.log('stdout data cloning', data.toString()); |
||||
if (data.toString().includes('done')) { |
||||
resolve(git); |
||||
} |
||||
}); |
||||
|
||||
git.stderr.on('data', function (data) { |
||||
console.log('stderr data cloning', data.toString()); |
||||
if (data.toString().includes('into')) { |
||||
setTimeout(() => { |
||||
resolve(git); |
||||
}, 5000) |
||||
} |
||||
}); |
||||
|
||||
git.on('error', (error) => { |
||||
reject(`Process error: ${error.message}`); |
||||
}); |
||||
|
||||
git.on('exit', (code, signal) => { |
||||
if (code !== 0) { |
||||
reject(`Process exited with code: ${code} and signal: ${signal}`); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
|
||||
export async function onLocalGitRepoAddFile(path: string, file: string) { |
||||
console.log('adding file', file) |
||||
return new Promise((resolve, reject) => { |
||||
const git = spawn('touch', [file], { cwd: path }); |
||||
|
||||
git.stdout.on('data', function (data) { |
||||
console.log('stdout data adding file', data.toString()); |
||||
if (data.toString().includes('done')) { |
||||
resolve(git); |
||||
} |
||||
}); |
||||
|
||||
git.stderr.on('data', function (data) { |
||||
console.error('stderr adding file', data.toString()); |
||||
reject(data.toString()); |
||||
}); |
||||
|
||||
git.on('error', (error) => { |
||||
reject(`Process error: ${error.message}`); |
||||
}); |
||||
|
||||
git.on('exit', (code, signal) => { |
||||
if (code !== 0) { |
||||
reject(`Process exited with code: ${code} and signal: ${signal}`); |
||||
} else { |
||||
resolve(git); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
|
||||
export async function onLocalGitRepoPush(path: string, branch: string = 'master') { |
||||
console.log('pushing', path) |
||||
return new Promise((resolve, reject) => { |
||||
const git = spawn('git', ['push', 'origin', branch], { cwd: path, shell: true, detached: true }); |
||||
|
||||
git.stdout.on('data', function (data) { |
||||
console.log('stdout data pushing', data.toString()); |
||||
if (data.toString().includes('done')) { |
||||
resolve(git); |
||||
} |
||||
}); |
||||
|
||||
git.stderr.on('data', function (data) { |
||||
console.error('stderr data pushing', data.toString()); |
||||
if (data.toString().includes(branch)) { |
||||
resolve(git); |
||||
} |
||||
}); |
||||
|
||||
git.on('error', (error) => { |
||||
reject(`Process error: ${error.message}`); |
||||
}); |
||||
|
||||
git.on('exit', (code, signal) => { |
||||
if (code !== 0) { |
||||
reject(`Process exited with code: ${code} and signal: ${signal}`); |
||||
} else { |
||||
resolve(git); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
|
||||
|
||||
export async function createCommitOnLocalServer(path: string, message: string) { |
||||
console.log('committing', message, path) |
||||
return new Promise((resolve, reject) => { |
||||
const git = spawn('git add . && git', ['commit', '-m', message], { cwd: path, shell: true, detached: true }); |
||||
|
||||
git.stdout.on('data', function (data) { |
||||
console.log('data stdout committing', data.toString()); |
||||
if (data.toString().includes(message)) { |
||||
setTimeout(() => { |
||||
resolve(git); |
||||
}, 1000) |
||||
} |
||||
}); |
||||
|
||||
git.stderr.on('data', function (data) { |
||||
console.error('data commiting', data.toString()); |
||||
reject(data.toString()); |
||||
}); |
||||
|
||||
git.on('error', (error) => { |
||||
console.error('error', error); |
||||
reject(`Process error: ${error.message}`); |
||||
}); |
||||
|
||||
git.on('exit', (code, signal) => { |
||||
if (code !== 0) { |
||||
console.error('exit', code, signal); |
||||
reject(`Process exited with code: ${code} and signal: ${signal}`); |
||||
} else { |
||||
resolve(git); |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
|
||||
|
||||
export async function spawnGitServer(path: string): Promise<ChildProcess> { |
||||
console.log(process.cwd()) |
||||
try { |
||||
const server = spawn('yarn && sh setup.sh && npx ts-node server.ts', [`${path}`], { cwd: process.cwd() + '/../remix-ide-e2e/src/githttpbackend/', shell: true, detached: true }) |
||||
console.log('spawned', server.stdout.closed, server.stderr.closed) |
||||
return new Promise((resolve, reject) => { |
||||
server.stdout.on('data', function (data) { |
||||
console.log(data.toString()) |
||||
if ( |
||||
data.toString().includes('is listening') |
||||
|| data.toString().includes('address already in use') |
||||
) { |
||||
console.log('resolving') |
||||
resolve(server) |
||||
} |
||||
}) |
||||
server.stderr.on('err', function (data) { |
||||
console.log(data.toString()) |
||||
reject(data.toString()) |
||||
}) |
||||
}) |
||||
} catch (e) { |
||||
console.log(e) |
||||
} |
||||
} |
@ -0,0 +1,187 @@ |
||||
import { ChildProcess, spawn } from "child_process" |
||||
import kill from 'tree-kill' |
||||
import { Nightwatch, NightwatchBrowser } from "nightwatch" |
||||
import { spawnGitServer, getGitLog, cloneOnServer, onLocalGitRepoAddFile, createCommitOnLocalServer, onLocalGitRepoPush, getBranches } from "../../lib/git" |
||||
let gitserver: ChildProcess |
||||
|
||||
/* |
||||
/ uses the git-http-backend package to create a git server ( if needed kill the server: kill -9 $(sudo lsof -t -i:6868) ) |
||||
/ GROUP 1: file operations PUSH PULL COMMIT SYNC FETCH CLONE ADD |
||||
/ GROUP 2: branch operations CREATE & PUBLISH |
||||
/ GROUP 3: file operations rename delete |
||||
*/ |
||||
|
||||
module.exports = { |
||||
before: function (browser: NightwatchBrowser, done: VoidFunction) { |
||||
done() |
||||
}, |
||||
after: function (browser: NightwatchBrowser) { |
||||
browser.perform((done) => { |
||||
console.log('kill server', gitserver.pid) |
||||
kill(gitserver.pid) |
||||
done() |
||||
}) |
||||
}, |
||||
|
||||
'run server #group1 #group2 #group3': function (browser: NightwatchBrowser) { |
||||
browser.perform(async (done) => { |
||||
gitserver = await spawnGitServer('/tmp/') |
||||
console.log('working directory', process.cwd()) |
||||
done() |
||||
}) |
||||
}, |
||||
|
||||
'clone a repo #group1 #group2 #group3': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.clickLaunchIcon('dgit') |
||||
.pause(5000) |
||||
.waitForElementVisible('*[data-id="cloneButton"]') |
||||
.click('*[data-id="cloneButton"]') |
||||
.pause(1000) |
||||
.waitForElementVisible('[data-id="fileSystemModalDialogModalBody-react"]') |
||||
.click('[data-id="fileSystemModalDialogModalBody-react"]') |
||||
.waitForElementVisible('[data-id="modalDialogCustomPromptTextClone"]') |
||||
.setValue('*[data-id="modalDialogCustomPromptTextClone"]', 'http://localhost:6868/bare.git') |
||||
.click('[data-id="fileSystem-modal-footer-ok-react"]') |
||||
.pause(5000) |
||||
.windowHandles(function (result) { |
||||
console.log(result.value) |
||||
browser.switchWindow(result.value[1]) |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItem.git"]') |
||||
}) |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItemREADME.md"]') |
||||
}, |
||||
'Update settings for git #group1 #group2 #group3': function (browser: NightwatchBrowser) { |
||||
browser. |
||||
clickLaunchIcon('dgit') |
||||
.setValue('*[data-id="gitubUsername"]', 'git') |
||||
.setValue('*[data-id="githubEmail"]', 'git@example.com') |
||||
.click('*[data-id="saveGitHubCredentials"]') |
||||
.modalFooterOKClick('github-credentials-error') |
||||
|
||||
}, |
||||
|
||||
// GROUP 1
|
||||
|
||||
'check file added #group1 #group3': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.addFile('test.txt', { content: 'hello world' }, 'README.md') |
||||
.clickLaunchIcon('dgit') |
||||
.pause(1000) |
||||
.waitForElementVisible({ |
||||
selector: "//*[@data-status='new-untracked' and @data-file='/test.txt']", |
||||
locateStrategy: 'xpath' |
||||
}) |
||||
.waitForElementVisible('*[data-id="addToGitChangestest.txt"]') |
||||
.pause(1000) |
||||
.click('*[data-id="addToGitChangestest.txt"]') |
||||
.waitForElementVisible({ |
||||
selector: "//*[@data-status='added-staged' and @data-file='/test.txt']", |
||||
locateStrategy: 'xpath' |
||||
}) |
||||
.setValue('*[data-id="commitMessage"]', 'testcommit') |
||||
.click('*[data-id="commitButton"]') |
||||
}, |
||||
'look at the commit #group1': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.click('*[data-id="commits-panel"]') |
||||
.waitForElementPresent({ |
||||
selector: '//*[@data-id="commit-summary-testcommit-ahead"]', |
||||
locateStrategy: 'xpath' |
||||
}) |
||||
}, |
||||
'sync the commit #group1': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.pause(1000) |
||||
.waitForElementVisible('*[data-id="sourcecontrol-panel"]') |
||||
.click('*[data-id="sourcecontrol-panel"]') |
||||
|
||||
.waitForElementVisible('*[data-id="syncButton"]') |
||||
.click('*[data-id="syncButton"]') |
||||
.pause(2000) |
||||
.waitForElementVisible('*[data-id="commitButton"]') |
||||
.click('*[data-id="commits-panel"]') |
||||
.waitForElementPresent({ |
||||
selector: '//*[@data-id="commit-summary-testcommit-"]', |
||||
locateStrategy: 'xpath' |
||||
}) |
||||
}, |
||||
'check the log #group1': async function (browser: NightwatchBrowser) { |
||||
const logs = await getGitLog('/tmp/git/bare.git') |
||||
console.log(logs) |
||||
browser.assert.ok(logs.includes('testcommit')) |
||||
}, |
||||
'change a file #group1': function (browser: NightwatchBrowser) { |
||||
browser. |
||||
openFile('test.txt'). |
||||
pause(1000). |
||||
setEditorValue('changes', null) |
||||
}, |
||||
'stage changed file #group1': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.clickLaunchIcon('dgit') |
||||
.click('*[data-id="sourcecontrol-panel"]') |
||||
.waitForElementVisible({ |
||||
selector: "//*[@data-status='modified-unstaged' and @data-file='/test.txt']", |
||||
locateStrategy: 'xpath' |
||||
}) |
||||
.waitForElementVisible('*[data-id="addToGitChangestest.txt"]') |
||||
.click('*[data-id="addToGitChangestest.txt"]') |
||||
.waitForElementVisible({ |
||||
selector: "//*[@data-status='modified-staged' and @data-file='/test.txt']", |
||||
locateStrategy: 'xpath' |
||||
}) |
||||
.setValue('*[data-id="commitMessage"]', 'testcommit2') |
||||
.click('*[data-id="commitButton"]') |
||||
}, |
||||
'push the commit #group1': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.click('*[data-id="commands-panel"]') |
||||
.waitForElementVisible('*[data-id="sourcecontrol-push"]') |
||||
.click('*[data-id="sourcecontrol-push"]') |
||||
.pause(2000) |
||||
.click('*[data-id="commits-panel"]') |
||||
.waitForElementPresent({ |
||||
selector: '//*[@data-id="commit-summary-testcommit2-"]', |
||||
locateStrategy: 'xpath' |
||||
}).pause(2000) |
||||
}, |
||||
'check the log for testcommit2 #group1': async function (browser: NightwatchBrowser) { |
||||
const logs = await getGitLog('/tmp/git/bare.git') |
||||
console.log(logs) |
||||
browser.assert.ok(logs.includes('testcommit2')) |
||||
}, |
||||
'clone locally and add a file and push #group1': async function (browser: NightwatchBrowser) { |
||||
await cloneOnServer('http://localhost:6868/bare.git', '/tmp/') |
||||
await onLocalGitRepoAddFile('/tmp/bare/', 'test2.txt') |
||||
await createCommitOnLocalServer('/tmp/bare/', 'testlocal') |
||||
await onLocalGitRepoPush('/tmp/bare/', 'master') |
||||
}, |
||||
'run a git fetch #group1': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.pause(2000) |
||||
.click('*[data-id="commands-panel"]') |
||||
.waitForElementVisible('*[data-id="sourcecontrol-fetch-branch"]') |
||||
|
||||
.click('*[data-id="sourcecontrol-fetch-branch"]') |
||||
.pause(2000) |
||||
.click('*[data-id="commits-panel"]') |
||||
.waitForElementVisible('*[data-id="commits-panel-behind"]') |
||||
.click('*[data-id="commits-panel-behind"]') |
||||
.waitForElementPresent({ |
||||
selector: '//*[@data-id="commit-summary-testlocal-"]', |
||||
locateStrategy: 'xpath' |
||||
}) |
||||
}, |
||||
'run pull from the header #group1': function (browser: NightwatchBrowser) { |
||||
browser. |
||||
click('*[data-id="sourcecontrol-button-pull"]') |
||||
.waitForElementNotPresent('*[data-id="commits-panel-behind"]') |
||||
}, |
||||
'check if the file is added #group1': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.clickLaunchIcon('filePanel') |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItemtest2.txt"]') |
||||
}, |
||||
} |
||||
|
@ -0,0 +1,164 @@ |
||||
import { ChildProcess, spawn } from "child_process" |
||||
import kill from 'tree-kill' |
||||
import { Nightwatch, NightwatchBrowser } from "nightwatch" |
||||
import { spawnGitServer, getGitLog, cloneOnServer, onLocalGitRepoAddFile, createCommitOnLocalServer, onLocalGitRepoPush, getBranches } from "../../lib/git" |
||||
let gitserver: ChildProcess |
||||
|
||||
/* |
||||
/ uses the git-http-backend package to create a git server ( if needed kill the server: kill -9 $(sudo lsof -t -i:6868) ) |
||||
/ GROUP 1: file operations PUSH PULL COMMIT SYNC FETCH CLONE ADD |
||||
/ GROUP 2: branch operations CREATE & PUBLISH |
||||
/ GROUP 3: file operations rename delete |
||||
*/ |
||||
|
||||
module.exports = { |
||||
before: function (browser: NightwatchBrowser, done: VoidFunction) { |
||||
done() |
||||
}, |
||||
after: function (browser: NightwatchBrowser) { |
||||
browser.perform((done) => { |
||||
console.log('kill server', gitserver.pid) |
||||
kill(gitserver.pid) |
||||
done() |
||||
}) |
||||
}, |
||||
|
||||
'run server #group1 #group2 #group3': function (browser: NightwatchBrowser) { |
||||
browser.perform(async (done) => { |
||||
gitserver = await spawnGitServer('/tmp/') |
||||
console.log('working directory', process.cwd()) |
||||
done() |
||||
}) |
||||
}, |
||||
|
||||
'clone a repo #group1 #group2 #group3': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.clickLaunchIcon('dgit') |
||||
.pause(5000) |
||||
.waitForElementVisible('*[data-id="cloneButton"]') |
||||
.click('*[data-id="cloneButton"]') |
||||
.pause(1000) |
||||
.waitForElementVisible('[data-id="fileSystemModalDialogModalBody-react"]') |
||||
.click('[data-id="fileSystemModalDialogModalBody-react"]') |
||||
.waitForElementVisible('[data-id="modalDialogCustomPromptTextClone"]') |
||||
.setValue('*[data-id="modalDialogCustomPromptTextClone"]', 'http://localhost:6868/bare.git') |
||||
.click('[data-id="fileSystem-modal-footer-ok-react"]') |
||||
.pause(5000) |
||||
.windowHandles(function (result) { |
||||
console.log(result.value) |
||||
browser.switchWindow(result.value[1]) |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItem.git"]') |
||||
}) |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItemREADME.md"]') |
||||
}, |
||||
'Update settings for git #group1 #group2 #group3': function (browser: NightwatchBrowser) { |
||||
browser. |
||||
clickLaunchIcon('dgit') |
||||
.setValue('*[data-id="gitubUsername"]', 'git') |
||||
.setValue('*[data-id="githubEmail"]', 'git@example.com') |
||||
.click('*[data-id="saveGitHubCredentials"]') |
||||
.modalFooterOKClick('github-credentials-error') |
||||
|
||||
}, |
||||
|
||||
// GROUP 2
|
||||
'create a branch #group2': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.click('*[data-id="branches-panel"]') |
||||
.waitForElementVisible('*[data-id="newbranchname"]') |
||||
.setValue('*[data-id="newbranchname"]', 'testbranch') |
||||
.click('*[data-id="sourcecontrol-create-branch"]') |
||||
.waitForElementVisible('*[data-id="branches-current-branch-testbranch"]') |
||||
.pause(1000) |
||||
}, |
||||
'check if the branch is in the filePanel #group2': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.clickLaunchIcon('filePanel') |
||||
.click('[data-id="workspaceGitBranchesDropdown"]') |
||||
.expect.element('[data-id="workspaceGit-testbranch"]').text.to.contain('✓ ') |
||||
}, |
||||
'publish the branch #group2': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.clickLaunchIcon('dgit') |
||||
.waitForElementVisible('*[data-id="sourcecontrol-panel"]') |
||||
.click('*[data-id="sourcecontrol-panel"]') |
||||
.pause(1000) |
||||
.click('*[data-id="publishBranchButton"]') |
||||
.pause(2000) |
||||
.waitForElementNotVisible('*[data-id="publishBranchButton"]') |
||||
}, |
||||
'check if the branch is published #group2': async function (browser: NightwatchBrowser) { |
||||
const branches = await getBranches('/tmp/git/bare.git') |
||||
browser.assert.ok(branches.includes('testbranch')) |
||||
}, |
||||
'add file to new branch #group2': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.pause(1000) |
||||
.addFile('test.txt', { content: 'hello world' }, 'README.md') |
||||
.clickLaunchIcon('dgit') |
||||
.pause(2000) |
||||
.waitForElementVisible({ |
||||
selector: "//*[@data-status='new-untracked' and @data-file='/test.txt']", |
||||
locateStrategy: 'xpath' |
||||
}) |
||||
.waitForElementVisible('*[data-id="addToGitChangestest.txt"]') |
||||
.pause(1000) |
||||
.click('*[data-id="addToGitChangestest.txt"]') |
||||
.waitForElementVisible({ |
||||
selector: "//*[@data-status='added-staged' and @data-file='/test.txt']", |
||||
locateStrategy: 'xpath' |
||||
}) |
||||
.setValue('*[data-id="commitMessage"]', 'testcommit') |
||||
.click('*[data-id="commitButton"]') |
||||
.pause(1000) |
||||
}, |
||||
'check if the commit is ahead in the branches list #group2': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.waitForElementVisible('*[data-id="branches-panel"]') |
||||
.click('*[data-id="branches-panel"]') |
||||
.waitForElementVisible('*[data-id="branches-current-branch-testbranch"]') |
||||
.click({ |
||||
selector: "//*[@data-id='branches-panel-content']//*[@data-id='branches-current-branch-testbranch']", |
||||
locateStrategy: 'xpath', |
||||
suppressNotFoundErrors: true |
||||
}) |
||||
.click({ |
||||
selector: "//*[@data-id='branches-panel-content']//*[@data-id='commits-panel-ahead']", |
||||
locateStrategy: 'xpath', |
||||
suppressNotFoundErrors: true |
||||
}) |
||||
.click({ |
||||
selector: "//*[@data-id='branches-panel-content']//*[@data-id='branchdifference-commits-testbranch-ahead']//*[@data-id='commit-summary-testcommit-ahead']", |
||||
locateStrategy: 'xpath', |
||||
}) |
||||
.click({ |
||||
selector: "//*[@data-id='branches-panel-content']//*[@data-id='branchdifference-commits-testbranch-ahead']//*[@data-id='commit-change-added-test.txt']", |
||||
locateStrategy: 'xpath', |
||||
}) |
||||
.click({ |
||||
selector: "//*[@data-id='branches-panel-content']//*[@data-id='local-branch-commits-testbranch']//*[@data-id='commit-summary-testcommit-ahead']", |
||||
locateStrategy: 'xpath', |
||||
}) |
||||
.waitForElementVisible({ |
||||
selector: "//*[@data-id='branches-panel-content']//*[@data-id='local-branch-commits-testbranch']//*[@data-id='commit-change-added-test.txt']", |
||||
locateStrategy: 'xpath', |
||||
}) |
||||
}, |
||||
'switch back to master #group2': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.click({ |
||||
selector: "//*[@data-id='branches-panel-content']//*[@data-id='branches-toggle-branch-master']", |
||||
locateStrategy: 'xpath', |
||||
}) |
||||
.waitForElementVisible({ |
||||
selector: "//*[@data-id='branches-panel-content']//*[@data-id='branches-toggle-current-branch-master']", |
||||
locateStrategy: 'xpath', |
||||
}) |
||||
}, |
||||
'check if test file is gone #group2': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.clickLaunchIcon('filePanel') |
||||
.waitForElementNotPresent('*[data-id="treeViewLitreeViewItemtest.txt"]') |
||||
} |
||||
} |
||||
|
@ -0,0 +1,132 @@ |
||||
import { ChildProcess, spawn } from "child_process" |
||||
import kill from 'tree-kill' |
||||
import { Nightwatch, NightwatchBrowser } from "nightwatch" |
||||
import { spawnGitServer, getGitLog, cloneOnServer, onLocalGitRepoAddFile, createCommitOnLocalServer, onLocalGitRepoPush, getBranches } from "../../lib/git" |
||||
let gitserver: ChildProcess |
||||
|
||||
/* |
||||
/ uses the git-http-backend package to create a git server ( if needed kill the server: kill -9 $(sudo lsof -t -i:6868) ) |
||||
/ GROUP 1: file operations PUSH PULL COMMIT SYNC FETCH CLONE ADD |
||||
/ GROUP 2: branch operations CREATE & PUBLISH |
||||
/ GROUP 3: file operations rename delete |
||||
*/ |
||||
|
||||
module.exports = { |
||||
before: function (browser: NightwatchBrowser, done: VoidFunction) { |
||||
done() |
||||
}, |
||||
after: function (browser: NightwatchBrowser) { |
||||
browser.perform((done) => { |
||||
console.log('kill server', gitserver.pid) |
||||
kill(gitserver.pid) |
||||
done() |
||||
}) |
||||
}, |
||||
|
||||
'run server #group1 #group2 #group3': function (browser: NightwatchBrowser) { |
||||
browser.perform(async (done) => { |
||||
gitserver = await spawnGitServer('/tmp/') |
||||
console.log('working directory', process.cwd()) |
||||
done() |
||||
}) |
||||
}, |
||||
|
||||
'clone a repo #group1 #group2 #group3': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.clickLaunchIcon('dgit') |
||||
.pause(5000) |
||||
.waitForElementVisible('*[data-id="cloneButton"]') |
||||
.click('*[data-id="cloneButton"]') |
||||
.pause(1000) |
||||
.waitForElementVisible('[data-id="fileSystemModalDialogModalBody-react"]') |
||||
.click('[data-id="fileSystemModalDialogModalBody-react"]') |
||||
.waitForElementVisible('[data-id="modalDialogCustomPromptTextClone"]') |
||||
.setValue('*[data-id="modalDialogCustomPromptTextClone"]', 'http://localhost:6868/bare.git') |
||||
.click('[data-id="fileSystem-modal-footer-ok-react"]') |
||||
.pause(5000) |
||||
.windowHandles(function (result) { |
||||
console.log(result.value) |
||||
browser.switchWindow(result.value[1]) |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItem.git"]') |
||||
}) |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItemREADME.md"]') |
||||
}, |
||||
'Update settings for git #group1 #group2 #group3': function (browser: NightwatchBrowser) { |
||||
browser. |
||||
clickLaunchIcon('dgit') |
||||
.setValue('*[data-id="gitubUsername"]', 'git') |
||||
.setValue('*[data-id="githubEmail"]', 'git@example.com') |
||||
.click('*[data-id="saveGitHubCredentials"]') |
||||
.modalFooterOKClick('github-credentials-error') |
||||
|
||||
}, |
||||
|
||||
'check file added #group1 #group3': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.addFile('test.txt', { content: 'hello world' }, 'README.md') |
||||
.clickLaunchIcon('dgit') |
||||
.pause(1000) |
||||
.waitForElementVisible({ |
||||
selector: "//*[@data-status='new-untracked' and @data-file='/test.txt']", |
||||
locateStrategy: 'xpath' |
||||
}) |
||||
.waitForElementVisible('*[data-id="addToGitChangestest.txt"]') |
||||
.pause(1000) |
||||
.click('*[data-id="addToGitChangestest.txt"]') |
||||
.waitForElementVisible({ |
||||
selector: "//*[@data-status='added-staged' and @data-file='/test.txt']", |
||||
locateStrategy: 'xpath' |
||||
}) |
||||
.setValue('*[data-id="commitMessage"]', 'testcommit') |
||||
.click('*[data-id="commitButton"]') |
||||
}, |
||||
|
||||
// group 3
|
||||
'rename a file #group3': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.clickLaunchIcon('filePanel') |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItemtest.txt"]') |
||||
.click('*[data-id="treeViewLitreeViewItemtest.txt"]') |
||||
.renamePath('test.txt', 'test_rename', 'test_rename.txt') |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItemtest_rename.txt"]') |
||||
.pause(1000) |
||||
}, |
||||
'stage renamed file #group3': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.clickLaunchIcon('dgit') |
||||
.waitForElementVisible({ |
||||
selector: "//*[@data-status='deleted-unstaged' and @data-file='/test.txt']", |
||||
locateStrategy: 'xpath' |
||||
}) |
||||
.waitForElementVisible('*[data-id="addToGitChangestest.txt"]') |
||||
.waitForElementVisible({ |
||||
selector: "//*[@data-status='new-untracked' and @data-file='/test_rename.txt']", |
||||
locateStrategy: 'xpath' |
||||
}) |
||||
.click('*[data-id="sourcecontrol-add-all"]') |
||||
.waitForElementVisible({ |
||||
selector: "//*[@data-status='added-staged' and @data-file='/test_rename.txt']", |
||||
locateStrategy: 'xpath' |
||||
}) |
||||
}, |
||||
'undo the rename #group3': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.waitForElementVisible('*[data-id="unStageStagedtest_rename.txt"]') |
||||
.click('*[data-id="unStageStagedtest_rename.txt"]') |
||||
.pause(1000) |
||||
.click('*[data-id="unDoStagedtest.txt"]') |
||||
.pause(1000) |
||||
.waitForElementNotPresent({ |
||||
selector: "//*[@data-file='/test.txt']", |
||||
locateStrategy: 'xpath' |
||||
}) |
||||
}, |
||||
'check if file is returned #group3': function (browser: NightwatchBrowser) { |
||||
browser |
||||
.clickLaunchIcon('filePanel') |
||||
.waitForElementVisible('*[data-id="treeViewLitreeViewItemtest.txt"]') |
||||
}, |
||||
|
||||
|
||||
} |
||||
|
Loading…
Reference in new issue