Skip to content

Commit

Permalink
Remember focus between tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bearfriend committed Jul 24, 2023
1 parent 90d4fc7 commit 24af2ba
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/server/pause.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ const controls = `

document.body.insertAdjacentHTML('afterBegin', controls);

document.querySelector('#skip-button').addEventListener('click', skip);
document.querySelector('#skip-all-button').addEventListener('click', skipAll);

const skipBtn = document.querySelector('#skip-button');
+skipBtn.addEventListener('click', skip);

const startBtn = document.querySelector('#start-button');
startBtn.addEventListener('click', start);

Expand All @@ -132,7 +134,7 @@ runBtn.addEventListener('click', run);
const testName = document.querySelector('#test-name');

/* eslint-disable no-undef, no-invalid-this */
let currentTest;
let currentTest, focusEl = runBtn;
beforeEach(async function() {
const fixture = new Promise(r => test.update = r);

Expand All @@ -147,7 +149,7 @@ beforeEach(async function() {

if (test.pause) {
runBtn.disabled = false;
runBtn.focus();
focusEl.focus();
}
});
});
Expand All @@ -160,6 +162,7 @@ function start() {
}

function run() {
focusEl = runBtn;
runBtn.disabled = true;
test.run();
}
Expand All @@ -171,6 +174,7 @@ function runAll() {
}

function skip() {
focusEl = skipBtn;
run();
try {
currentTest.skip();
Expand Down

0 comments on commit 24af2ba

Please sign in to comment.