Skip to content

Commit 5b6aedf

Browse files
authored
Merge pull request #29 from ssfinney/codex/inspect-shandoku-codebase-for-rift-mode-mfo0pi
Expose E2E test hooks and refactor rift lifecycle/state handling
2 parents c00c60b + 85d5e99 commit 5b6aedf

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"type": "module",
77
"scripts": {
88
"test": "playwright test",
9-
"test:e2e": "playwright test",
109
"lint": "eslint script.js sw.js",
1110
"lint:fix": "eslint --fix script.js sw.js",
1211
"test:serve": "http-server . -p 4173 -c-1 --silent",

script.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
const RIFT_NON_CONFLICT_CHECK_INTERVAL = 5;
1212
const testParams = new URLSearchParams(window.location.search);
1313
const isLocalHost = ['localhost','127.0.0.1','0.0.0.0'].includes(window.location.hostname);
14-
const TEST_MODE = (testParams.get('testHooks') === '1' && isLocalHost)
15-
|| (testParams.get('e2e') === '1' && (isLocalHost || navigator.webdriver === true));
14+
const testHooksEnabled = testParams.get('testHooks') === '1' && isLocalHost;
15+
const e2eModeEnabled = testParams.get('e2e') === '1' && (isLocalHost || navigator.webdriver);
16+
const TEST_MODE = testHooksEnabled || e2eModeEnabled;
1617
const boardEl = document.getElementById('board');
1718
const statusEl = document.getElementById('status');
1819
const difficultyEl = document.getElementById('difficulty');
@@ -891,7 +892,7 @@
891892

892893
function registerRiftExtension(extension={}){
893894
const dispose = [];
894-
['onTrigger','onResolve'].forEach(hookName => {
895+
Object.keys(riftExtensionHooks).forEach(hookName => {
895896
const handler = extension[hookName];
896897
if(typeof handler !== 'function') return;
897898
riftExtensionHooks[hookName].push(handler);
@@ -1139,6 +1140,10 @@
11391140
forceEvaluateRift(){
11401141
evaluateRiftTrigger('player-move',{ force:true, conflictIntroduced:true });
11411142
},
1143+
async forceRift(){
1144+
if(riftState.active || riftSequenceRunning) return;
1145+
await triggerRiftEvent();
1146+
},
11421147
getRiftState(){
11431148
return {
11441149
...serializeRiftState(),

0 commit comments

Comments
 (0)