mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-04 20:05:57 +00:00
added testimport.js, fixed repo= qs handling
This commit is contained in:
parent
8e8a65d44b
commit
f73e1dbf66
14
.gitignore
vendored
14
.gitignore
vendored
@ -1,13 +1,13 @@
|
||||
*~
|
||||
node_modules
|
||||
local/
|
||||
tests_output/
|
||||
test/output/
|
||||
./local/
|
||||
./tests_output/
|
||||
./test/output/
|
||||
.DS_Store
|
||||
tmp/
|
||||
web/
|
||||
release/
|
||||
gen/
|
||||
./tmp/
|
||||
./web/
|
||||
./release/
|
||||
./gen/
|
||||
config.js
|
||||
chromedriver.log
|
||||
nightwatch.conf.js
|
||||
|
3488
package-lock.json
generated
3488
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -52,7 +52,7 @@
|
||||
"chromedriver": "^97.0.1",
|
||||
"heapdump": "^0.3.15",
|
||||
"jsfuzz": "^1.0.14",
|
||||
"nightwatch": "^1.7.13",
|
||||
"nightwatch": "^2.0.5",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rgbquant": "^1.1.2",
|
||||
"typedoc": "^0.22.11"
|
||||
|
@ -187,8 +187,8 @@ class UserPrefs {
|
||||
getLastPlatformID() {
|
||||
return hasLocalStorage && !isEmbed && localStorage.getItem("__lastplatform");
|
||||
}
|
||||
getLastRepoID() {
|
||||
return hasLocalStorage && !isEmbed && localStorage.getItem("__lastrepo_" + platform_id);
|
||||
getLastRepoID(platform: string) {
|
||||
return hasLocalStorage && !isEmbed && platform && localStorage.getItem("__lastrepo_" + platform);
|
||||
}
|
||||
shouldCompleteTour() {
|
||||
return hasLocalStorage && !isEmbed && !localStorage.getItem("8bitworkshop.hello");
|
||||
@ -2372,20 +2372,25 @@ function setPlatformUI() {
|
||||
}
|
||||
|
||||
export function getPlatformAndRepo() {
|
||||
// lookup repository for this platform
|
||||
repo_id = qs.repo || userPrefs.getLastRepoID();
|
||||
// lookup repository for this platform (TODO: enable cross-platform repos)
|
||||
platform_id = qs.platform || userPrefs.getLastPlatformID();
|
||||
repo_id = qs.repo;
|
||||
// only look at cached repo_id if file= is not present, so back button works
|
||||
if (!qs.repo && !qs.file)
|
||||
repo_id = userPrefs.getLastRepoID(platform_id);
|
||||
// are we in a repo?
|
||||
if (hasLocalStorage && repo_id && repo_id !== '/') {
|
||||
var repo = getRepos()[repo_id];
|
||||
// override query string params w/ repo settings
|
||||
if (repo) {
|
||||
qs.repo = repo_id;
|
||||
if (repo.platform_id && !qs.platform)
|
||||
if (repo.platform_id)
|
||||
qs.platform = platform_id = repo.platform_id;
|
||||
if (!qs.file)
|
||||
if (!qs.file && repo.mainPath)
|
||||
qs.file = repo.mainPath;
|
||||
requestPersistPermission(true, true);
|
||||
//requestPersistPermission(true, true);
|
||||
}
|
||||
} else {
|
||||
platform_id = qs.platform || userPrefs.getLastPlatformID();
|
||||
repo_id = '';
|
||||
delete qs.repo;
|
||||
}
|
||||
|
75
test/web/testimport.js
Normal file
75
test/web/testimport.js
Normal file
@ -0,0 +1,75 @@
|
||||
|
||||
// https://nightwatchjs.org/api/
|
||||
|
||||
//var IDEURL = 'https://8bitworkshop.com/dev/';
|
||||
var IDEURL = 'http://localhost:8000/'
|
||||
var REPO = 'sehugg/happy2020'
|
||||
var PLATFORM = 'astrocade'
|
||||
var FILE = 'happy2020.c'
|
||||
var PRESETFILE = 'hello.c'
|
||||
var QS_GITHUBURL = '&githubURL=https%3A%2F%2Fgithub.com%2F' + REPO
|
||||
|
||||
let github_config = JSON.parse(require('fs').readFileSync('./github.json','utf-8'));
|
||||
if (github_config?.token) {
|
||||
exports['beforeEach'] = function(browser) {
|
||||
browser.setCookie({
|
||||
name: '__github_key',
|
||||
value: github_config.token,
|
||||
path: '/'
|
||||
});
|
||||
}
|
||||
} else {
|
||||
throw new Error('need ./github.js with {token:"..."}')
|
||||
}
|
||||
|
||||
exports['test import Github'] = async function (browser) {
|
||||
|
||||
await browser.url(`${IDEURL}?${QS_GITHUBURL}`)
|
||||
.waitForElementNotPresent('#step-0')
|
||||
.waitForElementNotVisible('#compile_spinner', time = 10000)
|
||||
.waitForElementNotVisible('#error_alert')
|
||||
.waitForElementVisible('#emuscreen')
|
||||
.waitForElementVisible('.emuvideo')
|
||||
.url(`${IDEURL}?repo=${REPO}`)
|
||||
|
||||
browser.expect.url().to.contain(`platform=${PLATFORM}`)
|
||||
browser.expect.url().to.contain(`file=${FILE}`)
|
||||
browser.expect.url().to.contain(`repo=${REPO.replace('/', '%2F')}`)
|
||||
|
||||
await browser.url(`${IDEURL}?`)
|
||||
.waitForElementNotVisible('#error_alert')
|
||||
.waitForElementVisible('#emuscreen')
|
||||
.waitForElementVisible('.emuvideo')
|
||||
|
||||
browser.expect.url().to.contain(`platform=${PLATFORM}`)
|
||||
browser.expect.url().to.contain(`file=${FILE}`)
|
||||
browser.expect.url().to.contain(`repo=${REPO.replace('/', '%2F')}`)
|
||||
|
||||
await browser.url(`${IDEURL}?repo=${REPO}`)
|
||||
.waitForElementNotVisible('#error_alert')
|
||||
.waitForElementVisible('#emuscreen')
|
||||
.waitForElementVisible('.emuvideo')
|
||||
|
||||
browser.expect.url().to.contain(`platform=${PLATFORM}`)
|
||||
browser.expect.url().to.contain(`file=${FILE}`)
|
||||
browser.expect.url().to.contain(`repo=${REPO.replace('/', '%2F')}`)
|
||||
|
||||
await browser.url(`${IDEURL}?platform=${PLATFORM}`)
|
||||
.waitForElementNotVisible('#error_alert')
|
||||
.waitForElementVisible('#emuscreen')
|
||||
.waitForElementVisible('.emuvideo')
|
||||
|
||||
browser.expect.url().to.contain(`platform=${PLATFORM}`)
|
||||
browser.expect.url().to.contain(`file=${FILE}`)
|
||||
browser.expect.url().to.contain(`repo=${REPO.replace('/', '%2F')}`)
|
||||
|
||||
await browser.url(`${IDEURL}?platform=${PLATFORM}&file=${PRESETFILE}`)
|
||||
.waitForElementNotVisible('#error_alert')
|
||||
.waitForElementVisible('#emuscreen')
|
||||
.waitForElementVisible('.emuvideo')
|
||||
|
||||
browser.expect.url().to.contain(`platform=${PLATFORM}`)
|
||||
browser.expect.url().to.contain(`file=${PRESETFILE}`)
|
||||
browser.expect.url().to.not.contain(`repo=${REPO.replace('/', '%2F')}`)
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user