Skip to content

Commit

Permalink
Few more integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Paxa committed Oct 16, 2017
1 parent 96eb82d commit 3fd5215
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 128 deletions.
3 changes: 0 additions & 3 deletions Rakefile
Expand Up @@ -49,12 +49,9 @@ end
desc "Rebuild npm native extensions for electron"
task :rebuild_ext do
if RUBY_PLATFORM =~ /darwin/
#system "rm -rf node_modules/fibers/bin/darwin-x64-v8-5.1"
system "PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin ./node_modules/.bin/electron-rebuild -n 54"
#system "mv node_modules/fibers/bin/darwin-x64-v8-5.0 node_modules/fibers/bin/darwin-x64-v8-5.1"
else
system "./node_modules/.bin/electron-rebuild -n 54"
#system "mv node_modules/fibers/bin/linux-x64-v8-5.0 node_modules/fibers/bin/linux-x64-v8-5.1"
end
end

Expand Down
3 changes: 2 additions & 1 deletion TODO.md
Expand Up @@ -10,4 +10,5 @@ My todo:
* Syntax highlight for json and xml fields

* check indisvalid in list of indexes (indisvalid means index created with errors, there is record but no index actually)
* select and drop multiple tables in left bar
* select and drop multiple tables in left bar
* Rewrite dialogs (replace alertify)
55 changes: 0 additions & 55 deletions build_files/build.sh

This file was deleted.

49 changes: 42 additions & 7 deletions integration_tests/integration.js
@@ -1,5 +1,9 @@
var Application = require('spectron').Application
var assert = require('assert')
var Application = require('spectron').Application;
global.assert = require('../tests/assert_extras');

function sleep (ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

describe('application launch', function () {
this.timeout(10000)
Expand All @@ -23,16 +27,13 @@ describe('application launch', function () {

app.client.getRenderProcessLogs().then(logs => {
logs.forEach(log => {
console.log(log.message)
console.log(log.source)
console.log(log.level)
console.log(`${log.level} ${log.message} -> ${log.source}`);
})
})

return client.execute(() => {
try {
var connection = Connection.instances[0];
console.log(['connection', typeof connection, connection]);
return connection.query("drop schema public cascade; create schema public;").then(() => {
return App.tabs[0].instance.fetchTablesAndSchemas();
})
Expand Down Expand Up @@ -61,7 +62,7 @@ describe('application launch', function () {
assert.equal(count, 1);
})

it('should show new table dialog', async () => {
it('should create new table dialog', async () => {
await client.waitForValue('.sidebar .databases select', 5000);

client.click('a.addTable');
Expand All @@ -81,4 +82,38 @@ describe('application launch', function () {

await client.waitForVisible('.tables li[table-name="test_table"]')
})

it.only('should install and uninstall extension', async () => {
await client.waitForValue('.sidebar .databases select', 5000);

client.click('[tab="extensions"]');

await client.waitForVisible('.window-content.extensions button');
client.click('.window-content.extensions button');

await client.waitForVisible('#alertify-ok');
client.click('#alertify-ok');

await client.waitForVisible('.alertify-alert');
var text = await client.getText('.alertify-alert');

assert.match(text, /Extension .+ successfully installed./)

client.click('#alertify-ok');

await client.waitForVisible('.window-content.extensions button[exec^=uninstall]');
client.click('.window-content.extensions button[exec^=uninstall]');

await sleep(100);

await client.waitForVisible('#alertify-ok');
client.click('#alertify-ok');

//await sleep(200);

await client.waitForVisible('.alertify-alert .alertify-message');
var uninstallText = await client.getText('.alertify-alert .alertify-message');

assert.match(uninstallText, /Extension .* uninstalled./)
})
})
42 changes: 1 addition & 41 deletions run
Expand Up @@ -4,44 +4,4 @@ export NW_DEV=true
export NW_DEBUG=true
export PATH=$PATH:node_modules/.bin

if [[ "$OSTYPE" == "darwin"* ]]; then
#/Applications/node-webkit.app/Contents/MacOS/node-webkit .
#/Applications/nwjs.app/Contents/MacOS/nwjs .
#~/Postbird.app/Contents/MacOS/nwjs
electron . $@
elif [[ "$OSTYPE" == "linux-gnu" ]]; then
paths=(
"/lib/x86_64-linux-gnu/libudev.so.1" # Ubuntu, Xubuntu, Mint
"/usr/lib64/libudev.so.1" # SUSE, Fedora
"/usr/lib/libudev.so.1" # Arch, Fedora 32bit
"/lib/i386-linux-gnu/libudev.so.1" # Ubuntu 32bit
)
for i in "${paths[@]}"
do
if [ -f $i ]
then
ln -sf "$i" ./libudev.so.0
break
fi
done

BASEDIR=$(dirname $0)
export LD_LIBRARY_PATH=$BASEDIR:$LD_LIBRARY_PATH
echo $LD_LIBRARY_PATH
~/Downloads/node-webkit-v0.11.6-linux-x64/nw .
#elif [[ "$OSTYPE" == "cygwin" ]]; then
# # POSIX compatibility layer and Linux environment emulation for Windows
#elif [[ "$OSTYPE" == "msys" ]]; then
# # Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
#elif [[ "$OSTYPE" == "win32" ]]; then
# # I'm not sure this can happen.
#elif [[ "$OSTYPE" == "freebsd"* ]]; then
# # ...
#else
# # Unknown.
fi





electron . $@
4 changes: 0 additions & 4 deletions run_tests

This file was deleted.

19 changes: 19 additions & 0 deletions tests/assert_extras.js
@@ -0,0 +1,19 @@
var assert = require('assert');

assert.true = (value) => {
return assert(value);
}

assert.false = (value) => {
return assert.equal(value, false);
}

assert.match = (value, regex) => {
return assert(regex.test(value), `Value ${value} should match ${regex}`);
}

assert.contain = (string, value) => {
return assert(string.includes(value), `Value ${string} should include ${value}`);
}

module.exports = assert;
18 changes: 1 addition & 17 deletions tests/test_helper.js
Expand Up @@ -8,23 +8,7 @@ require('../app');
require('../lib/jquery.class');
require('../app/connection');

global.assert = require('assert');

assert.true = (value) => {
return assert(value);
}

assert.false = (value) => {
return assert.equal(value, false);
}

assert.match = (value, regex) => {
return assert(regex.test(value), `Value ${value} should match ${regex}`);
}

assert.contain = (string, value) => {
return assert(string.includes(value), `Value ${string} should include ${value}`);
}
global.assert = require('./assert_extras');

global.Model = require('../app/models/all');

Expand Down

0 comments on commit 3fd5215

Please sign in to comment.