diff --git a/src/views/dashboards/userDashboard/wash/MyWashStart.vue b/src/views/dashboards/userDashboard/wash/MyWashStart.vue index 3b80b1d8..5007f8ea 100644 --- a/src/views/dashboards/userDashboard/wash/MyWashStart.vue +++ b/src/views/dashboards/userDashboard/wash/MyWashStart.vue @@ -1051,6 +1051,8 @@ const refreshRecentlyCompletedWashState = () => { return hasRecentlyCompletedWash.value; }; +refreshRecentlyCompletedWashState(); + const isRecentlyCompletedActiveWash = (activeWash: any) => { const recentlyCompleted = readRecentlyCompletedWash(); if (!recentlyCompleted) { @@ -1633,6 +1635,7 @@ onMounted(async () => { isMyWashStartUnmounted.value = false; setShowFooterInContent(false); unregisterBeforeUnload.value = registerBeforeUnload(); + refreshRecentlyCompletedWashState(); await fetchDepartments(); startAutoRefresh(); @@ -1641,7 +1644,6 @@ onMounted(async () => { await fetchCustomerVehicles(); await fetchVehicleTypes(); const restoredProgress = restoreProgress(); - refreshRecentlyCompletedWashState(); shouldRestoreServerActiveWash.value = !restoredProgress?.washInProgress; scheduleServerActiveWashRestore(restoredProgress ? 1600 : 0); }); diff --git a/tests/unit/my-wash-start.spec.js b/tests/unit/my-wash-start.spec.js index 8439a45a..a527d857 100644 --- a/tests/unit/my-wash-start.spec.js +++ b/tests/unit/my-wash-start.spec.js @@ -767,6 +767,33 @@ describe("MyWashStart", () => { expect(wrapper.find('[data-testid="completed-step-stub"]').exists()).toBe(true); }); + it("shows a recently completed wash before startup refreshes finish", async () => { + localStorage.setItem( + "mywash_recent_completed_v1", + JSON.stringify({ + laneId: 7, + reg: "AB12345", + customerNumber: 12345679, + completedAt: Date.now(), + }) + ); + mocks.fetchDepartments.mockReturnValueOnce(new Promise(() => {})); + + const wrapper = mountWithApp(MyWashStart, { + global: { + stubs: stubComponents, + }, + }); + + await nextTick(); + + expect(mocks.fetchDepartments).toHaveBeenCalledTimes(1); + expect(wrapper.find('[data-testid="self-serve-disabled-warning"]').exists()).toBe(false); + expect(wrapper.find('[data-testid="completed-step-stub"]').exists()).toBe(true); + + wrapper.unmount(); + }); + it("does not let a late lane refresh move a completed wash back to questions", async () => { mocks.doesCurrentDepartmentSelectionHaveSelfServeEnabled.value = false; mocks.restoredProgressPayload = {