Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36c1f10de8 | ||
|
|
ee41366c08 | ||
|
|
e22f78a449 | ||
|
|
0e9292d6d9 | ||
|
|
69250ada66 | ||
|
|
7f3a8c07e2 | ||
|
|
bd14d58f08 | ||
|
|
b8494cd1d9 | ||
|
|
49772c1334 | ||
|
|
02ddb99000 |
@@ -112,6 +112,8 @@ jobs:
|
||||
env:
|
||||
PLAYWRIGHT_ARTIFACT_NAMESPACE: e2e-pr-${{ matrix.suite }}-${{ matrix.project }}
|
||||
PLAYWRIGHT_REPORTER_MODE: line-html
|
||||
PLAYWRIGHT_WORKERS: 1
|
||||
PLAYWRIGHT_VIDEO_MODE: on-first-retry
|
||||
steps:
|
||||
- name: Repair self-hosted workspace permissions
|
||||
shell: bash
|
||||
@@ -223,6 +225,8 @@ jobs:
|
||||
--env CI="${CI:-}" \
|
||||
--env PLAYWRIGHT_ARTIFACT_NAMESPACE="$PLAYWRIGHT_ARTIFACT_NAMESPACE" \
|
||||
--env PLAYWRIGHT_REPORTER_MODE="$PLAYWRIGHT_REPORTER_MODE" \
|
||||
--env PLAYWRIGHT_WORKERS="$PLAYWRIGHT_WORKERS" \
|
||||
--env PLAYWRIGHT_VIDEO_MODE="$PLAYWRIGHT_VIDEO_MODE" \
|
||||
--env PLAYWRIGHT_DEV_PORT="$playwright_dev_port" \
|
||||
--env MATRIX_SUITE="$MATRIX_SUITE" \
|
||||
--env MATRIX_PROJECT="$MATRIX_PROJECT" \
|
||||
|
||||
@@ -7,14 +7,18 @@ export const fallbackChangePatterns = [
|
||||
/^vite\.config\.js$/u,
|
||||
/^playwright(?:\..+)?\.config\.(?:js|ts)$/u,
|
||||
/^playwright\.global-(?:setup|teardown)\.mjs$/u,
|
||||
/^scripts\/run-playwright-(?:pr|ci-parallel|batched-chromium)\.mjs$/u,
|
||||
/^scripts\/run-playwright-(?:ci-parallel|batched-chromium)\.mjs$/u,
|
||||
/^tests\/e2e\/(?:support|fixtures)\//u,
|
||||
];
|
||||
|
||||
export const sourceMappings = [
|
||||
{
|
||||
name: "auth",
|
||||
patterns: [/^src\/(?:views|components|middleware)\/.*auth/iu, /^src\/views\/auth\//u, /^src\/components\/session\//u],
|
||||
patterns: [
|
||||
/^src\/(?:views|components|middleware)\/.*auth/iu,
|
||||
/^src\/views\/auth\//u,
|
||||
/^src\/components\/session\/(?!token\/SessionUser\/Objects\/)/u,
|
||||
],
|
||||
specs: ["tests/e2e/auth.smoke.spec.js", "tests/e2e/userAuth.spec.ts"],
|
||||
projects: chromiumProjects,
|
||||
},
|
||||
@@ -92,6 +96,15 @@ export const sourceMappings = [
|
||||
specs: ["tests/e2e/superuser-system-status.smoke.spec.js"],
|
||||
projects: chromiumProjects,
|
||||
},
|
||||
{
|
||||
name: "superuser-department-pricing",
|
||||
patterns: [
|
||||
/^src\/views\/dashboards\/superUserDashboard\/department\/(?:DepartmentPricing|SuperUserSelectedDepartmentObject)\.vue$/u,
|
||||
/^src\/components\/session\/token\/SessionUser\/Objects\/Departments\.vue$/u,
|
||||
],
|
||||
specs: ["tests/e2e/superuser-department-pricing-custom-only.spec.ts"],
|
||||
projects: ["chromium-desktop"],
|
||||
},
|
||||
{
|
||||
name: "self-serve",
|
||||
patterns: [/self[-/]?serve/iu, /selfserve/iu, /wash\/MyWash/iu],
|
||||
|
||||
@@ -103,6 +103,7 @@ export const ownedFilesByRole = {
|
||||
"superuser-department-branding.spec.js",
|
||||
"superuser-department-gates.spec.ts",
|
||||
"superuser-department-lanes.spec.ts",
|
||||
"superuser-department-pricing-custom-only.spec.ts",
|
||||
"superuser-departments-archive.spec.ts",
|
||||
"superuser-drafts.spec.ts",
|
||||
"superuser-products-layout.spec.ts",
|
||||
|
||||
@@ -261,6 +261,8 @@ function selectChangedTests(changedFiles) {
|
||||
specProjects: new Map(),
|
||||
mappedFiles: [],
|
||||
unmappedFiles: [],
|
||||
directSpecFiles: [],
|
||||
skippedDirectSpecFiles: [],
|
||||
fallback: false,
|
||||
};
|
||||
|
||||
@@ -270,8 +272,7 @@ function selectChangedTests(changedFiles) {
|
||||
const file = normalizePath(rawFile);
|
||||
|
||||
if (isE2eSpec(file)) {
|
||||
addSpec(selection, file, selectedProjects);
|
||||
selection.mappedFiles.push(file);
|
||||
selection.directSpecFiles.push(file);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -295,13 +296,26 @@ function selectChangedTests(changedFiles) {
|
||||
|
||||
selection.mappedFiles.push(file);
|
||||
for (const mapping of matches) {
|
||||
const projects = mapping.projects.filter((project) => selectedProjects.includes(project));
|
||||
const mappedProjects = mapping.projects.length > 0 ? mapping.projects : selectedProjects;
|
||||
const projects = mappedProjects.filter((project) => selectedProjects.includes(project));
|
||||
if (projects.length === 0) {
|
||||
continue;
|
||||
}
|
||||
for (const spec of mapping.specs) {
|
||||
addSpec(selection, spec, projects.length > 0 ? projects : selectedProjects);
|
||||
addSpec(selection, spec, projects);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (selection.specProjects.size === 0 && !selection.fallback) {
|
||||
for (const file of selection.directSpecFiles) {
|
||||
addSpec(selection, file, selectedProjects);
|
||||
selection.mappedFiles.push(file);
|
||||
}
|
||||
} else {
|
||||
selection.skippedDirectSpecFiles.push(...selection.directSpecFiles);
|
||||
}
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
@@ -370,6 +384,12 @@ async function runChangedSelection(selection) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (selection.skippedDirectSpecFiles.length > 0) {
|
||||
console.log(
|
||||
`[playwright-pr] Source mappings selected changed-area specs; direct E2E file edits are covered by mapped/core gates: ${selection.skippedDirectSpecFiles.join(", ")}`
|
||||
);
|
||||
}
|
||||
|
||||
for (const [index, group] of groups.entries()) {
|
||||
for (const project of group.projects) {
|
||||
const code = await runPlaywright({
|
||||
|
||||
@@ -52,10 +52,6 @@ loadList();
|
||||
:columnLabels="{ type: SessionUser.objects.vehicles.columns.type.label }"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="$slots.actions" class="vehicles-pagination__add-action">
|
||||
<label class="label is-small"> </label>
|
||||
<slot name="actions" />
|
||||
</div>
|
||||
<!-- Create a new vehicle, if the route is /user -->
|
||||
<div class="vehicles-pagination__add-action"
|
||||
v-if="router.currentRoute.value.path.startsWith('/user')">
|
||||
|
||||
@@ -1,241 +0,0 @@
|
||||
<script setup>
|
||||
import { computed, nextTick, onMounted, ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import CustomerSearchSelect from "@/components/search/economic/CustomerSearchSelect.vue";
|
||||
import { SessionUser } from "@/components/session/token/SessionUser.vue";
|
||||
|
||||
const emit = defineEmits(["close", "created"]);
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const selectedCustomer = ref(null);
|
||||
const registrationNumber = ref("");
|
||||
const vehicleType = ref("");
|
||||
const washSubscription = ref(false);
|
||||
const reference = ref("");
|
||||
const vehicleTypeOptions = ref([]);
|
||||
const isLoadingVehicleTypes = ref(false);
|
||||
const isSubmitting = ref(false);
|
||||
const errorMessage = ref("");
|
||||
const vehicleTypeError = ref("");
|
||||
|
||||
const getCustomerNumber = (customer) => {
|
||||
const parsedValue = Number.parseInt(
|
||||
String(customer?.customerNumber ?? customer?.customer_number ?? customer?.customer_id ?? customer?.id ?? ""),
|
||||
10
|
||||
);
|
||||
|
||||
return Number.isInteger(parsedValue) && parsedValue > 0 ? parsedValue : null;
|
||||
};
|
||||
|
||||
const selectedCustomerNumber = computed(() => getCustomerNumber(selectedCustomer.value));
|
||||
|
||||
const normalizedVehicleType = computed(() => {
|
||||
if (vehicleType.value === "") {
|
||||
return null;
|
||||
}
|
||||
|
||||
const parsedValue = Number.parseInt(String(vehicleType.value), 10);
|
||||
return Number.isInteger(parsedValue) && parsedValue >= 0 ? parsedValue : null;
|
||||
});
|
||||
|
||||
const normalizedRegistrationNumber = computed(() => {
|
||||
return registrationNumber.value.trim().toUpperCase();
|
||||
});
|
||||
|
||||
const canSubmit = computed(() => {
|
||||
return (
|
||||
!isSubmitting.value &&
|
||||
!isLoadingVehicleTypes.value &&
|
||||
selectedCustomerNumber.value !== null &&
|
||||
normalizedRegistrationNumber.value.length > 0 &&
|
||||
normalizedVehicleType.value !== null
|
||||
);
|
||||
});
|
||||
|
||||
const parseErrorMessage = (error) => {
|
||||
return SessionUser.functions.parseErrorMessage(error) || t("vehicles.add_modal.error");
|
||||
};
|
||||
|
||||
const loadVehicleTypes = async () => {
|
||||
isLoadingVehicleTypes.value = true;
|
||||
vehicleTypeError.value = "";
|
||||
|
||||
try {
|
||||
vehicleTypeOptions.value = await SessionUser.objects.vehicles.columns.type.options();
|
||||
} catch (error) {
|
||||
vehicleTypeError.value = parseErrorMessage(error) || t("vehicles.add_modal.type_load_error");
|
||||
} finally {
|
||||
isLoadingVehicleTypes.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const closeModal = () => {
|
||||
if (!isSubmitting.value) {
|
||||
emit("close");
|
||||
}
|
||||
};
|
||||
|
||||
const submitVehicle = async () => {
|
||||
if (!canSubmit.value) {
|
||||
errorMessage.value = t("vehicles.add_modal.validation_error");
|
||||
return;
|
||||
}
|
||||
|
||||
isSubmitting.value = true;
|
||||
errorMessage.value = "";
|
||||
|
||||
try {
|
||||
const response = await SessionUser.objects.vehicles.add(
|
||||
normalizedVehicleType.value,
|
||||
normalizedRegistrationNumber.value,
|
||||
washSubscription.value,
|
||||
selectedCustomerNumber.value,
|
||||
reference.value.trim() || null
|
||||
);
|
||||
|
||||
emit("created", response);
|
||||
} catch (error) {
|
||||
errorMessage.value = parseErrorMessage(error);
|
||||
} finally {
|
||||
isSubmitting.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
await loadVehicleTypes();
|
||||
await nextTick();
|
||||
document.getElementById("superuser-add-vehicle-customer-search")?.focus();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="modal is-active" data-testid="superuser-add-vehicle-modal">
|
||||
<div class="modal-background" @click="closeModal"></div>
|
||||
<div class="modal-card superuser-add-vehicle-modal">
|
||||
<header class="modal-card-head">
|
||||
<p class="modal-card-title">{{ t("vehicles.add_modal.title") }}</p>
|
||||
<button
|
||||
class="delete"
|
||||
type="button"
|
||||
:aria-label="t('common.close')"
|
||||
data-testid="superuser-add-vehicle-close"
|
||||
@click="closeModal"
|
||||
></button>
|
||||
</header>
|
||||
|
||||
<section class="modal-card-body">
|
||||
<div v-if="errorMessage" class="notification is-danger is-light" data-testid="superuser-add-vehicle-error">
|
||||
{{ errorMessage }}
|
||||
</div>
|
||||
|
||||
<CustomerSearchSelect
|
||||
v-model="selectedCustomer"
|
||||
input-id="superuser-add-vehicle-customer-search"
|
||||
test-id-prefix="superuser-add-vehicle-customer"
|
||||
:disabled="isSubmitting"
|
||||
:placeholder="t('vehicles.add_modal.customer_placeholder')"
|
||||
/>
|
||||
|
||||
<div class="field">
|
||||
<label class="label" for="superuser-add-vehicle-registration">{{ t("vehicles.form.license_plate") }}</label>
|
||||
<div class="control">
|
||||
<input
|
||||
id="superuser-add-vehicle-registration"
|
||||
v-model="registrationNumber"
|
||||
class="input"
|
||||
type="text"
|
||||
autocomplete="off"
|
||||
:placeholder="t('vehicles.add_modal.registration_placeholder')"
|
||||
:disabled="isSubmitting"
|
||||
data-testid="superuser-add-vehicle-registration"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label" for="superuser-add-vehicle-type">{{ t("vehicles.form.type") }}</label>
|
||||
<div class="control" :class="{ 'is-loading': isLoadingVehicleTypes }">
|
||||
<div class="select is-fullwidth">
|
||||
<select
|
||||
id="superuser-add-vehicle-type"
|
||||
v-model="vehicleType"
|
||||
:disabled="isSubmitting || isLoadingVehicleTypes || vehicleTypeOptions.length === 0"
|
||||
data-testid="superuser-add-vehicle-type"
|
||||
>
|
||||
<option disabled value="">{{ t("vehicles.add_modal.type_placeholder") }}</option>
|
||||
<option v-for="option in vehicleTypeOptions" :key="option.id" :value="option.id">
|
||||
{{ option.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="vehicleTypeError" class="help is-danger" data-testid="superuser-add-vehicle-type-error">
|
||||
{{ vehicleTypeError }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="checkbox">
|
||||
<input
|
||||
v-model="washSubscription"
|
||||
type="checkbox"
|
||||
:disabled="isSubmitting"
|
||||
data-testid="superuser-add-vehicle-wash-subscription"
|
||||
/>
|
||||
{{ t("objects.vehicles.columns.wash_subscription") }}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label" for="superuser-add-vehicle-reference">{{ t("common.reference") }}</label>
|
||||
<div class="control">
|
||||
<input
|
||||
id="superuser-add-vehicle-reference"
|
||||
v-model="reference"
|
||||
class="input"
|
||||
type="text"
|
||||
autocomplete="off"
|
||||
:placeholder="t('vehicles.add_modal.reference_placeholder')"
|
||||
:disabled="isSubmitting"
|
||||
data-testid="superuser-add-vehicle-reference"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<footer class="modal-card-foot is-justify-content-flex-end">
|
||||
<button
|
||||
class="button"
|
||||
type="button"
|
||||
:disabled="isSubmitting"
|
||||
data-testid="superuser-add-vehicle-cancel"
|
||||
@click="closeModal"
|
||||
>
|
||||
{{ t("common.cancel") }}
|
||||
</button>
|
||||
<button
|
||||
class="button is-link"
|
||||
type="button"
|
||||
:class="{ 'is-loading': isSubmitting }"
|
||||
:disabled="!canSubmit"
|
||||
data-testid="superuser-add-vehicle-submit"
|
||||
@click="submitVehicle"
|
||||
>
|
||||
{{ t("vehicles.add_modal.submit") }}
|
||||
</button>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.superuser-add-vehicle-modal {
|
||||
max-width: min(44rem, calc(100vw - 2rem));
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.modal-card-body {
|
||||
overflow: visible;
|
||||
}
|
||||
</style>
|
||||
@@ -1,288 +0,0 @@
|
||||
<script setup>
|
||||
import { computed, nextTick, onBeforeUnmount, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { isSearching, searchCustomer, searchCustomerResults } from "@/components/search/economic/customerSearch.vue";
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
inputId: {
|
||||
type: String,
|
||||
default: "customer-search-select-input",
|
||||
},
|
||||
testIdPrefix: {
|
||||
type: String,
|
||||
default: "customer-search-select",
|
||||
},
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(["update:modelValue", "selected", "cleared"]);
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const searchQuery = ref("");
|
||||
const showResults = ref(false);
|
||||
const selectedResultIndex = ref(-1);
|
||||
|
||||
const getCustomerNumber = (customer) => {
|
||||
const parsedValue = Number.parseInt(
|
||||
String(customer?.customerNumber ?? customer?.customer_number ?? customer?.customer_id ?? customer?.id ?? ""),
|
||||
10
|
||||
);
|
||||
|
||||
return Number.isInteger(parsedValue) && parsedValue > 0 ? parsedValue : null;
|
||||
};
|
||||
|
||||
const getCustomerName = (customer) => {
|
||||
return String(customer?.name ?? customer?.customer_name ?? customer?.customerName ?? "").trim();
|
||||
};
|
||||
|
||||
const getCustomerCity = (customer) => {
|
||||
return String(customer?.city ?? customer?.address_city ?? "").trim();
|
||||
};
|
||||
|
||||
const formatCustomer = (customer) => {
|
||||
if (!customer) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const name = getCustomerName(customer);
|
||||
const customerNumber = getCustomerNumber(customer);
|
||||
|
||||
return [name, customerNumber ? `#${customerNumber}` : null].filter(Boolean).join(" - ");
|
||||
};
|
||||
|
||||
const selectedCustomerNumber = computed(() => getCustomerNumber(props.modelValue));
|
||||
const selectedCustomerName = computed(() => getCustomerName(props.modelValue));
|
||||
const selectedCustomerCity = computed(() => getCustomerCity(props.modelValue));
|
||||
const hasResults = computed(() => searchCustomerResults.value.length > 0);
|
||||
const placeholderText = computed(() => props.placeholder || t("vehicles.add_modal.customer_placeholder"));
|
||||
|
||||
const resetSearchResults = () => {
|
||||
searchCustomer(null);
|
||||
selectedResultIndex.value = -1;
|
||||
};
|
||||
|
||||
const setSelectedCustomer = (customer) => {
|
||||
emit("update:modelValue", customer);
|
||||
emit("selected", customer);
|
||||
searchQuery.value = formatCustomer(customer);
|
||||
showResults.value = false;
|
||||
selectedResultIndex.value = -1;
|
||||
};
|
||||
|
||||
const clearSelectedCustomer = async () => {
|
||||
emit("update:modelValue", null);
|
||||
emit("cleared");
|
||||
searchQuery.value = "";
|
||||
showResults.value = false;
|
||||
resetSearchResults();
|
||||
await nextTick();
|
||||
document.getElementById(props.inputId)?.focus();
|
||||
};
|
||||
|
||||
const handleSearchInput = () => {
|
||||
if (props.modelValue) {
|
||||
emit("update:modelValue", null);
|
||||
}
|
||||
|
||||
const query = searchQuery.value.trim();
|
||||
selectedResultIndex.value = -1;
|
||||
|
||||
if (!query) {
|
||||
showResults.value = false;
|
||||
resetSearchResults();
|
||||
return;
|
||||
}
|
||||
|
||||
showResults.value = true;
|
||||
searchCustomer(query);
|
||||
};
|
||||
|
||||
const handleFocus = () => {
|
||||
if (searchQuery.value.trim() && hasResults.value) {
|
||||
showResults.value = true;
|
||||
}
|
||||
};
|
||||
|
||||
const handleBlur = () => {
|
||||
window.setTimeout(() => {
|
||||
showResults.value = false;
|
||||
selectedResultIndex.value = -1;
|
||||
}, 150);
|
||||
};
|
||||
|
||||
const handleKeydown = (event) => {
|
||||
if (!showResults.value || !hasResults.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.key === "ArrowDown") {
|
||||
event.preventDefault();
|
||||
selectedResultIndex.value = Math.min(selectedResultIndex.value + 1, searchCustomerResults.value.length - 1);
|
||||
} else if (event.key === "ArrowUp") {
|
||||
event.preventDefault();
|
||||
selectedResultIndex.value = Math.max(selectedResultIndex.value - 1, 0);
|
||||
} else if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
const selectedCustomer = searchCustomerResults.value[selectedResultIndex.value] || searchCustomerResults.value[0];
|
||||
if (selectedCustomer) {
|
||||
setSelectedCustomer(selectedCustomer);
|
||||
}
|
||||
} else if (event.key === "Escape") {
|
||||
showResults.value = false;
|
||||
selectedResultIndex.value = -1;
|
||||
}
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(customer) => {
|
||||
if (customer) {
|
||||
searchQuery.value = formatCustomer(customer);
|
||||
} else if (!document.activeElement || document.activeElement.id !== props.inputId) {
|
||||
searchQuery.value = "";
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
resetSearchResults();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="customer-search-select">
|
||||
<div class="field">
|
||||
<label class="label" :for="inputId">{{ t("vehicles.add_modal.customer_label") }}</label>
|
||||
<div class="control has-icons-left" :class="{ 'is-loading': isSearching }">
|
||||
<input
|
||||
:id="inputId"
|
||||
v-model="searchQuery"
|
||||
class="input"
|
||||
type="text"
|
||||
autocomplete="off"
|
||||
:placeholder="placeholderText"
|
||||
:disabled="disabled"
|
||||
:aria-expanded="showResults && hasResults"
|
||||
:data-testid="`${testIdPrefix}-input`"
|
||||
@input="handleSearchInput"
|
||||
@focus="handleFocus"
|
||||
@blur="handleBlur"
|
||||
@keydown="handleKeydown"
|
||||
/>
|
||||
<span class="icon is-left">
|
||||
<i class="fas fa-search"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="showResults && hasResults"
|
||||
class="dropdown is-active customer-search-select__dropdown"
|
||||
:data-testid="`${testIdPrefix}-results`"
|
||||
>
|
||||
<div class="dropdown-menu customer-search-select__menu" role="listbox">
|
||||
<div class="dropdown-content">
|
||||
<button
|
||||
v-for="(customer, index) in searchCustomerResults"
|
||||
:key="getCustomerNumber(customer) || index"
|
||||
type="button"
|
||||
class="dropdown-item customer-search-select__option"
|
||||
:class="{ 'is-active': selectedResultIndex === index }"
|
||||
:data-testid="`${testIdPrefix}-option-${index}`"
|
||||
@mousedown.prevent="setSelectedCustomer(customer)"
|
||||
>
|
||||
<span class="customer-search-select__option-main">{{ getCustomerName(customer) }}</span>
|
||||
<span class="customer-search-select__option-meta">
|
||||
#{{ getCustomerNumber(customer) }}
|
||||
<template v-if="getCustomerCity(customer)"> · {{ getCustomerCity(customer) }}</template>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="modelValue" class="customer-search-select__selected" :data-testid="`${testIdPrefix}-selected`">
|
||||
<div>
|
||||
<p class="has-text-weight-semibold">{{ t("vehicles.add_modal.selected_customer") }}</p>
|
||||
<p>{{ selectedCustomerName }}</p>
|
||||
<p class="is-size-7 has-text-grey">
|
||||
#{{ selectedCustomerNumber }}
|
||||
<span v-if="selectedCustomerCity"> · {{ selectedCustomerCity }}</span>
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="button is-small is-light"
|
||||
:disabled="disabled"
|
||||
:data-testid="`${testIdPrefix}-clear`"
|
||||
@click="clearSelectedCustomer"
|
||||
>
|
||||
{{ t("common.clear") }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.customer-search-select {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.customer-search-select__dropdown,
|
||||
.customer-search-select__menu {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.customer-search-select__dropdown {
|
||||
left: 0;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 4.75rem;
|
||||
z-index: 40;
|
||||
}
|
||||
|
||||
.customer-search-select__option {
|
||||
align-items: flex-start;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
text-align: left;
|
||||
white-space: normal;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.customer-search-select__option-main {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.customer-search-select__option-meta {
|
||||
color: #6b7280;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.customer-search-select__selected {
|
||||
align-items: flex-start;
|
||||
background: #f5f8fc;
|
||||
border: 1px solid #d8e2ef;
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 1rem;
|
||||
padding: 0.85rem 1rem;
|
||||
}
|
||||
</style>
|
||||
@@ -108,6 +108,14 @@ export const Departments = {
|
||||
required: false,
|
||||
},
|
||||
},
|
||||
custom_pricing_only: {
|
||||
label: t("objects.departments.columns.custom_pricing_only"),
|
||||
type: "boolean",
|
||||
sortable: true,
|
||||
creation: {
|
||||
required: false,
|
||||
},
|
||||
},
|
||||
longitude: {
|
||||
label: t("objects.departments.columns.longitude"),
|
||||
type: "number",
|
||||
@@ -164,6 +172,14 @@ export const Departments = {
|
||||
archived: async (id, archived) => {
|
||||
return ObjectsGlobal.set.column(Departments.meta.endpoint, id, "archived", ObjectsGlobal.parse.boolean(archived));
|
||||
},
|
||||
custom_pricing_only: async (id, custom_pricing_only) => {
|
||||
return ObjectsGlobal.set.column(
|
||||
Departments.meta.endpoint,
|
||||
id,
|
||||
"custom_pricing_only",
|
||||
ObjectsGlobal.parse.boolean(custom_pricing_only)
|
||||
);
|
||||
},
|
||||
longitude: async (id, longitude) => {
|
||||
return ObjectsGlobal.set.column(Departments.meta.endpoint, id, "longitude", parseFloat(longitude));
|
||||
},
|
||||
|
||||
@@ -3455,6 +3455,13 @@
|
||||
"opening_hours": {
|
||||
"closed": "Stengt"
|
||||
},
|
||||
"pricing": {
|
||||
"custom_pricing_disabled": "Fallback aktiv",
|
||||
"custom_pricing_enabled": "Kun egne priser",
|
||||
"custom_pricing_missing_price": "Manglende afdelingspriser bliver 999999.",
|
||||
"custom_pricing_only": "Ingen fallback-priser",
|
||||
"effective_department_price": "Effektiv afdelingspris"
|
||||
},
|
||||
"search_placeholder": "@.capitalize:{'words.generated.søg'} @:{'words.generated.efter'} @:{'words.generated.afdelingsnavn'}",
|
||||
"select_department": "@.capitalize:{'words.generated.vælg'} @:{'words.replication.host_definite_suffix'} @:{'words.generated.afdeling'}",
|
||||
"subtitle": "@.capitalize:{'words.generated.administrer'} @:{'words.generated.afdelinger'}",
|
||||
@@ -4285,6 +4292,7 @@
|
||||
"departments": {
|
||||
"columns": {
|
||||
"archived": "Arkiveret",
|
||||
"custom_pricing_only": "Ingen fallback-priser",
|
||||
"dimension": "Dimension",
|
||||
"economic_department": "@.upper:{'words.generated.e'}-@:{'words.generated.conomic'} @:{'words.generated.afdeling'}",
|
||||
"latitude": "@:{'templates.generated.compat.departments.form.latitude'}",
|
||||
@@ -5932,20 +5940,6 @@
|
||||
},
|
||||
"vehicles": {
|
||||
"add": "@:{'words.generated.tilføj'} @:{'words.generated.køretøj'}",
|
||||
"add_modal": {
|
||||
"customer_label": "Kunde",
|
||||
"customer_placeholder": "Søg efter kundenavn eller kundenummer",
|
||||
"error": "Køretøjet kunne ikke tilføjes.",
|
||||
"no_customer_results": "Ingen kunder fundet",
|
||||
"reference_placeholder": "Valgfri reference",
|
||||
"registration_placeholder": "Registreringsnummer",
|
||||
"selected_customer": "Valgt kunde",
|
||||
"submit": "Tilføj køretøj",
|
||||
"title": "Tilføj køretøj",
|
||||
"type_load_error": "Køretøjstyper kunne ikke indlæses.",
|
||||
"type_placeholder": "Vælg køretøjstype",
|
||||
"validation_error": "Vælg kunde, registreringsnummer og køretøjstype."
|
||||
},
|
||||
"brand": "@:{'templates.generated.compat.admin.pos.make'}",
|
||||
"color": "Farve",
|
||||
"delete_vehicle": "@:{'templates.generated.compat.vehicles.delete'}",
|
||||
|
||||
@@ -3287,6 +3287,13 @@
|
||||
"opening_hours": {
|
||||
"closed": "@:{'templates.generated.compat.global.closed'}"
|
||||
},
|
||||
"pricing": {
|
||||
"custom_pricing_disabled": "Fallback enabled",
|
||||
"custom_pricing_enabled": "Custom only",
|
||||
"custom_pricing_missing_price": "Missing department prices resolve to 999999.",
|
||||
"custom_pricing_only": "No fallback pricing",
|
||||
"effective_department_price": "Effective department price"
|
||||
},
|
||||
"search_placeholder": "@.capitalize:{'words.generated.search'} @:{'words.generated.by'} @:{'words.generated.department'} @:{'words.generated.name'}",
|
||||
"select_department": "@.capitalize:{'words.generated.select'} @:{'words.generated.a'} @:{'words.generated.department'}",
|
||||
"subtitle": "@.capitalize:{'words.generated.manage'} @:{'words.generated.departments'}",
|
||||
@@ -4117,6 +4124,7 @@
|
||||
"departments": {
|
||||
"columns": {
|
||||
"archived": "@:{'words.generated.archived'}",
|
||||
"custom_pricing_only": "No fallback pricing",
|
||||
"dimension": "Dimension",
|
||||
"economic_department": "@.upper:{'words.generated.e'}-@:{'words.generated.conomic'} @.capitalize:{'words.generated.department'}",
|
||||
"latitude": "@:{'templates.generated.compat.departments.form.latitude'}",
|
||||
@@ -5764,20 +5772,6 @@
|
||||
},
|
||||
"vehicles": {
|
||||
"add": "@.capitalize:{'words.generated.add'} @:{'words.generated.vehicle'}",
|
||||
"add_modal": {
|
||||
"customer_label": "Customer",
|
||||
"customer_placeholder": "Search by customer name or number",
|
||||
"error": "Unable to add vehicle.",
|
||||
"no_customer_results": "No customers found",
|
||||
"reference_placeholder": "Optional reference",
|
||||
"registration_placeholder": "Registration number",
|
||||
"selected_customer": "Selected customer",
|
||||
"submit": "Add vehicle",
|
||||
"title": "Add vehicle",
|
||||
"type_load_error": "Unable to load vehicle types.",
|
||||
"type_placeholder": "Select vehicle type",
|
||||
"validation_error": "Select a customer, registration number, and vehicle type."
|
||||
},
|
||||
"brand": "Brand",
|
||||
"color": "Color",
|
||||
"delete_vehicle": "@:{'templates.generated.compat.vehicles.delete'}",
|
||||
|
||||
@@ -2420,6 +2420,13 @@
|
||||
"title": "@:{'templates.generated.compat.departments.tab.opening_hours'}"
|
||||
},
|
||||
"phone": "@:common.phone",
|
||||
"pricing": {
|
||||
"custom_pricing_disabled": "@:{'templates.generated.compat.departments.pricing.custom_pricing_disabled'}",
|
||||
"custom_pricing_enabled": "@:{'templates.generated.compat.departments.pricing.custom_pricing_enabled'}",
|
||||
"custom_pricing_missing_price": "@:{'templates.generated.compat.departments.pricing.custom_pricing_missing_price'}",
|
||||
"custom_pricing_only": "@:{'templates.generated.compat.departments.pricing.custom_pricing_only'}",
|
||||
"effective_department_price": "@:{'templates.generated.compat.departments.pricing.effective_department_price'}"
|
||||
},
|
||||
"products": {
|
||||
"new_product": "@:products.new_product"
|
||||
},
|
||||
@@ -3486,6 +3493,7 @@
|
||||
"departments": {
|
||||
"columns": {
|
||||
"archived": "@:{'templates.generated.compat.objects.departments.columns.archived'}",
|
||||
"custom_pricing_only": "@:{'templates.generated.compat.objects.departments.columns.custom_pricing_only'}",
|
||||
"dimension": "@:{'templates.generated.compat.objects.departments.columns.dimension'}",
|
||||
"economic_department": "@:{'templates.generated.compat.objects.departments.columns.economic_department'}",
|
||||
"latitude": "@:{'templates.generated.compat.objects.departments.columns.latitude'}",
|
||||
@@ -5834,20 +5842,6 @@
|
||||
"vehicles": {
|
||||
"actions": "@:common.actions",
|
||||
"add": "@:{'templates.generated.compat.vehicles.add'}",
|
||||
"add_modal": {
|
||||
"customer_label": "@:{'templates.generated.compat.vehicles.add_modal.customer_label'}",
|
||||
"customer_placeholder": "@:{'templates.generated.compat.vehicles.add_modal.customer_placeholder'}",
|
||||
"error": "@:{'templates.generated.compat.vehicles.add_modal.error'}",
|
||||
"no_customer_results": "@:{'templates.generated.compat.vehicles.add_modal.no_customer_results'}",
|
||||
"reference_placeholder": "@:{'templates.generated.compat.vehicles.add_modal.reference_placeholder'}",
|
||||
"registration_placeholder": "@:{'templates.generated.compat.vehicles.add_modal.registration_placeholder'}",
|
||||
"selected_customer": "@:{'templates.generated.compat.vehicles.add_modal.selected_customer'}",
|
||||
"submit": "@:{'templates.generated.compat.vehicles.add_modal.submit'}",
|
||||
"title": "@:{'templates.generated.compat.vehicles.add_modal.title'}",
|
||||
"type_load_error": "@:{'templates.generated.compat.vehicles.add_modal.type_load_error'}",
|
||||
"type_placeholder": "@:{'templates.generated.compat.vehicles.add_modal.type_placeholder'}",
|
||||
"validation_error": "@:{'templates.generated.compat.vehicles.add_modal.validation_error'}"
|
||||
},
|
||||
"brand": "@:{'templates.generated.compat.vehicles.brand'}",
|
||||
"color": "@:{'templates.generated.compat.vehicles.color'}",
|
||||
"created_at": "@:{'templates.generated.compat.global.generated'}",
|
||||
|
||||
@@ -21,6 +21,13 @@
|
||||
"opening_hours": {
|
||||
"closed": "Stengt"
|
||||
},
|
||||
"pricing": {
|
||||
"custom_pricing_disabled": "Fallback aktiv",
|
||||
"custom_pricing_enabled": "Kun egne priser",
|
||||
"custom_pricing_missing_price": "Manglende afdelingspriser bliver 999999.",
|
||||
"custom_pricing_only": "Ingen fallback-priser",
|
||||
"effective_department_price": "Effektiv afdelingspris"
|
||||
},
|
||||
"search_placeholder": "@.capitalize:{'terms.glossary.søg'} @:{'terms.glossary.efter'} @:{'terms.glossary.afdelingsnavn'}",
|
||||
"select_department": "@.capitalize:{'terms.glossary.vælg'} @:{'terms.replication.host_definite_suffix'} @:{'terms.glossary.afdeling'}",
|
||||
"subtitle": "@.capitalize:{'terms.glossary.administrer'} @:{'terms.glossary.afdelinger'}",
|
||||
|
||||
@@ -140,6 +140,7 @@
|
||||
"departments": {
|
||||
"columns": {
|
||||
"archived": "Arkiveret",
|
||||
"custom_pricing_only": "Ingen fallback-priser",
|
||||
"dimension": "Dimension",
|
||||
"economic_department": "@.upper:{'terms.glossary.e'}-@:{'terms.glossary.conomic'} @:{'terms.glossary.afdeling'}",
|
||||
"latitude": "@:{'phrases.compat.departments.form.latitude'}",
|
||||
|
||||
@@ -2,20 +2,6 @@
|
||||
"compat": {
|
||||
"vehicles": {
|
||||
"add": "@:{'terms.glossary.tilføj'} @:{'terms.glossary.køretøj'}",
|
||||
"add_modal": {
|
||||
"customer_label": "Kunde",
|
||||
"customer_placeholder": "Søg efter kundenavn eller kundenummer",
|
||||
"error": "Køretøjet kunne ikke tilføjes.",
|
||||
"no_customer_results": "Ingen kunder fundet",
|
||||
"reference_placeholder": "Valgfri reference",
|
||||
"registration_placeholder": "Registreringsnummer",
|
||||
"selected_customer": "Valgt kunde",
|
||||
"submit": "Tilføj køretøj",
|
||||
"title": "Tilføj køretøj",
|
||||
"type_load_error": "Køretøjstyper kunne ikke indlæses.",
|
||||
"type_placeholder": "Vælg køretøjstype",
|
||||
"validation_error": "Vælg kunde, registreringsnummer og køretøjstype."
|
||||
},
|
||||
"brand": "@:{'phrases.compat.admin.pos.make'}",
|
||||
"color": "Farve",
|
||||
"delete_vehicle": "@:{'phrases.compat.vehicles.delete'}",
|
||||
|
||||
@@ -21,6 +21,13 @@
|
||||
"opening_hours": {
|
||||
"closed": "@:{'phrases.compat.global.closed'}"
|
||||
},
|
||||
"pricing": {
|
||||
"custom_pricing_disabled": "Fallback enabled",
|
||||
"custom_pricing_enabled": "Custom only",
|
||||
"custom_pricing_missing_price": "Missing department prices resolve to 999999.",
|
||||
"custom_pricing_only": "No fallback pricing",
|
||||
"effective_department_price": "Effective department price"
|
||||
},
|
||||
"search_placeholder": "@.capitalize:{'terms.glossary.search'} @:{'terms.glossary.by'} @:{'terms.glossary.department'} @:{'terms.glossary.name'}",
|
||||
"select_department": "@.capitalize:{'terms.glossary.select'} @:{'terms.glossary.a'} @:{'terms.glossary.department'}",
|
||||
"subtitle": "@.capitalize:{'terms.glossary.manage'} @:{'terms.glossary.departments'}",
|
||||
|
||||
@@ -140,6 +140,7 @@
|
||||
"departments": {
|
||||
"columns": {
|
||||
"archived": "@:{'terms.glossary.archived'}",
|
||||
"custom_pricing_only": "No fallback pricing",
|
||||
"dimension": "Dimension",
|
||||
"economic_department": "@.upper:{'terms.glossary.e'}-@:{'terms.glossary.conomic'} @.capitalize:{'terms.glossary.department'}",
|
||||
"latitude": "@:{'phrases.compat.departments.form.latitude'}",
|
||||
|
||||
@@ -2,20 +2,6 @@
|
||||
"compat": {
|
||||
"vehicles": {
|
||||
"add": "@.capitalize:{'terms.glossary.add'} @:{'terms.glossary.vehicle'}",
|
||||
"add_modal": {
|
||||
"customer_label": "Customer",
|
||||
"customer_placeholder": "Search by customer name or number",
|
||||
"error": "Unable to add vehicle.",
|
||||
"no_customer_results": "No customers found",
|
||||
"reference_placeholder": "Optional reference",
|
||||
"registration_placeholder": "Registration number",
|
||||
"selected_customer": "Selected customer",
|
||||
"submit": "Add vehicle",
|
||||
"title": "Add vehicle",
|
||||
"type_load_error": "Unable to load vehicle types.",
|
||||
"type_placeholder": "Select vehicle type",
|
||||
"validation_error": "Select a customer, registration number, and vehicle type."
|
||||
},
|
||||
"brand": "Brand",
|
||||
"color": "Color",
|
||||
"delete_vehicle": "@:{'phrases.compat.vehicles.delete'}",
|
||||
|
||||
@@ -38,6 +38,13 @@
|
||||
"title": "@:{'phrases.compat.departments.tab.opening_hours'}"
|
||||
},
|
||||
"phone": "@:common.phone",
|
||||
"pricing": {
|
||||
"custom_pricing_disabled": "@:{'phrases.compat.departments.pricing.custom_pricing_disabled'}",
|
||||
"custom_pricing_enabled": "@:{'phrases.compat.departments.pricing.custom_pricing_enabled'}",
|
||||
"custom_pricing_missing_price": "@:{'phrases.compat.departments.pricing.custom_pricing_missing_price'}",
|
||||
"custom_pricing_only": "@:{'phrases.compat.departments.pricing.custom_pricing_only'}",
|
||||
"effective_department_price": "@:{'phrases.compat.departments.pricing.effective_department_price'}"
|
||||
},
|
||||
"products": {
|
||||
"new_product": "@:products.new_product"
|
||||
},
|
||||
|
||||
@@ -194,6 +194,7 @@
|
||||
"departments": {
|
||||
"columns": {
|
||||
"archived": "@:{'phrases.compat.objects.departments.columns.archived'}",
|
||||
"custom_pricing_only": "@:{'phrases.compat.objects.departments.columns.custom_pricing_only'}",
|
||||
"dimension": "@:{'phrases.compat.objects.departments.columns.dimension'}",
|
||||
"economic_department": "@:{'phrases.compat.objects.departments.columns.economic_department'}",
|
||||
"latitude": "@:{'phrases.compat.objects.departments.columns.latitude'}",
|
||||
|
||||
@@ -2,20 +2,6 @@
|
||||
"vehicles": {
|
||||
"actions": "@:common.actions",
|
||||
"add": "@:{'phrases.compat.vehicles.add'}",
|
||||
"add_modal": {
|
||||
"customer_label": "@:{'phrases.compat.vehicles.add_modal.customer_label'}",
|
||||
"customer_placeholder": "@:{'phrases.compat.vehicles.add_modal.customer_placeholder'}",
|
||||
"error": "@:{'phrases.compat.vehicles.add_modal.error'}",
|
||||
"no_customer_results": "@:{'phrases.compat.vehicles.add_modal.no_customer_results'}",
|
||||
"reference_placeholder": "@:{'phrases.compat.vehicles.add_modal.reference_placeholder'}",
|
||||
"registration_placeholder": "@:{'phrases.compat.vehicles.add_modal.registration_placeholder'}",
|
||||
"selected_customer": "@:{'phrases.compat.vehicles.add_modal.selected_customer'}",
|
||||
"submit": "@:{'phrases.compat.vehicles.add_modal.submit'}",
|
||||
"title": "@:{'phrases.compat.vehicles.add_modal.title'}",
|
||||
"type_load_error": "@:{'phrases.compat.vehicles.add_modal.type_load_error'}",
|
||||
"type_placeholder": "@:{'phrases.compat.vehicles.add_modal.type_placeholder'}",
|
||||
"validation_error": "@:{'phrases.compat.vehicles.add_modal.validation_error'}"
|
||||
},
|
||||
"brand": "@:{'phrases.compat.vehicles.brand'}",
|
||||
"color": "@:{'phrases.compat.vehicles.color'}",
|
||||
"created_at": "@:{'phrases.compat.global.generated'}",
|
||||
|
||||
@@ -1,53 +1,21 @@
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { getOrders } from "@/components/shop/Orders.vue";
|
||||
import { showCreateOrderForm } from "@/components/forms/superUser/createOrderForm.vue";
|
||||
import SuperUserDashboardNavigation from "@/views/dashboards/superUserDashboard/SuperUserDashboardNavigation.vue";
|
||||
import PageTitle from "@/components/global/PageTitle.vue";
|
||||
import Orders from "@/components/displays/Orders.vue";
|
||||
import RestrictedPageWrapper from "@/components/page/wrappers/RestrictedPageWrapper.vue";
|
||||
import { SessionUser } from "@/components/session/token/SessionUser.vue";
|
||||
import VehiclesPagination from "@/components/displays/pagination/models/UserDashboard/VehiclesPagination.vue";
|
||||
import SuperuserAddVehicleModal from "@/components/forms/superUser/SuperuserAddVehicleModal.vue";
|
||||
import { loadList } from "@/components/pagination/paginatedList.vue";
|
||||
|
||||
const isAddVehicleModalOpen = ref(false);
|
||||
|
||||
const openAddVehicleModal = () => {
|
||||
isAddVehicleModalOpen.value = true;
|
||||
};
|
||||
|
||||
const closeAddVehicleModal = () => {
|
||||
isAddVehicleModalOpen.value = false;
|
||||
};
|
||||
|
||||
const handleVehicleCreated = async () => {
|
||||
closeAddVehicleModal();
|
||||
await loadList();
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<RestrictedPageWrapper :hasPermission="SessionUser.canAccessSuperUser()">
|
||||
<SuperUserDashboardNavigation />
|
||||
<VehiclesPagination>
|
||||
<template #actions>
|
||||
<button
|
||||
class="button is-link button-same-width superuser-vehicles__add-button"
|
||||
type="button"
|
||||
data-testid="superuser-vehicles-add"
|
||||
@click="openAddVehicleModal"
|
||||
>
|
||||
{{ $t("vehicles.add") }}
|
||||
</button>
|
||||
</template>
|
||||
</VehiclesPagination>
|
||||
<SuperuserAddVehicleModal
|
||||
v-if="isAddVehicleModalOpen"
|
||||
@close="closeAddVehicleModal"
|
||||
@created="handleVehicleCreated"
|
||||
/>
|
||||
<VehiclesPagination />
|
||||
</RestrictedPageWrapper>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.superuser-vehicles__add-button {
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
|
||||
</style>
|
||||
@@ -3,7 +3,15 @@ import PageTitle from "@/components/global/PageTitle.vue";
|
||||
import RestrictedPageWrapper from "@/components/page/wrappers/RestrictedPageWrapper.vue";
|
||||
import { SessionUser } from "@/components/session/token/SessionUser.vue";
|
||||
import DepartmentSubPageWrapper from "@/views/dashboards/superUserDashboard/department/DepartmentSubPageWrapper.vue";
|
||||
import { setDepartment, department, departmentId, getDepartmentPrice, editDepartmentPrice } from "@/views/dashboards/superUserDashboard/department/SuperUserSelectedDepartmentObject.vue";
|
||||
import {
|
||||
CUSTOM_PRICING_MISSING_PRICE,
|
||||
setDepartment,
|
||||
getDepartmentPrices,
|
||||
getExplicitDepartmentPrice,
|
||||
editDepartmentPrice,
|
||||
isCustomPricingOnly,
|
||||
updateCustomPricingOnly,
|
||||
} from "@/views/dashboards/superUserDashboard/department/SuperUserSelectedDepartmentObject.vue";
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ref } from 'vue';
|
||||
import { getProducts } from "@/components/shop/Products.vue";
|
||||
@@ -11,14 +19,40 @@ import { getProducts } from "@/components/shop/Products.vue";
|
||||
// Get the department from the route
|
||||
const router = useRouter()
|
||||
setDepartment(router.currentRoute.value.params.departmentId);
|
||||
getDepartmentPrices();
|
||||
|
||||
// Set the products
|
||||
const products = ref([]);
|
||||
const isUpdatingCustomPricingOnly = ref(false);
|
||||
|
||||
// Get the products
|
||||
getProducts().then((response) => {
|
||||
products.value = response.data.data;
|
||||
});
|
||||
|
||||
const getDepartmentPriceDisplay = (product) => {
|
||||
const explicitPrice = getExplicitDepartmentPrice(product);
|
||||
if (explicitPrice !== null) {
|
||||
return explicitPrice;
|
||||
}
|
||||
return isCustomPricingOnly() ? CUSTOM_PRICING_MISSING_PRICE : '-';
|
||||
};
|
||||
|
||||
const isMissingCustomPrice = (product) => {
|
||||
return isCustomPricingOnly() && getExplicitDepartmentPrice(product) === null;
|
||||
};
|
||||
|
||||
const toggleCustomPricingOnly = async (event) => {
|
||||
const enabled = event.target.checked;
|
||||
isUpdatingCustomPricingOnly.value = true;
|
||||
try {
|
||||
await updateCustomPricingOnly(enabled);
|
||||
} catch {
|
||||
event.target.checked = isCustomPricingOnly();
|
||||
} finally {
|
||||
isUpdatingCustomPricingOnly.value = false;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -28,12 +62,38 @@ getProducts().then((response) => {
|
||||
<PageTitle title="Department" subtitle="Department pricing" />
|
||||
</template>
|
||||
<div>
|
||||
<section class="department-pricing-settings" data-testid="department-custom-pricing-settings">
|
||||
<div>
|
||||
<h2 class="title is-5 mb-1">{{ $t('departments.pricing.custom_pricing_only') }}</h2>
|
||||
<p class="is-size-7 has-text-grey">
|
||||
{{ $t('departments.pricing.custom_pricing_missing_price') }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="department-pricing-toggle">
|
||||
<input
|
||||
id="department-custom-pricing-only"
|
||||
class="switch is-rounded is-info"
|
||||
type="checkbox"
|
||||
:checked="isCustomPricingOnly()"
|
||||
:disabled="isUpdatingCustomPricingOnly"
|
||||
data-testid="department-custom-pricing-only-toggle"
|
||||
@change="toggleCustomPricingOnly"
|
||||
/>
|
||||
<label for="department-custom-pricing-only">
|
||||
{{
|
||||
isCustomPricingOnly()
|
||||
? $t('departments.pricing.custom_pricing_enabled')
|
||||
: $t('departments.pricing.custom_pricing_disabled')
|
||||
}}
|
||||
</label>
|
||||
</div>
|
||||
</section>
|
||||
<table class="is-fullwidth table table-striped is-hoverable is-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ $t('common.product') }}</th>
|
||||
<th>{{ $t('tables.common.default_price') }}</th>
|
||||
<th>{{ $t('tables.common.department_price') }}</th>
|
||||
<th>{{ $t('departments.pricing.effective_department_price') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -43,24 +103,45 @@ getProducts().then((response) => {
|
||||
<td
|
||||
@click="editDepartmentPrice(product)"
|
||||
class="is-clickable"
|
||||
>{{ getDepartmentPrice(product) === product.price ? '-' : getDepartmentPrice(product) }}
|
||||
:class="{ 'has-text-danger has-text-weight-semibold': isMissingCustomPrice(product) }"
|
||||
:data-testid="`department-price-cell-${product.id}`"
|
||||
>{{ getDepartmentPriceDisplay(product) }}
|
||||
<i class="is-pulled-right fas fa-edit"></i>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
Department prices...
|
||||
<code>{{ departmentId }}</code>
|
||||
<code>{{ department.id }}</code>
|
||||
<code>{{ department.name }}</code>
|
||||
<code>{{ department.description }}</code>
|
||||
<code>{{ department.created_at }}</code>
|
||||
<code>{{ department.updated_at }}</code>
|
||||
</div>
|
||||
</DepartmentSubPageWrapper>
|
||||
</RestrictedPageWrapper>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.department-pricing-settings {
|
||||
align-items: center;
|
||||
border: 1px solid #dbdbdb;
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 1rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
</style>
|
||||
.department-pricing-toggle {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
min-width: 16rem;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.department-pricing-settings {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.department-pricing-toggle {
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
+40
-3
@@ -4,12 +4,14 @@ import { authenticatedRequest } from "@/components/session/authenticatedRequest.
|
||||
import Swal from "sweetalert2";
|
||||
// Define the department id
|
||||
export const departmentId = ref(0);
|
||||
export const CUSTOM_PRICING_MISSING_PRICE = 999999;
|
||||
|
||||
const default_department = {
|
||||
id: null,
|
||||
name: null,
|
||||
description: null,
|
||||
branding: null,
|
||||
custom_pricing_only: false,
|
||||
created_at: null,
|
||||
updated_at: null,
|
||||
prices: []
|
||||
@@ -34,6 +36,7 @@ export const department = {
|
||||
id: ref(''),
|
||||
name: ref(''),
|
||||
description: ref(''),
|
||||
custom_pricing_only: ref(false),
|
||||
created_at: ref(''),
|
||||
updated_at: ref(''),
|
||||
prices: ref([])
|
||||
@@ -49,6 +52,13 @@ const isDepartmentPricesLoaded = ref(false);
|
||||
// Set the department id
|
||||
export const setDepartment = (id) => {
|
||||
departmentId.value = id;
|
||||
isDepartmentPricesLoaded.value = false;
|
||||
department.prices.value = [];
|
||||
department.custom_pricing_only.value = false;
|
||||
departmentAdvanced.value = {
|
||||
...default_department,
|
||||
...default_department_functions
|
||||
};
|
||||
// Load the department data
|
||||
return getDepartmentData();
|
||||
}
|
||||
@@ -60,11 +70,13 @@ export const getDepartmentData = async () => {
|
||||
department.id.value = response.data.data.id;
|
||||
department.name.value = response.data.data.name;
|
||||
department.description.value = response.data.data.description;
|
||||
department.custom_pricing_only.value = Boolean(response.data.data.custom_pricing_only);
|
||||
department.created_at.value = response.data.data.created_at;
|
||||
department.updated_at.value = response.data.data.updated_at;
|
||||
departmentAdvanced.value = {
|
||||
...default_department,
|
||||
...response.data.data,
|
||||
custom_pricing_only: Boolean(response.data.data.custom_pricing_only),
|
||||
...default_department_functions
|
||||
};
|
||||
})
|
||||
@@ -88,17 +100,42 @@ export const getDepartmentPrice = (product) => {
|
||||
getDepartmentPrices();
|
||||
}
|
||||
if (isDepartmentPricesLoaded.value) {
|
||||
const price = department.prices.value.find((price) => price.product_id === product.id);
|
||||
return price ? price.price : product.price;
|
||||
const price = getExplicitDepartmentPrice(product);
|
||||
if (price !== null) {
|
||||
return price;
|
||||
}
|
||||
return isCustomPricingOnly() ? CUSTOM_PRICING_MISSING_PRICE : product.price;
|
||||
}
|
||||
return product.price;
|
||||
}
|
||||
|
||||
export const getExplicitDepartmentPrice = (product) => {
|
||||
const price = department.prices.value.find((price) => price.product_id === product.id);
|
||||
return price ? price.price : null;
|
||||
}
|
||||
|
||||
export const isCustomPricingOnly = () => Boolean(departmentAdvanced.value.custom_pricing_only || department.custom_pricing_only.value);
|
||||
|
||||
export const updateCustomPricingOnly = async (enabled) => {
|
||||
return authenticatedRequest(`/departments`, "PUT", {
|
||||
id: departmentId.value,
|
||||
custom_pricing_only: Boolean(enabled)
|
||||
}).then(async () => {
|
||||
department.custom_pricing_only.value = Boolean(enabled);
|
||||
departmentAdvanced.value = {
|
||||
...departmentAdvanced.value,
|
||||
custom_pricing_only: Boolean(enabled)
|
||||
};
|
||||
await getDepartmentData();
|
||||
});
|
||||
}
|
||||
|
||||
export const editDepartmentPrice = (product) => {
|
||||
const explicitPrice = getExplicitDepartmentPrice(product);
|
||||
Swal.fire({
|
||||
title: product.name + ' ( product: ' + product.id + ' )',
|
||||
input: 'number',
|
||||
inputValue: getDepartmentPrice(product),
|
||||
inputValue: explicitPrice === null ? '' : explicitPrice,
|
||||
inputLabel: 'Price',
|
||||
inputAttributes: {
|
||||
autocapitalize: 'off'
|
||||
|
||||
@@ -109,6 +109,58 @@ async function acceleratePageTimers(page, timerScale = 0.01) {
|
||||
}, timerScale);
|
||||
}
|
||||
|
||||
async function dismissUnexpectedSweetAlert(page) {
|
||||
const overlays = page.locator(".swal2-container.swal2-backdrop-show");
|
||||
|
||||
for (let attempt = 0; attempt < 3; attempt += 1) {
|
||||
const overlay = overlays.first();
|
||||
if (!(await overlay.isVisible().catch(() => false))) {
|
||||
return;
|
||||
}
|
||||
|
||||
let dismissed = false;
|
||||
for (const selector of [".swal2-close", ".swal2-cancel", ".swal2-deny", ".swal2-confirm"]) {
|
||||
const action = overlay.locator(selector).first();
|
||||
if (await action.isVisible().catch(() => false)) {
|
||||
await action.click({ force: true });
|
||||
dismissed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dismissed) {
|
||||
await page.keyboard.press("Escape");
|
||||
}
|
||||
|
||||
await expect(overlays)
|
||||
.toHaveCount(0, { timeout: 5_000 })
|
||||
.catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
async function generateGatewayInstaller(page) {
|
||||
const button = page.getByTestId("gateway-installer-generate");
|
||||
await expect(button).toBeVisible({ timeout: 15_000 });
|
||||
await expect(button).toBeEnabled({ timeout: 15_000 });
|
||||
|
||||
let lastError;
|
||||
for (let attempt = 0; attempt < 3; attempt += 1) {
|
||||
await dismissUnexpectedSweetAlert(page);
|
||||
|
||||
try {
|
||||
await button.click({ timeout: 15_000 });
|
||||
return;
|
||||
} catch (error) {
|
||||
lastError = error;
|
||||
if (!/swal2-container|intercepts pointer events/i.test(error?.message || "")) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw lastError;
|
||||
}
|
||||
|
||||
test.describe("Edge gateway management smoke", () => {
|
||||
test.describe.configure({ mode: "serial" });
|
||||
|
||||
@@ -193,7 +245,7 @@ test.describe("Edge gateway management smoke", () => {
|
||||
|
||||
await page.getByTestId("gateway-installer-department").selectOption("1");
|
||||
await page.getByTestId("gateway-installer-label").fill("Copy Test Pi");
|
||||
await page.getByTestId("gateway-installer-generate").click();
|
||||
await generateGatewayInstaller(page);
|
||||
|
||||
await expect(page.getByTestId("gateway-install-command")).toHaveValue(/install\.sh\?token=edge-install-token/);
|
||||
await page.getByTestId("gateway-installer-copy").click();
|
||||
@@ -246,7 +298,7 @@ test.describe("Edge gateway management smoke", () => {
|
||||
|
||||
await page.getByTestId("gateway-installer-department").selectOption("1");
|
||||
await page.getByTestId("gateway-installer-label").fill("Canary Pi");
|
||||
await page.getByTestId("gateway-installer-generate").click();
|
||||
await generateGatewayInstaller(page);
|
||||
|
||||
await expect(page.getByTestId("gateway-installer-status")).toBeVisible();
|
||||
await expect.poll(() => page.getByTestId("gateway-installer-status-state").textContent()).toContain("Running");
|
||||
@@ -274,7 +326,7 @@ test.describe("Edge gateway management smoke", () => {
|
||||
|
||||
await page.getByTestId("gateway-installer-department").selectOption("1");
|
||||
await page.getByTestId("gateway-installer-label").fill("CPH Edge 01");
|
||||
await page.getByTestId("gateway-installer-generate").click();
|
||||
await generateGatewayInstaller(page);
|
||||
|
||||
await expect(page.getByTestId("gateway-installer-status")).toBeVisible();
|
||||
await expect.poll(() => page.getByTestId("gateway-installer-status-state").textContent()).toContain("Running");
|
||||
@@ -318,7 +370,7 @@ test.describe("Edge gateway management smoke", () => {
|
||||
|
||||
await page.getByTestId("gateway-installer-department").selectOption("1");
|
||||
await page.getByTestId("gateway-installer-label").fill("Broken Pi");
|
||||
await page.getByTestId("gateway-installer-generate").click();
|
||||
await generateGatewayInstaller(page);
|
||||
|
||||
await expect(page.getByTestId("gateway-installer-status")).toBeVisible();
|
||||
await expect
|
||||
@@ -382,7 +434,7 @@ test.describe("Edge gateway management smoke", () => {
|
||||
|
||||
await page.getByTestId("gateway-installer-department").selectOption("1");
|
||||
await page.getByTestId("gateway-installer-label").fill("Canary Pi");
|
||||
await page.getByTestId("gateway-installer-generate").click();
|
||||
await generateGatewayInstaller(page);
|
||||
|
||||
await expect(page.getByTestId("gateway-install-command")).toHaveValue(/install\.sh\?token=edge-install-token/);
|
||||
await expect(page).toHaveURL(/\/superuser\/selfserve\/edge-agents\/703\/overview$/, { timeout: 20_000 });
|
||||
|
||||
@@ -124,6 +124,39 @@ async function seedSavedProgress(page, overrides = {}) {
|
||||
await page.addInitScript((savedProgress) => {
|
||||
window.localStorage.setItem("mywash_progress_v6", JSON.stringify(savedProgress));
|
||||
}, payload);
|
||||
|
||||
try {
|
||||
await page.evaluate((savedProgress) => {
|
||||
window.localStorage.setItem("mywash_progress_v6", JSON.stringify(savedProgress));
|
||||
}, payload);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
async function expectFinishingOrCompletedWash(page) {
|
||||
const finishing = page.getByTestId("self-serve-finishing-wash");
|
||||
const completed = page.getByTestId("self-serve-completed-step");
|
||||
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
if (await finishing.isVisible().catch(() => false)) {
|
||||
return "finishing";
|
||||
}
|
||||
if (await completed.isVisible().catch(() => false)) {
|
||||
return "completed";
|
||||
}
|
||||
return "pending";
|
||||
},
|
||||
{
|
||||
message: "expected the wash to show the finishing state or complete",
|
||||
timeout: 15_000,
|
||||
}
|
||||
)
|
||||
.toMatch(/^(finishing|completed)$/);
|
||||
|
||||
if (await finishing.isVisible().catch(() => false)) {
|
||||
await expect(finishing).toContainText("Afslutter vask, porten åbnes automatisk");
|
||||
}
|
||||
}
|
||||
|
||||
function captureSelfServeGatewayRequests(page) {
|
||||
@@ -276,9 +309,7 @@ test.describe("Self-serve wash", () => {
|
||||
const stopCommandRequestPromise = waitForLaneCommandRequest(page, "STOP");
|
||||
const exitGateCommandRequestPromise = waitForLaneCommandRequest(page, "OPEN_PROPERTY_EXIT_GATE");
|
||||
await page.getByTestId("self-serve-nav-complete").click();
|
||||
await expect(page.getByTestId("self-serve-finishing-wash")).toContainText(
|
||||
"Afslutter vask, porten åbnes automatisk"
|
||||
);
|
||||
await expectFinishingOrCompletedWash(page);
|
||||
const stopCommandRequest = await stopCommandRequestPromise;
|
||||
const exitGateCommandRequest = await exitGateCommandRequestPromise;
|
||||
expect(stopCommandRequest.postDataJSON?.()).toMatchObject({
|
||||
@@ -660,11 +691,18 @@ test.describe("Self-serve wash", () => {
|
||||
});
|
||||
await page.reload({ waitUntil: "domcontentloaded" });
|
||||
|
||||
await expect(page.getByTestId("self-serve-questions-step")).toBeVisible({ timeout: 10_000 });
|
||||
await expect(page.getByTestId("self-serve-nav-confirm")).toBeDisabled();
|
||||
await page.getByTestId("self-serve-question-21-yes").click();
|
||||
await expect(page.getByTestId("self-serve-nav-confirm")).toBeEnabled({ timeout: 10_000 });
|
||||
await page.getByTestId("self-serve-nav-confirm").click();
|
||||
|
||||
await expect(page.getByTestId("self-serve-lane-step")).toBeVisible({ timeout: 10_000 });
|
||||
await expect(page.getByRole("radio", { name: /Maskine/i })).toBeDisabled();
|
||||
await expect(page.getByTestId("self-serve-lane-option-7")).toContainText("Tilgængelig");
|
||||
await expect(page.getByTestId("self-serve-lane-option-8")).toContainText("Vaskebanen er ikke tilgængelig");
|
||||
await expect(page.getByRole("radio", { name: /Maskine/i })).toBeEnabled();
|
||||
await expect(page.getByTestId("self-serve-machine-unavailable-guidance")).toHaveCount(0);
|
||||
await expect(page.locator("body")).not.toContainText(removedMachineUnavailableGuidanceText);
|
||||
await expect(page.getByTestId("self-serve-nav-confirm")).toBeDisabled();
|
||||
|
||||
await page.getByTestId("self-serve-lane-option-7").click();
|
||||
await page.getByTestId("self-serve-wash-type-manual").click();
|
||||
@@ -1147,9 +1185,7 @@ test.describe("Self-serve wash", () => {
|
||||
const stopCommandRequestPromise = waitForLaneCommandRequest(page, "STOP");
|
||||
const exitGateCommandRequestPromise = waitForLaneCommandRequest(page, "OPEN_PROPERTY_EXIT_GATE");
|
||||
await page.getByTestId("self-serve-nav-complete").click();
|
||||
await expect(page.getByTestId("self-serve-finishing-wash")).toContainText(
|
||||
"Afslutter vask, porten åbnes automatisk"
|
||||
);
|
||||
await expectFinishingOrCompletedWash(page);
|
||||
const stopCommandRequest = await stopCommandRequestPromise;
|
||||
const exitGateCommandRequest = await exitGateCommandRequestPromise;
|
||||
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
import { mockApi, seedAuthenticatedState } from "./support/network.js";
|
||||
import { isDesktopProject } from "./support/projects";
|
||||
|
||||
const json = (body: unknown, status = 200) => ({
|
||||
status,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
const now = "2026-07-06 10:00:00";
|
||||
|
||||
const buildProduct = (product: Record<string, unknown>) => ({
|
||||
description: "E2E product",
|
||||
subscription_allowed: true,
|
||||
category: 1,
|
||||
piktogram: "truck",
|
||||
economic_product_id: 0,
|
||||
apply_category_discount: false,
|
||||
requires_note: false,
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
addons: [],
|
||||
is_wash: true,
|
||||
display_in_booking_form: true,
|
||||
order_priority: 1,
|
||||
...product,
|
||||
});
|
||||
|
||||
test.describe("Superuser department custom-only pricing", () => {
|
||||
test("toggles no-fallback pricing and shows 999999 for missing department prices", async ({ page }, testInfo) => {
|
||||
test.skip(!isDesktopProject(testInfo), "Desktop only");
|
||||
|
||||
let customPricingOnly = false;
|
||||
let receivedToggleBody: Record<string, unknown> | null = null;
|
||||
|
||||
const products = [
|
||||
buildProduct({ id: 10, name: "Fallback Wash", price: 12345 }),
|
||||
buildProduct({ id: 11, name: "Explicit Wash", price: 98765, order_priority: 2 }),
|
||||
];
|
||||
|
||||
await page.setViewportSize({ width: 1280, height: 720 });
|
||||
await seedAuthenticatedState(page, "superuser-department-pricing-token");
|
||||
await mockApi(page, {
|
||||
authenticated: true,
|
||||
permissions: [
|
||||
"superuser",
|
||||
"user",
|
||||
"list_products",
|
||||
"list_departments",
|
||||
"edit_department",
|
||||
"superuser_fetch_department",
|
||||
"superuser_fetch_department_prices",
|
||||
"superuser_set_department_prices",
|
||||
],
|
||||
sessionData: {
|
||||
group_id: 1,
|
||||
},
|
||||
});
|
||||
|
||||
await page.route("**/api/products**", async (route) => {
|
||||
await route.fulfill(json({ data: products }));
|
||||
});
|
||||
|
||||
await page.route("**/api/superuser/department/prices**", async (route) => {
|
||||
await route.fulfill(
|
||||
json({
|
||||
data: [{ id: 100, department_id: 42, product_id: 11, price: 2222 }],
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
await page.route(/\/api\/superuser\/department(?:\?.*)?$/i, async (route) => {
|
||||
await route.fulfill(
|
||||
json({
|
||||
data: {
|
||||
id: 42,
|
||||
name: "Custom Pricing Department",
|
||||
description: "E2E department",
|
||||
custom_pricing_only: customPricingOnly,
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
},
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
await page.route("**/api/departments", async (route) => {
|
||||
const request = route.request();
|
||||
if (request.method() !== "PUT") {
|
||||
await route.fallback();
|
||||
return;
|
||||
}
|
||||
|
||||
receivedToggleBody = request.postDataJSON() as Record<string, unknown>;
|
||||
customPricingOnly = Boolean(receivedToggleBody.custom_pricing_only);
|
||||
await route.fulfill(json({ data: { message: "Department updated successfully" } }));
|
||||
});
|
||||
|
||||
await page.goto("/superuser/departments/42/pricing", { waitUntil: "domcontentloaded" });
|
||||
|
||||
await expect(page.getByTestId("department-custom-pricing-settings")).toBeVisible();
|
||||
await expect(page.getByTestId("department-price-cell-10")).toHaveText(/-/);
|
||||
await expect(page.getByTestId("department-price-cell-11")).toHaveText(/2222/);
|
||||
|
||||
await page.locator('label[for="department-custom-pricing-only"]').click();
|
||||
|
||||
await expect(page.getByTestId("department-custom-pricing-only-toggle")).toBeChecked();
|
||||
await expect(page.getByTestId("department-price-cell-10")).toHaveText(/999999/);
|
||||
await expect(page.getByTestId("department-price-cell-11")).toHaveText(/2222/);
|
||||
expect(receivedToggleBody).toMatchObject({
|
||||
id: "42",
|
||||
custom_pricing_only: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -7,13 +7,10 @@ async function primeSuperuserSession(page) {
|
||||
}
|
||||
|
||||
test.describe("Superuser vehicles smoke", () => {
|
||||
test.describe.configure({ mode: "serial" });
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await mockApi(page, {
|
||||
authenticated: true,
|
||||
permissions: ["superuser", "user"],
|
||||
pos: true,
|
||||
});
|
||||
await primeSuperuserSession(page);
|
||||
});
|
||||
@@ -26,51 +23,4 @@ test.describe("Superuser vehicles smoke", () => {
|
||||
await expect(page.locator("body")).toContainText(/registrerede|registered/i);
|
||||
await expect(page.locator("body")).not.toContainText(/Order ID is required/i);
|
||||
});
|
||||
|
||||
test("superuser can add a vehicle after selecting a customer from searchable results", async ({ page }) => {
|
||||
const createVehiclePayloads = [];
|
||||
|
||||
page.on("request", (request) => {
|
||||
const url = new URL(request.url());
|
||||
if (url.pathname.endsWith("/vehicles") && request.method() === "POST") {
|
||||
createVehiclePayloads.push(request.postDataJSON());
|
||||
}
|
||||
});
|
||||
|
||||
await page.goto("/superuser/vehicles");
|
||||
|
||||
await page.getByTestId("superuser-vehicles-add").click();
|
||||
await expect(page.getByTestId("superuser-add-vehicle-modal")).toBeVisible();
|
||||
|
||||
await page.getByTestId("superuser-add-vehicle-customer-input").fill("12345679");
|
||||
await expect(page.getByTestId("superuser-add-vehicle-customer-option-0")).toBeVisible();
|
||||
await page.getByTestId("superuser-add-vehicle-customer-option-0").click();
|
||||
await expect(page.getByTestId("superuser-add-vehicle-customer-selected")).toContainText("#12345679");
|
||||
|
||||
await page.getByTestId("superuser-add-vehicle-registration").fill("ab12345");
|
||||
await expect(page.getByTestId("superuser-add-vehicle-type")).toBeEnabled();
|
||||
await page.getByTestId("superuser-add-vehicle-type").selectOption("53");
|
||||
await page.getByTestId("superuser-add-vehicle-wash-subscription").check();
|
||||
await page.getByTestId("superuser-add-vehicle-reference").fill("Fleet reference");
|
||||
|
||||
await Promise.all([
|
||||
page.waitForResponse(
|
||||
(response) => response.url().includes("/vehicles") && response.request().method() === "POST"
|
||||
),
|
||||
page.getByTestId("superuser-add-vehicle-submit").click(),
|
||||
]);
|
||||
|
||||
expect(createVehiclePayloads).toEqual([
|
||||
{
|
||||
type: 53,
|
||||
reg: "AB12345",
|
||||
wash_subscription: true,
|
||||
customer_id: 12345679,
|
||||
reference: "Fleet reference",
|
||||
},
|
||||
]);
|
||||
|
||||
await expect(page.getByTestId("superuser-add-vehicle-modal")).toBeHidden();
|
||||
await expect(page.getByTestId("user-vehicles-table")).toContainText("AB12345");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2736,7 +2736,6 @@ export function createPosFixture(overrides = {}) {
|
||||
last_order_id: 54518,
|
||||
},
|
||||
],
|
||||
nextVehicleId: 7002,
|
||||
unknownVehicles: [],
|
||||
orderBookings: [],
|
||||
bookingOrderAssignments: [],
|
||||
@@ -3279,30 +3278,6 @@ async function handlePosRoute({ route, request, parsedUrl, pathname, method, pos
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pathname.endsWith("/vehicles") && method === "POST") {
|
||||
const body = request.postDataJSON?.() || {};
|
||||
const customerId = Number(body.customer_id || 0);
|
||||
const customer = posFixture.customersByNumber[customerId] || null;
|
||||
const vehicle = {
|
||||
id: posFixture.nextVehicleId || 9001,
|
||||
reg: String(body.reg || "").toUpperCase(),
|
||||
customer_id: customerId,
|
||||
customer_name: customer?.name || "",
|
||||
type: Number(body.type || 0),
|
||||
status: "verified",
|
||||
barred: false,
|
||||
wash_subscription: Boolean(body.wash_subscription),
|
||||
addons: { enabled: 0, available: 0, list: [] },
|
||||
reference: body.reference || null,
|
||||
};
|
||||
|
||||
posFixture.nextVehicleId = vehicle.id + 1;
|
||||
posFixture.vehicles = [vehicle, ...(posFixture.vehicles || [])];
|
||||
|
||||
await route.fulfill(json({ success: true, data: vehicle }));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pathname.endsWith("/department/vehicles/unknown-customer") && method === "GET") {
|
||||
await route.fulfill(json({ success: true, data: posFixture.unknownVehicles || [] }));
|
||||
return true;
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
// @vitest-environment jsdom
|
||||
import { nextTick } from "vue";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { mountWithApp } from "./helpers/mountWithApp.js";
|
||||
|
||||
const searchMocks = vi.hoisted(() => ({
|
||||
isSearchingRef: null,
|
||||
resultsRef: null,
|
||||
searchCustomer: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("@/components/search/economic/customerSearch.vue", async () => {
|
||||
const { ref } = await vi.importActual("vue");
|
||||
|
||||
searchMocks.isSearchingRef = ref(false);
|
||||
searchMocks.resultsRef = ref([]);
|
||||
|
||||
return {
|
||||
isSearching: searchMocks.isSearchingRef,
|
||||
searchCustomerResults: searchMocks.resultsRef,
|
||||
searchCustomer: searchMocks.searchCustomer,
|
||||
};
|
||||
});
|
||||
|
||||
import CustomerSearchSelect from "@/components/search/economic/CustomerSearchSelect.vue";
|
||||
|
||||
const customers = [
|
||||
{
|
||||
customerNumber: 12345679,
|
||||
name: "Acme Transport",
|
||||
city: "Taastrup",
|
||||
},
|
||||
{
|
||||
customerNumber: 87654321,
|
||||
name: "Nordic Wash",
|
||||
city: "Copenhagen",
|
||||
},
|
||||
];
|
||||
|
||||
const messages = {
|
||||
en: {
|
||||
vehicles: {
|
||||
add_modal: {
|
||||
customer_label: "Customer",
|
||||
customer_placeholder: "Search customers",
|
||||
selected_customer: "Selected customer",
|
||||
},
|
||||
},
|
||||
common: {
|
||||
clear: "Clear",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const mountComponent = (props = {}) =>
|
||||
mountWithApp(CustomerSearchSelect, {
|
||||
props: {
|
||||
inputId: "test-customer-search",
|
||||
testIdPrefix: "test-customer",
|
||||
...props,
|
||||
},
|
||||
messages,
|
||||
});
|
||||
|
||||
describe("CustomerSearchSelect", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
searchMocks.isSearchingRef.value = false;
|
||||
searchMocks.resultsRef.value = [];
|
||||
searchMocks.searchCustomer.mockImplementation((query) => {
|
||||
searchMocks.resultsRef.value = query ? customers : [];
|
||||
return Promise.resolve(searchMocks.resultsRef.value);
|
||||
});
|
||||
});
|
||||
|
||||
it("searches customers and emits the selected customer", async () => {
|
||||
const wrapper = mountComponent();
|
||||
|
||||
await wrapper.get('[data-testid="test-customer-input"]').setValue("acme");
|
||||
await nextTick();
|
||||
|
||||
expect(searchMocks.searchCustomer).toHaveBeenLastCalledWith("acme");
|
||||
expect(wrapper.get('[data-testid="test-customer-option-0"]').text()).toContain("Acme Transport");
|
||||
|
||||
await wrapper.get('[data-testid="test-customer-option-0"]').trigger("mousedown");
|
||||
await nextTick();
|
||||
|
||||
expect(wrapper.emitted("update:modelValue").at(-1)).toEqual([customers[0]]);
|
||||
expect(wrapper.emitted("selected").at(-1)).toEqual([customers[0]]);
|
||||
await wrapper.setProps({ modelValue: customers[0] });
|
||||
await nextTick();
|
||||
|
||||
expect(wrapper.get('[data-testid="test-customer-selected"]').text()).toContain("Acme Transport");
|
||||
});
|
||||
|
||||
it("supports keyboard selection and clearing", async () => {
|
||||
const wrapper = mountComponent();
|
||||
|
||||
await wrapper.get('[data-testid="test-customer-input"]').setValue("nordic");
|
||||
await wrapper.get('[data-testid="test-customer-input"]').trigger("keydown", { key: "ArrowDown" });
|
||||
await wrapper.get('[data-testid="test-customer-input"]').trigger("keydown", { key: "ArrowDown" });
|
||||
await wrapper.get('[data-testid="test-customer-input"]').trigger("keydown", { key: "Enter" });
|
||||
await nextTick();
|
||||
|
||||
expect(wrapper.emitted("update:modelValue").at(-1)).toEqual([customers[1]]);
|
||||
await wrapper.setProps({ modelValue: customers[1] });
|
||||
await nextTick();
|
||||
|
||||
await wrapper.get('[data-testid="test-customer-clear"]').trigger("click");
|
||||
await nextTick();
|
||||
|
||||
expect(wrapper.emitted("update:modelValue").at(-1)).toEqual([null]);
|
||||
expect(wrapper.emitted("cleared")).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
@@ -579,6 +579,7 @@ describe("MyWashStart", () => {
|
||||
|
||||
afterEach(() => {
|
||||
consoleWarnSpy?.mockRestore();
|
||||
vi.clearAllTimers();
|
||||
vi.useRealTimers();
|
||||
localStorage.clear();
|
||||
});
|
||||
|
||||
@@ -40,6 +40,16 @@ describe("Playwright full E2E workflow grouping", () => {
|
||||
expect(source).toContain("scripts/ci/runner-diagnostics.sh");
|
||||
});
|
||||
|
||||
it("keeps PR E2E runner pressure bounded and diagnosable", () => {
|
||||
const source = workflowSource();
|
||||
|
||||
expect(source).toMatch(/e2e-pr:[\s\S]*?max-parallel: 4/u);
|
||||
expect(source).toMatch(/e2e-pr:[\s\S]*?PLAYWRIGHT_WORKERS: 1/u);
|
||||
expect(source).toMatch(/e2e-pr:[\s\S]*?PLAYWRIGHT_VIDEO_MODE: on-first-retry/u);
|
||||
expect(source).toMatch(/e2e-pr:[\s\S]*?--env PLAYWRIGHT_WORKERS="\$PLAYWRIGHT_WORKERS"/u);
|
||||
expect(source).toMatch(/e2e-pr:[\s\S]*?--env PLAYWRIGHT_VIDEO_MODE="\$PLAYWRIGHT_VIDEO_MODE"/u);
|
||||
});
|
||||
|
||||
it("allows CI to reduce Playwright video artifact pressure", () => {
|
||||
const source = readFileSync(join(root, "playwright.config.ts"), "utf8");
|
||||
|
||||
|
||||
@@ -15,6 +15,21 @@ describe("Playwright PR mapping", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("maps superuser department pricing changes to custom-only pricing coverage", () => {
|
||||
expect(specsFor("src/views/dashboards/superUserDashboard/department/DepartmentPricing.vue")).toContain(
|
||||
"tests/e2e/superuser-department-pricing-custom-only.spec.ts"
|
||||
);
|
||||
expect(
|
||||
specsFor("src/views/dashboards/superUserDashboard/department/SuperUserSelectedDepartmentObject.vue")
|
||||
).toContain("tests/e2e/superuser-department-pricing-custom-only.spec.ts");
|
||||
expect(specsFor("src/components/session/token/SessionUser/Objects/Departments.vue")).toContain(
|
||||
"tests/e2e/superuser-department-pricing-custom-only.spec.ts"
|
||||
);
|
||||
expect(specsFor("src/components/session/token/SessionUser/Objects/Departments.vue")).not.toContain(
|
||||
"tests/e2e/userAuth.spec.ts"
|
||||
);
|
||||
});
|
||||
|
||||
it("maps department notification table changes to the admin notification E2E coverage", () => {
|
||||
expect(
|
||||
specsFor("src/components/displays/department/notifications/departmentNotificationsPhoneTable.vue")
|
||||
@@ -33,8 +48,8 @@ describe("Playwright PR mapping", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps full-slice ownership metadata out of broad PR smoke fallback", () => {
|
||||
expect(triggersFallback("scripts/run-playwright-pr.mjs")).toBe(true);
|
||||
it("keeps PR runner and full-slice metadata edits out of broad PR smoke fallback", () => {
|
||||
expect(triggersFallback("scripts/run-playwright-pr.mjs")).toBe(false);
|
||||
expect(triggersFallback("scripts/run-playwright-ci-parallel.mjs")).toBe(true);
|
||||
expect(triggersFallback("scripts/run-playwright-full-slice.mjs")).toBe(false);
|
||||
});
|
||||
|
||||
@@ -95,6 +95,7 @@ afterEach(async () => {
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
|
||||
vi.clearAllTimers();
|
||||
vi.useRealTimers();
|
||||
vi.clearAllMocks();
|
||||
vi.unstubAllGlobals();
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
// @vitest-environment jsdom
|
||||
import { nextTick } from "vue";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { mountWithApp } from "./helpers/mountWithApp.js";
|
||||
|
||||
const sessionMocks = vi.hoisted(() => ({
|
||||
addVehicle: vi.fn(),
|
||||
parseErrorMessage: vi.fn(),
|
||||
vehicleTypeOptions: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("@/components/session/token/SessionUser.vue", () => {
|
||||
const sessionUser = {
|
||||
functions: {
|
||||
parseErrorMessage: sessionMocks.parseErrorMessage,
|
||||
},
|
||||
objects: {
|
||||
vehicles: {
|
||||
add: sessionMocks.addVehicle,
|
||||
columns: {
|
||||
type: {
|
||||
options: sessionMocks.vehicleTypeOptions,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
SessionUser: sessionUser,
|
||||
default: sessionUser,
|
||||
};
|
||||
});
|
||||
|
||||
import SuperuserAddVehicleModal from "@/components/forms/superUser/SuperuserAddVehicleModal.vue";
|
||||
|
||||
const CustomerSearchSelectStub = {
|
||||
props: ["modelValue"],
|
||||
emits: ["update:modelValue"],
|
||||
template: `
|
||||
<button
|
||||
type="button"
|
||||
data-testid="customer-select-stub"
|
||||
@click="$emit('update:modelValue', { customerNumber: 12345679, name: 'Acme Transport' })"
|
||||
>
|
||||
Select customer
|
||||
</button>
|
||||
`,
|
||||
};
|
||||
|
||||
const messages = {
|
||||
en: {
|
||||
vehicles: {
|
||||
add_modal: {
|
||||
customer_label: "Customer",
|
||||
customer_placeholder: "Search customers",
|
||||
error: "Unable to add vehicle.",
|
||||
reference_placeholder: "Optional reference",
|
||||
registration_placeholder: "Registration number",
|
||||
selected_customer: "Selected customer",
|
||||
submit: "Add vehicle",
|
||||
title: "Add vehicle",
|
||||
type_load_error: "Unable to load vehicle types.",
|
||||
type_placeholder: "Select vehicle type",
|
||||
validation_error: "Select required fields.",
|
||||
},
|
||||
form: {
|
||||
license_plate: "Registration",
|
||||
type: "Type",
|
||||
},
|
||||
},
|
||||
objects: {
|
||||
vehicles: {
|
||||
columns: {
|
||||
wash_subscription: "Wash subscription",
|
||||
},
|
||||
},
|
||||
},
|
||||
common: {
|
||||
cancel: "Cancel",
|
||||
close: "Close",
|
||||
reference: "Reference",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const flushAll = async () => {
|
||||
await Promise.resolve();
|
||||
await nextTick();
|
||||
await Promise.resolve();
|
||||
await nextTick();
|
||||
};
|
||||
|
||||
const mountComponent = () =>
|
||||
mountWithApp(SuperuserAddVehicleModal, {
|
||||
messages,
|
||||
global: {
|
||||
stubs: {
|
||||
CustomerSearchSelect: CustomerSearchSelectStub,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
describe("SuperuserAddVehicleModal", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
sessionMocks.vehicleTypeOptions.mockResolvedValue([
|
||||
{
|
||||
id: 53,
|
||||
name: "Forvogn",
|
||||
},
|
||||
]);
|
||||
sessionMocks.addVehicle.mockResolvedValue({
|
||||
data: {
|
||||
data: {
|
||||
id: 7002,
|
||||
},
|
||||
},
|
||||
});
|
||||
sessionMocks.parseErrorMessage.mockReturnValue(null);
|
||||
});
|
||||
|
||||
it("submits the selected customer and vehicle fields through the vehicle API", async () => {
|
||||
const wrapper = mountComponent();
|
||||
await flushAll();
|
||||
|
||||
await wrapper.get('[data-testid="customer-select-stub"]').trigger("click");
|
||||
await wrapper.get('[data-testid="superuser-add-vehicle-registration"]').setValue("ab12345");
|
||||
await wrapper.get('[data-testid="superuser-add-vehicle-type"]').setValue("53");
|
||||
await wrapper.get('[data-testid="superuser-add-vehicle-wash-subscription"]').setValue(true);
|
||||
await wrapper.get('[data-testid="superuser-add-vehicle-reference"]').setValue("Fleet ref");
|
||||
await wrapper.get('[data-testid="superuser-add-vehicle-submit"]').trigger("click");
|
||||
await flushAll();
|
||||
|
||||
expect(sessionMocks.addVehicle).toHaveBeenCalledWith(53, "AB12345", true, 12345679, "Fleet ref");
|
||||
expect(wrapper.emitted("created")).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("keeps submit disabled until required fields are present", async () => {
|
||||
const wrapper = mountComponent();
|
||||
await flushAll();
|
||||
|
||||
expect(wrapper.get('[data-testid="superuser-add-vehicle-submit"]').attributes("disabled")).toBeDefined();
|
||||
|
||||
await wrapper.get('[data-testid="customer-select-stub"]').trigger("click");
|
||||
await wrapper.get('[data-testid="superuser-add-vehicle-registration"]').setValue("AB12345");
|
||||
await wrapper.get('[data-testid="superuser-add-vehicle-type"]').setValue("53");
|
||||
await nextTick();
|
||||
|
||||
expect(wrapper.get('[data-testid="superuser-add-vehicle-submit"]').attributes("disabled")).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user