Use history stack approach
All checks were successful
Build and test project / build-and-test (push) Successful in 1m30s
All checks were successful
Build and test project / build-and-test (push) Successful in 1m30s
This commit is contained in:
@@ -903,9 +903,9 @@ test.describe('Custom patches', () => {
|
|||||||
await expect(page.locator('#error-message')).toContainText('Build failed');
|
await expect(page.locator('#error-message')).toContainText('Build failed');
|
||||||
await expect(page.locator('#btn-error-back')).toBeVisible();
|
await expect(page.locator('#btn-error-back')).toBeVisible();
|
||||||
|
|
||||||
// "Select different patches" should return to mode selection (auto mode)
|
// "Select different patches" should return to patches step
|
||||||
await page.click('#btn-error-back');
|
await page.click('#btn-error-back');
|
||||||
await expect(page.locator('#step-mode')).not.toBeHidden();
|
await expect(page.locator('#step-patches')).not.toBeHidden();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('with device — real patch failure with Go Back (Allow rotation)', async ({ page }) => {
|
test('with device — real patch failure with Go Back (Allow rotation)', async ({ page }) => {
|
||||||
@@ -936,11 +936,9 @@ test.describe('Custom patches', () => {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if (doneOrError === 'error') {
|
if (doneOrError === 'error') {
|
||||||
// Build failed — "Select different patches" should return to mode selection
|
// Build failed — "Select different patches" should return to patches step
|
||||||
await expect(page.locator('#error-message')).toContainText('Build failed');
|
|
||||||
await expect(page.locator('#btn-error-back')).toBeVisible();
|
|
||||||
await page.click('#btn-error-back');
|
await page.click('#btn-error-back');
|
||||||
await expect(page.locator('#step-mode')).not.toBeHidden();
|
await expect(page.locator('#step-patches')).not.toBeHidden();
|
||||||
} else {
|
} else {
|
||||||
// Build succeeded — check if the patch was skipped
|
// Build succeeded — check if the patch was skipped
|
||||||
const logText = await page.locator('#build-log').textContent();
|
const logText = await page.locator('#build-log').textContent();
|
||||||
|
|||||||
@@ -136,6 +136,17 @@ import JSZip from 'jszip';
|
|||||||
|
|
||||||
let currentNavLabels = NAV_DEFAULT;
|
let currentNavLabels = NAV_DEFAULT;
|
||||||
|
|
||||||
|
const stepHistory = [stepConnect];
|
||||||
|
|
||||||
|
function pushStep(step) {
|
||||||
|
stepHistory.push(step);
|
||||||
|
}
|
||||||
|
|
||||||
|
function popStep() {
|
||||||
|
stepHistory.pop();
|
||||||
|
return stepHistory[stepHistory.length - 1];
|
||||||
|
}
|
||||||
|
|
||||||
function setNavLabels(labels) {
|
function setNavLabels(labels) {
|
||||||
currentNavLabels = labels;
|
currentNavLabels = labels;
|
||||||
const ol = $q('ol', stepNav);
|
const ol = $q('ol', stepNav);
|
||||||
@@ -147,10 +158,13 @@ import JSZip from 'jszip';
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showStep(step) {
|
function showStep(step, updateHistory = true) {
|
||||||
for (const s of allSteps) {
|
for (const s of allSteps) {
|
||||||
s.hidden = (s !== step);
|
s.hidden = (s !== step);
|
||||||
}
|
}
|
||||||
|
if (updateHistory) {
|
||||||
|
stepHistory[stepHistory.length - 1] = step;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setNavStep(num) {
|
function setNavStep(num) {
|
||||||
@@ -845,7 +859,7 @@ import JSZip from 'jszip';
|
|||||||
showBuildResult();
|
showBuildResult();
|
||||||
await checkExistingTgz();
|
await checkExistingTgz();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
showError('Build failed: ' + err.message, buildLog.textContent, stepPatches);
|
showError('Build failed: ' + err.message, buildLog.textContent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -883,7 +897,7 @@ import JSZip from 'jszip';
|
|||||||
});
|
});
|
||||||
|
|
||||||
// --- Error / Retry ---
|
// --- Error / Retry ---
|
||||||
function showError(message, log, backStep) {
|
function showError(message, log) {
|
||||||
errorMessage.textContent = message;
|
errorMessage.textContent = message;
|
||||||
if (log) {
|
if (log) {
|
||||||
errorLog.textContent = log;
|
errorLog.textContent = log;
|
||||||
@@ -894,33 +908,30 @@ import JSZip from 'jszip';
|
|||||||
} else {
|
} else {
|
||||||
errorLog.hidden = true;
|
errorLog.hidden = true;
|
||||||
}
|
}
|
||||||
if (backStep) {
|
|
||||||
|
const hasBackStep = stepHistory[stepHistory.length - 1] === stepPatches;
|
||||||
|
if (hasBackStep) {
|
||||||
errorTitle.textContent = 'The patch failed to apply';
|
errorTitle.textContent = 'The patch failed to apply';
|
||||||
errorHint.hidden = false;
|
errorHint.hidden = false;
|
||||||
btnErrorBack.hidden = false;
|
btnErrorBack.hidden = false;
|
||||||
btnErrorBack._backStep = backStep;
|
|
||||||
btnRetry.classList.add('danger');
|
btnRetry.classList.add('danger');
|
||||||
} else {
|
} else {
|
||||||
errorTitle.textContent = 'Something went wrong';
|
errorTitle.textContent = 'Something went wrong';
|
||||||
errorHint.hidden = true;
|
errorHint.hidden = true;
|
||||||
btnErrorBack.hidden = true;
|
btnErrorBack.hidden = true;
|
||||||
btnErrorBack._backStep = null;
|
|
||||||
btnRetry.classList.remove('danger');
|
btnRetry.classList.remove('danger');
|
||||||
}
|
}
|
||||||
hideNav();
|
hideNav();
|
||||||
showStep(stepError);
|
pushStep(stepError);
|
||||||
|
showStep(stepError, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
btnErrorBack.addEventListener('click', () => {
|
btnErrorBack.addEventListener('click', () => {
|
||||||
btnErrorBack.hidden = true;
|
btnErrorBack.hidden = true;
|
||||||
btnRetry.classList.remove('danger');
|
btnRetry.classList.remove('danger');
|
||||||
|
const prev = popStep();
|
||||||
showNav();
|
showNav();
|
||||||
if (manualMode) {
|
showStep(prev);
|
||||||
setNavStep(2);
|
|
||||||
showStep(stepManualVersion);
|
|
||||||
} else {
|
|
||||||
goToModeSelection();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
btnRetry.addEventListener('click', () => {
|
btnRetry.addEventListener('click', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user