Reset manual mode state when pressing "Connect"
Ideally, I think I just want to change how these flows pass state in the first place. Seems like it should be possible to come up with a flow that cannot have these kind of issues due to how it's architected.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -31,6 +31,7 @@ electron/release/
|
|||||||
tests/cached_assets/
|
tests/cached_assets/
|
||||||
|
|
||||||
# E2E tests
|
# E2E tests
|
||||||
|
test-results/
|
||||||
tests/node_modules/
|
tests/node_modules/
|
||||||
tests/test-results/
|
tests/test-results/
|
||||||
tests/playwright-report/
|
tests/playwright-report/
|
||||||
|
|||||||
@@ -1157,6 +1157,48 @@ test.describe('Custom patches', () => {
|
|||||||
await expect(page.locator('#step-manual-version')).not.toBeHidden();
|
await expect(page.locator('#step-manual-version')).not.toBeHidden();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('switching from manual to connect resets manual state', async ({ page }) => {
|
||||||
|
test.skip(!hasFirmwareZip(), `Firmware not found at ${FIRMWARE_PATH}`);
|
||||||
|
|
||||||
|
await page.goto('/');
|
||||||
|
await expect(page.locator('h1')).toContainText('KoboPatch');
|
||||||
|
|
||||||
|
// Start in manual mode, select patches, reach version picker
|
||||||
|
await page.click('#btn-manual');
|
||||||
|
await expect(page.locator('#step-mode')).not.toBeHidden();
|
||||||
|
await page.click('input[name="mode"][value="patches"]');
|
||||||
|
await page.click('#btn-mode-next');
|
||||||
|
await expect(page.locator('#step-manual-version')).not.toBeHidden();
|
||||||
|
|
||||||
|
// Go back all the way to the connect step
|
||||||
|
await page.click('#btn-manual-version-back');
|
||||||
|
await expect(page.locator('#step-mode')).not.toBeHidden();
|
||||||
|
await page.click('#btn-mode-back');
|
||||||
|
await expect(page.locator('#step-connect')).not.toBeHidden();
|
||||||
|
|
||||||
|
// Change mind: click "Connect to Kobo" — manualMode must be reset
|
||||||
|
await injectMockDevice(page, { hasNickelMenu: false, overrideFirmware: true });
|
||||||
|
await page.click('#btn-connect');
|
||||||
|
await expect(page.locator('#step-connect-instructions')).not.toBeHidden();
|
||||||
|
await page.click('#btn-connect-ready');
|
||||||
|
await expect(page.locator('#step-device')).not.toBeHidden();
|
||||||
|
|
||||||
|
// Continue to mode selection, pick patches
|
||||||
|
await page.click('#btn-device-next');
|
||||||
|
await expect(page.locator('#step-mode')).not.toBeHidden();
|
||||||
|
await page.click('input[name="mode"][value="patches"]');
|
||||||
|
await page.click('#btn-mode-next');
|
||||||
|
|
||||||
|
// Should go to the device-aware patches step, NOT the manual version picker
|
||||||
|
await expect(page.locator('#step-patches')).not.toBeHidden();
|
||||||
|
await expect(page.locator('#step-manual-version')).toBeHidden();
|
||||||
|
|
||||||
|
// Back from patches should return to mode selection, not manual version
|
||||||
|
await page.click('#btn-patches-back');
|
||||||
|
await expect(page.locator('#step-mode')).not.toBeHidden();
|
||||||
|
await expect(page.locator('#step-manual-version')).toBeHidden();
|
||||||
|
});
|
||||||
|
|
||||||
test('no device — back navigation through manual mode flow', async ({ page }) => {
|
test('no device — back navigation through manual mode flow', async ({ page }) => {
|
||||||
await page.goto('/');
|
await page.goto('/');
|
||||||
await goToManualMode(page);
|
await goToManualMode(page);
|
||||||
|
|||||||
@@ -367,6 +367,10 @@ function displayDeviceInfo(info) {
|
|||||||
|
|
||||||
// "Connect my Kobo" shows the instructions step first (not the file picker).
|
// "Connect my Kobo" shows the instructions step first (not the file picker).
|
||||||
btnConnect.addEventListener('click', () => {
|
btnConnect.addEventListener('click', () => {
|
||||||
|
// Reset any state from a previous manual-mode attempt so it does not
|
||||||
|
// leak into the device-connected flow (e.g. back navigation would
|
||||||
|
// otherwise land on the manual version picker).
|
||||||
|
state.manualMode = false;
|
||||||
track('flow-start', { method: 'connect' });
|
track('flow-start', { method: 'connect' });
|
||||||
showStep(stepConnectInstructions);
|
showStep(stepConnectInstructions);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user