added nightwatch web tests

This commit is contained in:
Steven Hugg 2019-08-31 15:36:50 -04:00
parent 187bcfc2e2
commit f3138f9b57
9 changed files with 1059 additions and 28 deletions

1
.gitignore vendored
View File

@ -5,4 +5,5 @@ local
release
gen
test/output
tests_output/
.DS_Store

View File

@ -23,12 +23,12 @@ lint:
web:
ifconfig | grep inet
python3 scripts/serveit.py 2>> http.out
python3 scripts/serveit.py 2>> /dev/null #http.out
tsweb:
ifconfig | grep inet
$(TSC) -w &
python3 scripts/serveit.py 2>> http.out
python3 scripts/serveit.py 2>> /dev/null #http.out
astrolibre.b64.txt: astrolibre.rom
lzg -9 $< | base64 -w 0 > $@

23
nightwatch.json Normal file
View File

@ -0,0 +1,23 @@
{
"src_folders" : ["test/web"],
"webdriver" : {
"start_process": true,
"server_path": "node_modules/.bin/chromedriver",
"port": 9515
},
"test_settings" : {
"default" : {
"desiredCapabilities": {
"browserName": "chrome"
},
"screenshots" : {
"enabled" : "true",
"path" : "",
"on_failure": true,
"on_error": true
}
}
}
}

937
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -15,11 +15,13 @@
"@types/jquery": "^3.3.29",
"atob": "^2.1.x",
"btoa": "^1.2.x",
"chromedriver": "^76.0.1",
"clipboard": "^2.0.4",
"jquery": "^3.4.1",
"jsdom": "^12.2.0",
"lzg": "^1.0.x",
"mocha": "^5.2.x",
"nightwatch": "^1.2.1",
"octokat": "^0.10.0",
"pngjs": "^3.3.3",
"typescript": "^3.6.2",
@ -36,6 +38,7 @@
"test": "npm run test-node",
"test-one": "NODE_PATH=$(pwd) mocha --recursive --timeout 60000",
"test-node": "NODE_PATH=$(pwd) mocha --recursive --timeout 60000 test/cli",
"test-web": "NODE_PATH=$(pwd) nightwatch test/web",
"test-worker": "NODE_PATH=$(pwd) mocha --recursive --timeout 60000 test/cli/testworker.js",
"test-platforms": "NODE_PATH=$(pwd) mocha --recursive --timeout 60000 test/cli/testplatforms.js",
"test-profile": "NODE_PATH=$(pwd) mocha --recursive --timeout 60000 --prof test/cli"

View File

@ -173,6 +173,7 @@ function refreshWindowList() {
var a = document.createElement("a");
a.setAttribute("class", "dropdown-item");
a.setAttribute("href", "#");
a.setAttribute("data-wndid", id);
if (id == projectWindows.getActiveID())
$(a).addClass("dropdown-item-checked");
a.appendChild(document.createTextNode(name));

View File

@ -1,26 +0,0 @@
function assert(b, msg) {
if (!b) { throw new Error(msg); }
}
describe('Test VCS emulator', function() {
var platform = new VCSPlatform();
it('Should start', function(done) {
platform.start();
assert(!platform.isRunning());
// TODO: more testing
done();
});
});
describe('Test Space Invaders emulator', function() {
var platform = new Midway8080BWPlatform($('#emulator')[0]);
it('Should start', function(done) {
platform.start();
assert(!platform.isRunning());
platform.resume();
assert(platform.isRunning());
// TODO: more testing
done();
});
});

View File

@ -0,0 +1,91 @@
//var IDEURL = 'https://8bitworkshop.com/dev/';
var IDEURL = 'http://localhost:8000/';
function testCompile(browser, platform_id, platform_name) {
// wait for page to load
browser
.waitForElementVisible('body')
.waitForElementVisible('#booksMenuButton')
.waitForElementVisible('#preset_select')
.assert.containsText('#platformsMenuButton', platform_name)
.waitForElementNotVisible('#compile_spinner')
.waitForElementNotVisible('#error_alert')
.waitForElementNotPresent('.bootbox-alert');
if (platform_id == 'vcs') {
browser.waitForElementVisible('#javatari-screen');
} else {
browser.waitForElementVisible('#emuscreen');
browser.waitForElementVisible('.emuvideo');
browser.waitForElementVisible('a[data-wndid="#memmap"]');
}
}
function testDebugging(browser) {
// do some debugging
browser
.waitForElementVisible('#dbg_go.btn_active')
.click('#dbg_step')
.waitForElementVisible('#dbg_step.btn_stopped')
.waitForElementVisible('#mem_info')
.click('#dbg_reset')
.waitForElementVisible('#dbg_reset.btn_stopped')
.waitForElementVisible('#mem_info')
.click('#dbg_tovsync')
.waitForElementVisible('#dbg_tovsync.btn_stopped')
.waitForElementVisible('#mem_info')
.click('#dbg_go')
.waitForElementVisible('#dbg_go.btn_active')
.waitForElementNotVisible('#mem_info');
/*
.click('a[data-wndid="#disasm"]')
.click('a[data-wndid="#memory"]')
.click('a[data-wndid="#memmap"]')
*/
}
function testTourDialog(browser) {
// tour dialog dismiss
browser
.waitForElementVisible('#step-0')
.click('button[data-role="end"]');
}
function testPlatform(exports, platform_id, platform_name, numPresets) {
exports['load_'+platform_id] = function(browser) {
browser.url(IDEURL + '?platform='+platform_id+"&file=NOEXIST");
browser.waitForElementVisible('.bootbox-alert'); // test unknown file alert (TODO: check text)
browser.waitForElementNotVisible('#error_alert'); // but it will build anyway
testTourDialog(browser);
}
for (let i=1; i<=numPresets; i++) {
exports['load_'+platform_id+'_'+i] = function(browser) {
browser.click('#preset_select option:nth-child('+(i+1)+')');
testCompile(browser, platform_id, platform_name);
browser.getTitle( (title) => { console.log(title); } );
testDebugging(browser);
}
}
exports['end_'+platform_id] = function(browser) {
browser.end();
}
}
///
testPlatform(this, 'vcs', 'Atari 2600', 35);
testPlatform(this, 'nes', 'NES', 30);
testPlatform(this, 'vicdual', 'VIC Dual', 7);
testPlatform(this, 'mw8080bw', 'Midway 8080', 3);
testPlatform(this, 'galaxian-scramble', 'Galaxian/Scramble', 3);
testPlatform(this, 'vector-z80color', 'Atari Color Vector (Z80)', 3);
testPlatform(this, 'williams-z80', 'Williams (Z80)', 3);
// TODO testPlatform(this, 'sound_williams-z80', 'Williams Sound (Z80)', 1);
testPlatform(this, 'coleco', 'ColecoVision', 12);
testPlatform(this, 'sms-sg1000-libcv', 'Sega SG-1000', 3);
testPlatform(this, 'sms-sms-libcv', 'Sega Master System', 2);
testPlatform(this, 'atari7800', 'Atari 7800', 1);
testPlatform(this, 'astrocade', 'Bally Astrocade', 12);
testPlatform(this, 'apple2', 'Apple ][+', 10);

View File

@ -17,6 +17,7 @@
},
"include": [
"./src/**/*.ts",
"./test/**/*.ts",
"./localForage/typings/*.ts"
]
}