Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Commit

Permalink
Started automated testing of codiad. This change uses selenium, webdr…
Browse files Browse the repository at this point in the history
…iverio and nodejs to do some functional test on codiad. I have written some basic test but will add more tests later.
  • Loading branch information
amshali committed Sep 23, 2015
1 parent 272f6fb commit 1b4df6b
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 108 deletions.
21 changes: 17 additions & 4 deletions .test-build-on-repo-change.yaml
Expand Up @@ -12,7 +12,8 @@ properties:
maxConcurrentPerNode: 0
disable: false
concurrentBuild: false
hasSlaveAffinity: false
hasSlaveAffinity: true
label: master
hasCustomQuietPeriod: false
quiet_period: 5
hasCustomScmCheckoutRetryCount: false
Expand All @@ -26,11 +27,23 @@ hasCustomWorkspace: false
builder:
command: apt-get update

apt-get install -y -qq --no-install-recommends make
apt-get install -y -qq --no-install-recommends make curl

cd ide-proxy
cd codiad && make && cd ..

make build
cd test

curl -sL https://deb.nodesource.com/setup_0.12 | bash -

apt-get update && apt-get install -y nodejs

curl -L https://npmjs.com/install.sh | sh

npm install -g mocha

npm install expect.js webdriverio

mocha *.spec.js

$class: !shell
$class: !freestyle
2 changes: 1 addition & 1 deletion codiad/third_party/term.js/package.json
Expand Up @@ -15,6 +15,6 @@
"devDependencies": {
"express": "4.13.1",
"socket.io": "1.3.5",
"pty.js": ">= 0.2.13"
"pty.js": "0.3.0"
}
}
2 changes: 1 addition & 1 deletion dev-common/Dockerfile
Expand Up @@ -75,7 +75,7 @@ RUN apt-get update && apt-get install -y nodejs && \
RUN curl -L https://npmjs.com/install.sh | sh

RUN npm install -g js-beautify uglify-js uglifycss firebase firebase-token-generator webdriverio \
chromedriver
mocha expect.js

# Adding git-appraise
ENV GOPATH /usr/local/
Expand Down
127 changes: 127 additions & 0 deletions test/codiad.spec.js
@@ -0,0 +1,127 @@
// Copyright 2015 Google Inc. All Rights Reserved.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

var webdriverio = require('webdriverio');
var expect = require('expect.js');
var assert = require('assert');
var fs = require('fs');
var spawnSync = require('child_process').spawnSync;

var options = {
host: 'localhost',
port: 4444,
desiredCapabilities: {
browserName: 'firefox'
}
};

var CODIAD_PORT = 10000;
var CODIAD = 'http://localhost:' + CODIAD_PORT;
var CODIAD_WS = '/tmp/ide-ws';
var WAIT_FOR_VISIBLE_MS = 10000;

describe('Codiad Tests', function(){

this.timeout(120000); // 2 minutes
var client = {};
var seleniumId;
var codiadId;

before(function(done) {
var output = spawnSync('docker',
['run', '--net', 'host', '-d', '-P', 'selenium/standalone-firefox']);
seleniumId = output.stdout.toString('utf8').trim();
output = spawnSync('docker', ['run', '-e', 'USER_EMAIL=youremail@company.com', '--privileged',
'-d', '-v', CODIAD_WS + ':/usr/share/nginx/www/_', '-p',
CODIAD_PORT + ':8080', 'google/codiad']);
codiadId = output.stdout.toString('utf8').trim();
client = webdriverio.remote(options);
client.init(done);
});

// Make sure codiad loads:
it('Codiad Loaded',function(done) {
client.pause(10000).url(CODIAD).
waitForVisible('div#file-manager', WAIT_FOR_VISIBLE_MS).
getTitle(function(err, title) {
assert(err === undefined);
assert(title === 'Codiad');
}).
call(done);
});

// Make sure terminal appears:
it('Codiad Terminal',function(done) {
client.url(CODIAD).
click('span.content-closed div.terminal-toggler').
waitForVisible('#terminal-pane', WAIT_FOR_VISIBLE_MS).
waitForVisible('div.terminal', WAIT_FOR_VISIBLE_MS).
getText('div.terminal').
then(function(text) {
expect(text).to.contain("root's home directory is '/workspace/'.");
}).
call(done);
});

// Make sure settings dialog shows up:
it('Codiad Settings',function(done) {
client.url(CODIAD).
click('div#settings-icon').
waitForVisible('.settings-view', WAIT_FOR_VISIBLE_MS).
getText('table.settings').
then(function(text) {
expect(text).to.contain("Line Numbers");
}).
call(done);
});

// Create a file:
it('Create File',function(done) {
client.url(CODIAD).
rightClick('a#project-root').
waitForVisible('div#context-menu', WAIT_FOR_VISIBLE_MS).
click('=New File').
waitForVisible('div#modal-content', WAIT_FOR_VISIBLE_MS).
setValue('form.codiad-form input[name="object_name"]', 'file.md').
click('button*=Create').
getText('a.file').
then(function(value) {
expect(value).to.contain("file.md");
}).
call(done);
});

// Delete the created file:
it('Delete File',function(done) {
client.url(CODIAD).
rightClick('a*=file.md').
waitForVisible('div#context-menu', WAIT_FOR_VISIBLE_MS).
click('=Delete').
waitForVisible('div#modal-content', WAIT_FOR_VISIBLE_MS).
click('button*=Delete').
getText('div#file-manager').
then(function(value) {
expect(value).to.not.contain("file.md");
}).
call(done);
});

after(function(done) {
client.end(done).then(function() {
fs.unlink(CODIAD_WS + '/workspace/cloud-project/file.md', function(){});
spawnSync('docker', ['stop', codiadId]);
spawnSync('docker', ['stop', seleniumId]);
});
});
});
23 changes: 8 additions & 15 deletions test/package.json
@@ -1,19 +1,12 @@
{
"name": "Codiad Tests",
"name": "codiadTests",
"description": "Set of functional test cases for codiad.",
"author": "Amin Shali",
"version": "0.0.1",
"main": "./index.js",
"preferGlobal": false,
"repository": "git://github.com/chjj/term.js.git",
"homepage": "https://github.com/chjj/term.js",
"bugs": { "url": "https://github.com/chjj/term.js/issues" },
"keywords": ["tty", "terminal", "term", "xterm"],
"tags": ["tty", "terminal", "term", "xterm"],
"engines": { "node": ">= 0.10.0" },
"devDependencies": {
"express": "4.13.1",
"socket.io": "1.3.5",
"pty.js": ">= 0.2.13"
"scripts": {
"test": "mocha *.spec.js"
},
"dependencies": {
"expect.js": "0.3.1",
"mocha": "2.3.3",
"webdriverio": "^3.2.4"
}
}
Binary file removed test/screenshot.png
Binary file not shown.
19 changes: 0 additions & 19 deletions test/specs/run-codiad.spec.js

This file was deleted.

68 changes: 0 additions & 68 deletions test/test.js

This file was deleted.

0 comments on commit 1b4df6b

Please sign in to comment.