UI: allow vehicle charging limit below 20%, include api-set values (#32460)

This commit is contained in:
Michael Geers 2026-08-03 08:52:44 +02:00 • committed by GitHub
parent 5555395cd7
commit ac5d384e39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 3 deletions

View file

@ -40,11 +40,15 @@ export default defineComponent({
}, },
options() { options() {
const result = []; const result = [];
const start = this.rangeActive ? this.minTemp : 20; const start = this.rangeActive ? this.minTemp : 5;
const end = this.rangeActive ? this.maxTemp : 100; const end = this.rangeActive ? this.maxTemp : 100;
for (let soc = start; soc <= end; soc += this.step) { for (let soc = start; soc <= end; soc += this.step) {
const name = this.fmtSocOption(soc, this.rangePerSoc, distanceUnit(), this.heating); result.push(this.socOption(soc));
result.push({ value: soc, name }); }
// include current value if it's not in the list
if (this.limitSoc && !result.some((o) => o.value === this.limitSoc)) {
result.push(this.socOption(this.limitSoc));
result.sort((a, b) => a.value - b.value);
} }
return result; return result;
}, },
@ -61,6 +65,10 @@ export default defineComponent({
}, },
}, },
methods: { methods: {
socOption(soc: number) {
const name = this.fmtSocOption(soc, this.rangePerSoc, distanceUnit(), this.heating);
return { value: soc, name };
},
change(e: Event) { change(e: Event) {
return this.$emit( return this.$emit(
"limit-soc-updated", "limit-soc-updated",

View file

@ -44,6 +44,17 @@ test.describe("limitSoc", async () => {
await expect(page.getByTestId("limit-soc-value")).toHaveText("50%"); await expect(page.getByTestId("limit-soc-value")).toHaveText("50%");
}); });
test("starts at 5% and includes api-set values", async ({ page, request }) => {
await page.goto("/");
const combobox = page.getByTestId("limit-soc").getByRole("combobox");
await expect(combobox.getByRole("option").first()).toHaveText("5%");
await request.post("/api/loadpoints/1/limitsoc/42");
await expect(page.getByTestId("limit-soc-value")).toHaveText("42%");
await expect(combobox.getByRole("option", { name: "42%" })).toHaveCount(1);
});
test("can be set even if vehicle isn't connected yet", async ({ page }) => { test("can be set even if vehicle isn't connected yet", async ({ page }) => {
await page.goto(simulatorUrl()); await page.goto(simulatorUrl());
await page.getByTestId("loadpoint0").getByText("A (disconnected)").click(); await page.getByTestId("loadpoint0").getByText("A (disconnected)").click();