Seed recently completed wash state before startup awaits
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user