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('#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 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 }) => {
|
||||
@@ -936,11 +936,9 @@ test.describe('Custom patches', () => {
|
||||
]);
|
||||
|
||||
if (doneOrError === 'error') {
|
||||
// Build failed — "Select different patches" should return to mode selection
|
||||
await expect(page.locator('#error-message')).toContainText('Build failed');
|
||||
await expect(page.locator('#btn-error-back')).toBeVisible();
|
||||
// Build failed — "Select different patches" should return to patches step
|
||||
await page.click('#btn-error-back');
|
||||
await expect(page.locator('#step-mode')).not.toBeHidden();
|
||||
await expect(page.locator('#step-patches')).not.toBeHidden();
|
||||
} else {
|
||||
// Build succeeded — check if the patch was skipped
|
||||
const logText = await page.locator('#build-log').textContent();
|
||||
|
||||
@@ -136,6 +136,17 @@ import JSZip from 'jszip';
|
||||
|
||||
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) {
|
||||
currentNavLabels = labels;
|
||||
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) {
|
||||
s.hidden = (s !== step);
|
||||
}
|
||||
if (updateHistory) {
|
||||
stepHistory[stepHistory.length - 1] = step;
|
||||
}
|
||||
}
|
||||
|
||||
function setNavStep(num) {
|
||||
@@ -845,7 +859,7 @@ import JSZip from 'jszip';
|
||||
showBuildResult();
|
||||
await checkExistingTgz();
|
||||
} 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 ---
|
||||
function showError(message, log, backStep) {
|
||||
function showError(message, log) {
|
||||
errorMessage.textContent = message;
|
||||
if (log) {
|
||||
errorLog.textContent = log;
|
||||
@@ -894,33 +908,30 @@ import JSZip from 'jszip';
|
||||
} else {
|
||||
errorLog.hidden = true;
|
||||
}
|
||||
if (backStep) {
|
||||
|
||||
const hasBackStep = stepHistory[stepHistory.length - 1] === stepPatches;
|
||||
if (hasBackStep) {
|
||||
errorTitle.textContent = 'The patch failed to apply';
|
||||
errorHint.hidden = false;
|
||||
btnErrorBack.hidden = false;
|
||||
btnErrorBack._backStep = backStep;
|
||||
btnRetry.classList.add('danger');
|
||||
} else {
|
||||
errorTitle.textContent = 'Something went wrong';
|
||||
errorHint.hidden = true;
|
||||
btnErrorBack.hidden = true;
|
||||
btnErrorBack._backStep = null;
|
||||
btnRetry.classList.remove('danger');
|
||||
}
|
||||
hideNav();
|
||||
showStep(stepError);
|
||||
pushStep(stepError);
|
||||
showStep(stepError, false);
|
||||
}
|
||||
|
||||
btnErrorBack.addEventListener('click', () => {
|
||||
btnErrorBack.hidden = true;
|
||||
btnRetry.classList.remove('danger');
|
||||
const prev = popStep();
|
||||
showNav();
|
||||
if (manualMode) {
|
||||
setNavStep(2);
|
||||
showStep(stepManualVersion);
|
||||
} else {
|
||||
goToModeSelection();
|
||||
}
|
||||
showStep(prev);
|
||||
});
|
||||
|
||||
btnRetry.addEventListener('click', () => {
|
||||
|
||||
Reference in New Issue
Block a user