diff --git a/Rakefile b/Rakefile index e93735f5..e6e8bc45 100644 --- a/Rakefile +++ b/Rakefile @@ -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 diff --git a/TODO.md b/TODO.md index d6986479..1319646b 100644 --- a/TODO.md +++ b/TODO.md @@ -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 \ No newline at end of file +* select and drop multiple tables in left bar +* Rewrite dialogs (replace alertify) diff --git a/build_files/build.sh b/build_files/build.sh deleted file mode 100755 index 8806fe8c..00000000 --- a/build_files/build.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash - -echo "This script requires nwjs.app in your applications folder" - -TARGET_DIR="${HOME}/Postbird.app" -APP_TARGET_DIR="${TARGET_DIR}/Contents/Resources/app.nw" -echo $TARGET_DIR - - -if [ -e "$TARGET_DIR" ]; then - echo "Removing existing build" - rm -rf $TARGET_DIR -fi - -if [ -e "$HOME/postbird.nw" ]; then - echo "Removing existing nw build" - rm -rf $HOME/Postbird.nw -fi - -#read -p "Is nwjs.app in your applications folder (y/n)? " -n 1 -r -#if [[ $REPLY =~ ^[Yy]$ ]] -#then - # node-webkit exists continue build - cp -r /Applications/nwjs.app ${TARGET_DIR} - - # create app.nw and move to correct location - git checkout-index -a --prefix="${APP_TARGET_DIR}/" - #cp -r . ~/postbird.app/Contents/Resources/app.nw - - rm ${APP_TARGET_DIR}/run - rm ${APP_TARGET_DIR}/run_tests - rm -rf ${APP_TARGET_DIR}/build_files - rm -rf ${APP_TARGET_DIR}/node_modules/fibers - rm -rf ${APP_TARGET_DIR}/node_modules/grunt - rm -rf ${APP_TARGET_DIR}/node_modules/grunt-node-webkit-builder - rm -rf ${APP_TARGET_DIR}/tests - rm -rf ${APP_TARGET_DIR}/sugar - rm -rf ${APP_TARGET_DIR}/integration_tests - rm -rf ${APP_TARGET_DIR}/vendor/datasets - rm -rf ${APP_TARGET_DIR}/vendor/win32 - rm -rf ${APP_TARGET_DIR}/vendor/linux - - # copy icon and plist file - cp ./build_files/icon.icns ${TARGET_DIR}/Contents/Resources - cp ./build_files/info.plist ${TARGET_DIR}/Contents - cp ./build_files/Credits.html ${TARGET_DIR}/Contents/Resources - - echo -e "\nPostbird.app copied to home directory" - tmp_dir=`pwd` - cd ${APP_TARGET_DIR} - zip -r -q ~/Postbird.nw * - cd $tmp_dir -#else -# echo -e "\nPlease place nwjs.app in your applications folder and run the script again" -#fi \ No newline at end of file diff --git a/integration_tests/integration.js b/integration_tests/integration.js index 22976392..234c3822 100644 --- a/integration_tests/integration.js +++ b/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) @@ -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(); }) @@ -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'); @@ -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./) + }) }) \ No newline at end of file diff --git a/run b/run index 65b06cd1..0e41dabd 100755 --- a/run +++ b/run @@ -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 . $@ diff --git a/run_tests b/run_tests deleted file mode 100755 index 69b01d44..00000000 --- a/run_tests +++ /dev/null @@ -1,4 +0,0 @@ -#/Applications/nwjs.app/Contents/MacOS/nwjs ./tests "$@" -BASEDIR=$(dirname $0) -#/Applications/node-webkit.app/Contents/MacOS/node-webkit $BASEDIR/tests "$@" -cd $BASEDIR/tests && ../node_modules/.bin/electron . "$@" \ No newline at end of file diff --git a/tests/assert_extras.js b/tests/assert_extras.js new file mode 100644 index 00000000..f27af79a --- /dev/null +++ b/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; \ No newline at end of file diff --git a/tests/test_helper.js b/tests/test_helper.js index a00323fa..08809cd6 100644 --- a/tests/test_helper.js +++ b/tests/test_helper.js @@ -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');