Add co2 grid charge tests (#22444)

Co-authored-by: Michael Geers <michael@geers.tv>
This commit is contained in:
andig 2025-07-28 10:01:55 +02:00 • committed by GitHub
parent a6da7a5d77
commit 7761979913
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 101 additions and 0 deletions

View file

@ -0,0 +1,66 @@
interval: 0.1s
site:
title: Battery Settings
meters:
grid: grid
pv: pv
battery: battery
meters:
- name: grid
type: custom
power:
source: const
value: 1000
- name: pv
type: custom
power:
source: const
value: 2000
- name: battery
type: custom
power:
source: const
value: -1000
soc:
source: const
value: 50
capacity: 20
batterymode:
source: js
vm: shared
script: |
1
loadpoints:
- title: Carport
charger: charger
mode: now
chargers:
- name: charger
type: custom
enable:
source: js
script:
enabled:
source: js
script: |
true
status:
source: js
script: |
"B"
maxcurrent:
source: js
script: |
16
tariffs:
currency: EUR
co2:
type: template
template: demo-co2-forecast
base: 80.7
variation: 1.07

View file

@ -0,0 +1,35 @@
import { test, expect } from "@playwright/test";
import { start, stop, baseUrl } from "./evcc";
import { expectModalVisible, expectModalHidden, openTopNavigation } from "./utils";
test.use({ baseURL: baseUrl() });
test.beforeAll(async () => {
await start("battery-settings-co2.evcc.yaml");
});
test.afterAll(async () => {
await stop();
});
test.describe("battery settings co2", async () => {
test("grid charging", async ({ page }) => {
await page.goto("/");
await openTopNavigation(page);
await page.getByTestId("topnavigation-battery").click();
const modal = page.getByTestId("battery-settings-modal");
await expectModalVisible(modal);
await modal.getByRole("link", { name: "Grid charging" }).click();
await modal.getByLabel("CO₂ limit").selectOption({ label: "≤ 150 g/kWh" });
await expect(modal).toContainText("20 g – 150 g");
await page.getByRole("button", { name: "Close" }).click();
await expectModalHidden(modal);
await page.getByTestId("energyflow").click();
await page.getByRole("button", { name: "grid charging active (≤ 150 g)" }).click();
await expectModalVisible(modal);
await modal.getByLabel("CO₂ limit").selectOption({ label: "≤ 40 g/kWh" });
await modal.getByRole("button", { name: "Close" }).click();
await expectModalHidden(modal);
await expect(modal).not.toBeVisible();
await expect(page.getByRole("button", { name: "grid charging when ≤ 40 g" })).toBeVisible();
});
});