UI: allow vehicle charging limit below 20%, include api-set values (#32460)
This commit is contained in:
parent
5555395cd7
commit
ac5d384e39
2 changed files with 22 additions and 3 deletions
|
|
@ -40,11 +40,15 @@ export default defineComponent({
|
|||
},
|
||||
options() {
|
||||
const result = [];
|
||||
const start = this.rangeActive ? this.minTemp : 20;
|
||||
const start = this.rangeActive ? this.minTemp : 5;
|
||||
const end = this.rangeActive ? this.maxTemp : 100;
|
||||
for (let soc = start; soc <= end; soc += this.step) {
|
||||
const name = this.fmtSocOption(soc, this.rangePerSoc, distanceUnit(), this.heating);
|
||||
result.push({ value: soc, name });
|
||||
result.push(this.socOption(soc));
|
||||
}
|
||||
// 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;
|
||||
},
|
||||
|
|
@ -61,6 +65,10 @@ export default defineComponent({
|
|||
},
|
||||
},
|
||||
methods: {
|
||||
socOption(soc: number) {
|
||||
const name = this.fmtSocOption(soc, this.rangePerSoc, distanceUnit(), this.heating);
|
||||
return { value: soc, name };
|
||||
},
|
||||
change(e: Event) {
|
||||
return this.$emit(
|
||||
"limit-soc-updated",
|
||||
|
|
|
|||
|
|
@ -44,6 +44,17 @@ test.describe("limitSoc", async () => {
|
|||
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 }) => {
|
||||
await page.goto(simulatorUrl());
|
||||
await page.getByTestId("loadpoint0").getByText("A (disconnected)").click();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue