Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4b248573a | ||
|
|
14e454e9d9 | ||
|
|
ebab7d8804 | ||
|
|
78a3fb1879 |
@@ -250,16 +250,18 @@ export function useWashSessionActions(options) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const selectedWashType = radioWashType.value === "Machine" ? "Machine" : "Manual";
|
||||
const startResponse = await executeSelfServeCommand(laneId, "START", {
|
||||
customer_number: parseInt(customerNumber),
|
||||
license_plate: licensePlate.trim().toUpperCase(),
|
||||
wash_type: selectedWashType,
|
||||
defer_relay_side_effects: true,
|
||||
});
|
||||
if (!startResponse) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (radioWashType.value === "Machine" && isServiceAllowed("MACHINE")) {
|
||||
if (selectedWashType === "Machine" && isServiceAllowed("MACHINE")) {
|
||||
let machineRelayResponse = null;
|
||||
try {
|
||||
machineRelayResponse = await enableMachineRelay(laneId);
|
||||
|
||||
@@ -512,6 +512,7 @@ test.describe("Self-serve wash", () => {
|
||||
expect(startCommandRequest.postDataJSON?.()).toMatchObject({
|
||||
lane_id: 7,
|
||||
command: "START",
|
||||
wash_type: "Manual",
|
||||
});
|
||||
});
|
||||
|
||||
@@ -778,6 +779,7 @@ test.describe("Self-serve wash", () => {
|
||||
expect(startCommandRequest.postDataJSON?.()).toMatchObject({
|
||||
command: "START",
|
||||
customer_number: 12345679,
|
||||
wash_type: "Manual",
|
||||
defer_relay_side_effects: true,
|
||||
});
|
||||
await page.waitForTimeout(250);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// @vitest-environment jsdom
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { mountWithApp } from "./helpers/mountWithApp.js";
|
||||
import ReferenceAutocompletePOS from "@/components/forms/department/pos/input/ReferenceAutocompletePOS.vue";
|
||||
|
||||
@@ -16,8 +16,72 @@ const flushPromises = async () => {
|
||||
await Promise.resolve();
|
||||
};
|
||||
|
||||
// Buefy schedules dropdown viewport checks after activation; stubbing it keeps this focused unit test from
|
||||
// leaking those browser-only timers past jsdom teardown.
|
||||
const AutocompleteStub = {
|
||||
name: "BAutocomplete",
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
data: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
},
|
||||
emits: ["blur", "focus", "keydown", "select", "typing", "update:modelValue"],
|
||||
methods: {
|
||||
emitInput(event) {
|
||||
const value = event.target.value;
|
||||
this.$emit("update:modelValue", value);
|
||||
this.$emit("typing", value);
|
||||
},
|
||||
optionsFor(group) {
|
||||
return Array.isArray(group?.items) ? group.items : [];
|
||||
},
|
||||
optionKey(option) {
|
||||
return `${option.source}-${option.origin_id}-${option.reference}`;
|
||||
},
|
||||
},
|
||||
template: `
|
||||
<div class="b-autocomplete-stub">
|
||||
<input
|
||||
v-bind="$attrs"
|
||||
:value="modelValue"
|
||||
@input="emitInput"
|
||||
@focus="$emit('focus', $event)"
|
||||
@blur="$emit('blur', $event)"
|
||||
@keydown="$emit('keydown', $event)"
|
||||
/>
|
||||
<div class="dropdown-content">
|
||||
<template v-for="(group, index) in data" :key="group.group || index">
|
||||
<slot name="group" :group="group.group" :index="index">
|
||||
<span>{{ group.group }}</span>
|
||||
</slot>
|
||||
<button
|
||||
v-for="option in optionsFor(group)"
|
||||
:key="optionKey(option)"
|
||||
type="button"
|
||||
class="dropdown-item"
|
||||
@click="$emit('select', option, $event)"
|
||||
>
|
||||
<slot :option="option">
|
||||
{{ option.reference }}
|
||||
</slot>
|
||||
</button>
|
||||
</template>
|
||||
<slot v-if="data.length === 0" name="empty" />
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
};
|
||||
|
||||
const mountedWrappers = [];
|
||||
|
||||
function mountAutocomplete(props = {}) {
|
||||
return mountWithApp(ReferenceAutocompletePOS, {
|
||||
const wrapper = mountWithApp(ReferenceAutocompletePOS, {
|
||||
props: {
|
||||
modelValue: "",
|
||||
departmentId: 12,
|
||||
@@ -26,7 +90,15 @@ function mountAutocomplete(props = {}) {
|
||||
debounceMs: 0,
|
||||
...props,
|
||||
},
|
||||
global: {
|
||||
stubs: {
|
||||
BAutocomplete: AutocompleteStub,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
mountedWrappers.push(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
describe("ReferenceAutocompletePOS", () => {
|
||||
@@ -35,6 +107,12 @@ describe("ReferenceAutocompletePOS", () => {
|
||||
requestState.authenticatedRequest.mockResolvedValue({ data: { data: [] } });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
for (const wrapper of mountedWrappers.splice(0)) {
|
||||
wrapper.unmount();
|
||||
}
|
||||
});
|
||||
|
||||
it("fetches async suggestions with the current POS context", async () => {
|
||||
requestState.authenticatedRequest.mockResolvedValue({
|
||||
data: {
|
||||
|
||||
@@ -47,7 +47,7 @@ describe("useWashSessionActions production commands", () => {
|
||||
expect(state.request).toHaveBeenCalledWith(
|
||||
"/modules/self-serve/lane/command",
|
||||
"post",
|
||||
expect.objectContaining({ command: "START", license_plate: "AB12345" })
|
||||
expect.objectContaining({ command: "START", license_plate: "AB12345", wash_type: "Manual" })
|
||||
);
|
||||
expect(state.washInProgress.value).toBe(true);
|
||||
expect(state.currentStep.value).toBe(WASH_STEPS.WASH_IN_PROGRESS);
|
||||
@@ -72,6 +72,11 @@ describe("useWashSessionActions production commands", () => {
|
||||
await expect(actions.onStartWash(7, "AB12345", "12345679")).resolves.toBe(true);
|
||||
|
||||
expect(state.enableMachineRelay).toHaveBeenCalledWith(7);
|
||||
expect(state.request).toHaveBeenCalledWith(
|
||||
"/modules/self-serve/lane/command",
|
||||
"post",
|
||||
expect.objectContaining({ command: "START", wash_type: "Machine" })
|
||||
);
|
||||
expect(state.washInProgress.value).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
@@ -207,6 +207,7 @@ describe("useWashSessionActions property gate commands", () => {
|
||||
command: "START",
|
||||
customer_number: 12345679,
|
||||
license_plate: "AB12345",
|
||||
wash_type: "Manual",
|
||||
defer_relay_side_effects: true,
|
||||
});
|
||||
|
||||
@@ -286,6 +287,7 @@ describe("useWashSessionActions property gate commands", () => {
|
||||
command: "START",
|
||||
customer_number: 12345679,
|
||||
license_plate: "AB12345",
|
||||
wash_type: "Machine",
|
||||
defer_relay_side_effects: true,
|
||||
});
|
||||
expect(request).toHaveBeenCalledWith("/modules/self-serve/lane/command", "post", {
|
||||
@@ -346,6 +348,7 @@ describe("useWashSessionActions property gate commands", () => {
|
||||
command: "START",
|
||||
customer_number: 12345679,
|
||||
license_plate: "AB12345",
|
||||
wash_type: "Machine",
|
||||
defer_relay_side_effects: true,
|
||||
});
|
||||
expect(request).toHaveBeenCalledWith("/modules/self-serve/lane/command", "post", {
|
||||
|
||||
Reference in New Issue
Block a user