diff --git a/assets/js/components/Loadpoints/SettingsModal.vue b/assets/js/components/Loadpoints/SettingsModal.vue index dfc7e53d5..8c42db1a0 100644 --- a/assets/js/components/Loadpoints/SettingsModal.vue +++ b/assets/js/components/Loadpoints/SettingsModal.vue @@ -67,8 +67,8 @@ $t( `main.loadpointSettings.phasesConfigured.phases_${phases}_hint`, { - min: minPowerPhases(phases), - max: maxPowerPhases(phases), + min: fmtPhasePower(minCurrent, phases), + max: fmtPhasePower(maxCurrent, phases), } ) }} @@ -82,11 +82,11 @@ -
+
- ~ {{ maxPower }}
@@ -105,11 +104,11 @@ -
+
- ~ {{ minPower }}
@@ -213,39 +211,29 @@ export default defineComponent({ batteryBoostProps() { return this.collectProps(SettingsBatteryBoost); }, - maxPower() { - if (this.chargerPhases1p3p) { - if (this.phasesConfigured === AUTO) { - return this.maxPowerPhases(THREE_PHASES); - } - if ([THREE_PHASES, ONE_PHASE].includes(this.phasesConfigured)) { - return this.maxPowerPhases(this.phasesConfigured); - } + maxPhases(): number { + if (this.chargerPhases1p3p && this.phasesConfigured === AUTO) { + return THREE_PHASES; } - return this.fmtW(this.maxCurrent * V * this.phasesConfigured); + return this.phasesConfigured; }, - minPower() { - if (this.chargerPhases1p3p) { - if (this.phasesConfigured === AUTO) { - return this.minPowerPhases(ONE_PHASE); - } - if ([THREE_PHASES, ONE_PHASE].includes(this.phasesConfigured)) { - return this.minPowerPhases(this.phasesConfigured); - } + minPhases(): number { + if (this.chargerPhases1p3p && this.phasesConfigured === AUTO) { + return ONE_PHASE; } - return this.fmtW(this.minCurrent * V * this.phasesConfigured); + return this.phasesConfigured; }, minCurrentOptions() { const opt1 = [...range(Math.floor(this.maxCurrent), 1), 0.5, 0.25, 0.125]; // ensure that current value is always included const opt2 = insertSorted(opt1, this.minCurrent); - return opt2.map((value) => this.currentOption(value, value === 6)); + return opt2.map((value) => this.currentOption(value, value === 6, this.minPhases)); }, maxCurrentOptions() { const opt1 = range(MAX_CURRENT, Math.ceil(this.minCurrent)); // ensure that current value is always included const opt2 = insertSorted(opt1, this.maxCurrent); - return opt2.map((value) => this.currentOption(value, value === 16)); + return opt2.map((value) => this.currentOption(value, value === 16, this.maxPhases)); }, loadpointId() { @@ -264,11 +252,8 @@ export default defineComponent({ }, }, methods: { - maxPowerPhases(phases: PHASES) { - return this.fmtW(this.maxCurrent * V * phases); - }, - minPowerPhases(phases: PHASES) { - return this.fmtW(this.minCurrent * V * phases); + fmtPhasePower(current: number, phases: PHASES) { + return this.fmtW(V * current * phases); }, formId(name: string) { return `loadpoint_${this.id}_${name}`; @@ -282,12 +267,13 @@ export default defineComponent({ changePhasesConfigured() { this.$emit("phasesconfigured-updated", this.selectedPhases); }, - currentOption(value: number, isDefault: boolean) { - let name = `${this.fmtNumber(value, value <= 1 ? undefined : 0)} A`; + currentOption(current: number, isDefault: boolean, phases: number) { + const kw = this.fmtPhasePower(current, phases); + let name = `${this.fmtNumber(current, current <= 1 ? undefined : 0)} A (${kw})`; if (isDefault) { - name += ` (${this.$t("main.loadpointSettings.default")})`; + name += ` [${this.$t("main.loadpointSettings.default")}]`; } - return { value, name }; + return { value: current, name }; }, modalVisible() { this.isModalVisible = true; diff --git a/tests/basics.spec.ts b/tests/basics.spec.ts index 98a8fc152..b3bb856f5 100644 --- a/tests/basics.spec.ts +++ b/tests/basics.spec.ts @@ -69,16 +69,19 @@ test.describe("session info", async () => { test.describe("loadpoint settings", async () => { test("phase selection", async ({ page }) => { + const minCurrentSelected = page.getByLabel("Min. current").locator("option:checked"); + const maxCurrentSelected = page.getByLabel("Max. current").locator("option:checked"); + await page.getByTestId("loadpoint-settings-button").nth(1).click(); await expect(page.getByLabel("auto-switching")).not.toBeVisible(); await expect(page.getByLabel("3 phase")).toBeChecked(); await expect(page.getByLabel("1 phase")).not.toBeChecked(); - await expect(page.getByText("~ 11.0 kW")).toBeVisible(); - await expect(page.getByText("~ 4.1 kW")).toBeVisible(); + await expect(maxCurrentSelected).toHaveText("16 A (11.0 kW) [default]"); + await expect(minCurrentSelected).toHaveText("6 A (4.1 kW) [default]"); await page.getByLabel("1 phase").click(); - await expect(page.getByText("~ 3.7 kW")).toBeVisible(); - await expect(page.getByText("~ 1.4 kW")).toBeVisible(); + await expect(maxCurrentSelected).toHaveText("16 A (3.7 kW) [default]"); + await expect(minCurrentSelected).toHaveText("6 A (1.4 kW) [default]"); }); }); diff --git a/tests/currents.spec.ts b/tests/currents.spec.ts index 549cd61c8..c3a38bcfb 100644 --- a/tests/currents.spec.ts +++ b/tests/currents.spec.ts @@ -22,22 +22,22 @@ test.describe("currents", async () => { await expectModalVisible(modal); const minCurrent = modal.getByLabel("Min. current"); + const minCurrentSelected = minCurrent.locator("option:checked"); const maxCurrent = modal.getByLabel("Max. current"); - const minPower = modal.getByTestId("min-power"); - const maxPower = modal.getByTestId("max-power"); + const maxCurrentSelected = maxCurrent.locator("option:checked"); // initial values await expect(maxCurrent).toHaveValue("16"); - await expect(maxPower).toContainText("~ 11.0 kW"); + await expect(maxCurrentSelected).toHaveText("16 A (11.0 kW) [default]"); await expect(minCurrent).toHaveValue("6"); - await expect(minPower).toContainText("~ 4.1 kW"); + await expect(minCurrentSelected).toHaveText("6 A (4.1 kW) [default]"); // change min current - await minCurrent.selectOption("0.125 A"); - await expect(minPower).toContainText("~ 0.1 kW"); + await minCurrent.selectOption("0.125 A (0.1 kW)"); + await expect(minCurrentSelected).toHaveText("0.125 A (0.1 kW)"); // change max current - await maxCurrent.selectOption("32 A"); - await expect(maxPower).toContainText("~ 22.1 kW"); + await maxCurrent.selectOption("32 A (22.1 kW)"); + await expect(maxCurrentSelected).toHaveText("32 A (22.1 kW)"); }); });