Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ func (s *HTTPd) RegisterSystemHandler(site *core.Site, valueChan chan<- util.Par
"deletedevice": {"DELETE", "/devices/{class:[a-z]+}/{id:[0-9.]+}", deleteDeviceHandler(site)},
"testconfig": {"POST", "/test/{class:[a-z]+}", testConfigHandler},
"testmerged": {"POST", "/test/{class:[a-z]+}/merge/{id:[0-9.]+}", testConfigHandler},
"interval": {"POST", "/interval/{value:[0-9.]+}", settingsSetDurationHandler(keys.Interval)},
"updatesponsortoken": {"POST", "/sponsortoken", updateSponsortokenHandler},
"deletesponsortoken": {"DELETE", "/sponsortoken", deleteSponsorTokenHandler},
"interval": {"POST", "/interval/{value:[0-9.]+}", settingsSetDurationHandler(keys.Interval, valueChan)},
"updatesponsortoken": {"POST", "/sponsortoken", updateSponsortokenHandler(valueChan)},
"deletesponsortoken": {"DELETE", "/sponsortoken", deleteSponsorTokenHandler(valueChan)},
}

// yaml handlers
Expand Down
54 changes: 33 additions & 21 deletions server/http_config_site_other_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,48 @@ import (

"github.com/evcc-io/evcc/core/keys"
"github.com/evcc-io/evcc/server/db/settings"
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/util/sponsor"
)

func updateSponsortokenHandler(w http.ResponseWriter, r *http.Request) {
var req struct {
Token string `json:"token"`
}

if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
jsonError(w, http.StatusBadRequest, err)
return
}
func updateSponsortokenHandler(valueChan chan<- util.Param) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req struct {
Token string `json:"token"`
}

if req.Token != "" {
if err := sponsor.ConfigureSponsorship(req.Token); err != nil {
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
jsonError(w, http.StatusBadRequest, err)
return
}
sponsor.SetFromYaml(false)
}

// TODO find better place
settings.SetString(keys.SponsorToken, req.Token)
setConfigDirty()
if req.Token != "" {
if err := sponsor.ConfigureSponsorship(req.Token); err != nil {
jsonError(w, http.StatusBadRequest, err)
return
}
sponsor.SetFromYaml(false)
}

// TODO find better place
settings.SetString(keys.SponsorToken, req.Token)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imho we should move this and the channel handling into a sponsor function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can refactor this into a helper function. Would you prefer a function in the sponsor package that handles both the database save and websocket publish, or a local helper in the handler file?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot move this saving and publishing logic to the sponsor package. Pass uiChan to package on init.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 5aaa62d. Moved sponsor token saving and publishing logic to the sponsor package:

  • Added sponsor.Init(valueChan) called in RegisterSystemHandler
  • Created sponsor.SaveToken() and sponsor.DeleteToken() functions that handle database persistence and websocket publishing
  • Updated handlers to use these new functions
  • Removed valueChan parameter from sponsor handlers

setConfigDirty()

status := sponsor.Status()
valueChan <- util.Param{Key: keys.Sponsor, Val: status}

jsonWrite(w, sponsor.Status())
jsonWrite(w, status)
}
}

func deleteSponsorTokenHandler(w http.ResponseWriter, r *http.Request) {
settings.SetString(keys.SponsorToken, "")
setConfigDirty()
jsonWrite(w, true)
func deleteSponsorTokenHandler(valueChan chan<- util.Param) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
settings.SetString(keys.SponsorToken, "")
setConfigDirty()

status := sponsor.Status()
valueChan <- util.Param{Key: keys.Sponsor, Val: status}

jsonWrite(w, true)
}
}
4 changes: 3 additions & 1 deletion server/http_global_settings_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func settingsDeleteHandler(key string) http.HandlerFunc {
}
}

func settingsSetDurationHandler(key string) http.HandlerFunc {
func settingsSetDurationHandler(key string, valueChan chan<- util.Param) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)

Expand All @@ -41,6 +41,8 @@ func settingsSetDurationHandler(key string) http.HandlerFunc {
settings.SetInt(key, int64(time.Second*time.Duration(val)))
setConfigDirty()

valueChan <- util.Param{Key: key, Val: val}

jsonWrite(w, val)
}
}
Expand Down
70 changes: 70 additions & 0 deletions tests/config-control.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { test, expect } from "@playwright/test";
import { start, stop, baseUrl } from "./evcc";
import { enableExperimental, expectModalVisible, expectModalHidden } from "./utils";

test.use({ baseURL: baseUrl() });

test.afterEach(async () => {
await stop();
});

test.describe("control settings (interval)", () => {
test("interval is immediately visible after save without restart", async ({ page }) => {
await start();
await page.goto("/#/config");
await enableExperimental(page);

const controlEntry = page.getByTestId("generalconfig-control");
await expect(controlEntry).toContainText("30 s");

Check failure on line 18 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart

1) [chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart Retry #4 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toContainText(expected) failed Locator: getByTestId('generalconfig-control') Expected substring: "30 s" Received string: "Control behavior 🧪 10 s" Timeout: 5000ms Call log: - Expect "toContainText" with timeout 5000ms - waiting for getByTestId('generalconfig-control') 9 × locator resolved to <div data-v-9ec5b3b6="" data-testid="generalconfig-control" class="d-flex justify-content-between flex-wrap align-items-center gap-2">…</div> - unexpected value "Control behavior 🧪 10 s" 16 | 17 | const controlEntry = page.getByTestId("generalconfig-control"); > 18 | await expect(controlEntry).toContainText("30 s"); | ^ 19 | 20 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 21 | at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:18:32

Check failure on line 18 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart

1) [chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart Retry #3 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toContainText(expected) failed Locator: getByTestId('generalconfig-control') Expected substring: "30 s" Received string: "Control behavior 🧪 10 s" Timeout: 5000ms Call log: - Expect "toContainText" with timeout 5000ms - waiting for getByTestId('generalconfig-control') 9 × locator resolved to <div data-v-9ec5b3b6="" data-testid="generalconfig-control" class="d-flex justify-content-between flex-wrap align-items-center gap-2">…</div> - unexpected value "Control behavior 🧪 10 s" 16 | 17 | const controlEntry = page.getByTestId("generalconfig-control"); > 18 | await expect(controlEntry).toContainText("30 s"); | ^ 19 | 20 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 21 | at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:18:32

Check failure on line 18 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart

1) [chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toContainText(expected) failed Locator: getByTestId('generalconfig-control') Expected substring: "30 s" Received string: "Control behavior 🧪 10 s" Timeout: 5000ms Call log: - Expect "toContainText" with timeout 5000ms - waiting for getByTestId('generalconfig-control') 9 × locator resolved to <div data-v-9ec5b3b6="" data-testid="generalconfig-control" class="d-flex justify-content-between flex-wrap align-items-center gap-2">…</div> - unexpected value "Control behavior 🧪 10 s" 16 | 17 | const controlEntry = page.getByTestId("generalconfig-control"); > 18 | await expect(controlEntry).toContainText("30 s"); | ^ 19 | 20 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 21 | at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:18:32

Check failure on line 18 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart

1) [chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toContainText(expected) failed Locator: getByTestId('generalconfig-control') Expected substring: "30 s" Received string: "Control behavior 🧪 10 s" Timeout: 5000ms Call log: - Expect "toContainText" with timeout 5000ms - waiting for getByTestId('generalconfig-control') 9 × locator resolved to <div data-v-9ec5b3b6="" data-testid="generalconfig-control" class="d-flex justify-content-between flex-wrap align-items-center gap-2">…</div> - unexpected value "Control behavior 🧪 10 s" 16 | 17 | const controlEntry = page.getByTestId("generalconfig-control"); > 18 | await expect(controlEntry).toContainText("30 s"); | ^ 19 | 20 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 21 | at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:18:32

Check failure on line 18 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart

1) [chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart Error: expect(locator).toContainText(expected) failed Locator: getByTestId('generalconfig-control') Expected substring: "30 s" Received string: "Control behavior 🧪 10 s" Timeout: 5000ms Call log: - Expect "toContainText" with timeout 5000ms - waiting for getByTestId('generalconfig-control') 9 × locator resolved to <div data-v-9ec5b3b6="" data-testid="generalconfig-control" class="d-flex justify-content-between flex-wrap align-items-center gap-2">…</div> - unexpected value "Control behavior 🧪 10 s" 16 | 17 | const controlEntry = page.getByTestId("generalconfig-control"); > 18 | await expect(controlEntry).toContainText("30 s"); | ^ 19 | 20 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 21 | at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:18:32

Check failure on line 18 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart

1) [chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart Retry #4 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toContainText(expected) failed Locator: getByTestId('generalconfig-control') Expected substring: "30 s" Received string: "Control behavior 🧪 10 s" Timeout: 5000ms Call log: - Expect "toContainText" with timeout 5000ms - waiting for getByTestId('generalconfig-control') 9 × locator resolved to <div data-v-9ec5b3b6="" data-testid="generalconfig-control" class="d-flex justify-content-between flex-wrap align-items-center gap-2">…</div> - unexpected value "Control behavior 🧪 10 s" 16 | 17 | const controlEntry = page.getByTestId("generalconfig-control"); > 18 | await expect(controlEntry).toContainText("30 s"); | ^ 19 | 20 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 21 | at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:18:32

Check failure on line 18 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart

1) [chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart Retry #3 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toContainText(expected) failed Locator: getByTestId('generalconfig-control') Expected substring: "30 s" Received string: "Control behavior 🧪 10 s" Timeout: 5000ms Call log: - Expect "toContainText" with timeout 5000ms - waiting for getByTestId('generalconfig-control') 9 × locator resolved to <div data-v-9ec5b3b6="" data-testid="generalconfig-control" class="d-flex justify-content-between flex-wrap align-items-center gap-2">…</div> - unexpected value "Control behavior 🧪 10 s" 16 | 17 | const controlEntry = page.getByTestId("generalconfig-control"); > 18 | await expect(controlEntry).toContainText("30 s"); | ^ 19 | 20 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 21 | at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:18:32

Check failure on line 18 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart

1) [chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toContainText(expected) failed Locator: getByTestId('generalconfig-control') Expected substring: "30 s" Received string: "Control behavior 🧪 10 s" Timeout: 5000ms Call log: - Expect "toContainText" with timeout 5000ms - waiting for getByTestId('generalconfig-control') 9 × locator resolved to <div data-v-9ec5b3b6="" data-testid="generalconfig-control" class="d-flex justify-content-between flex-wrap align-items-center gap-2">…</div> - unexpected value "Control behavior 🧪 10 s" 16 | 17 | const controlEntry = page.getByTestId("generalconfig-control"); > 18 | await expect(controlEntry).toContainText("30 s"); | ^ 19 | 20 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 21 | at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:18:32

Check failure on line 18 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart

1) [chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toContainText(expected) failed Locator: getByTestId('generalconfig-control') Expected substring: "30 s" Received string: "Control behavior 🧪 10 s" Timeout: 5000ms Call log: - Expect "toContainText" with timeout 5000ms - waiting for getByTestId('generalconfig-control') 9 × locator resolved to <div data-v-9ec5b3b6="" data-testid="generalconfig-control" class="d-flex justify-content-between flex-wrap align-items-center gap-2">…</div> - unexpected value "Control behavior 🧪 10 s" 16 | 17 | const controlEntry = page.getByTestId("generalconfig-control"); > 18 | await expect(controlEntry).toContainText("30 s"); | ^ 19 | 20 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 21 | at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:18:32

Check failure on line 18 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart

1) [chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart Error: expect(locator).toContainText(expected) failed Locator: getByTestId('generalconfig-control') Expected substring: "30 s" Received string: "Control behavior 🧪 10 s" Timeout: 5000ms Call log: - Expect "toContainText" with timeout 5000ms - waiting for getByTestId('generalconfig-control') 9 × locator resolved to <div data-v-9ec5b3b6="" data-testid="generalconfig-control" class="d-flex justify-content-between flex-wrap align-items-center gap-2">…</div> - unexpected value "Control behavior 🧪 10 s" 16 | 17 | const controlEntry = page.getByTestId("generalconfig-control"); > 18 | await expect(controlEntry).toContainText("30 s"); | ^ 19 | 20 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 21 | at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:18:32

await controlEntry.getByRole("button", { name: "Edit" }).click();

const modal = page.getByTestId("control-modal");
await expectModalVisible(modal);

const intervalInput = modal.getByLabel("Interval");
await expect(intervalInput).toHaveValue("30");
await intervalInput.fill("60");

await modal.getByRole("button", { name: "Save" }).click();

await expectModalHidden(modal);

await expect(page.getByTestId("restart-needed")).toBeVisible();

await expect(controlEntry).toContainText("60 s");
await expect(controlEntry).not.toContainText("30 s");

await controlEntry.getByRole("button", { name: "Edit" }).click();
await expectModalVisible(modal);
await expect(intervalInput).toHaveValue("60");
});

test("residual power is immediately visible after save", async ({ page }) => {
await start();
await page.goto("/#/config");
await enableExperimental(page);

const controlEntry = page.getByTestId("generalconfig-control");
await controlEntry.getByRole("button", { name: "Edit" }).click();

const modal = page.getByTestId("control-modal");
await expectModalVisible(modal);

const residualPowerInput = modal.getByLabel("Residual power");
const initialValue = await residualPowerInput.inputValue();

await residualPowerInput.fill("200");

await modal.getByRole("button", { name: "Save" }).click();

await expectModalHidden(modal);

await expect(page.getByTestId("restart-needed")).toBeVisible();

Check failure on line 63 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save

2) [chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save Retry #4 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toBeVisible() failed Locator: getByTestId('restart-needed') Expected: visible Timeout: 5000ms Error: element(s) not found Call log: - Expect "toBeVisible" with timeout 5000ms - waiting for getByTestId('restart-needed') 61 | await expectModalHidden(modal); 62 | > 63 | await expect(page.getByTestId("restart-needed")).toBeVisible(); | ^ 64 | 65 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 66 | await expectModalVisible(modal); at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:63:54

Check failure on line 63 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save

2) [chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save Retry #3 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toBeVisible() failed Locator: getByTestId('restart-needed') Expected: visible Timeout: 5000ms Error: element(s) not found Call log: - Expect "toBeVisible" with timeout 5000ms - waiting for getByTestId('restart-needed') 61 | await expectModalHidden(modal); 62 | > 63 | await expect(page.getByTestId("restart-needed")).toBeVisible(); | ^ 64 | 65 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 66 | await expectModalVisible(modal); at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:63:54

Check failure on line 63 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save

2) [chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toBeVisible() failed Locator: getByTestId('restart-needed') Expected: visible Timeout: 5000ms Error: element(s) not found Call log: - Expect "toBeVisible" with timeout 5000ms - waiting for getByTestId('restart-needed') 61 | await expectModalHidden(modal); 62 | > 63 | await expect(page.getByTestId("restart-needed")).toBeVisible(); | ^ 64 | 65 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 66 | await expectModalVisible(modal); at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:63:54

Check failure on line 63 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save

2) [chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toBeVisible() failed Locator: getByTestId('restart-needed') Expected: visible Timeout: 5000ms Error: element(s) not found Call log: - Expect "toBeVisible" with timeout 5000ms - waiting for getByTestId('restart-needed') 61 | await expectModalHidden(modal); 62 | > 63 | await expect(page.getByTestId("restart-needed")).toBeVisible(); | ^ 64 | 65 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 66 | await expectModalVisible(modal); at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:63:54

Check failure on line 63 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save

2) [chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save Error: expect(locator).toBeVisible() failed Locator: getByTestId('restart-needed') Expected: visible Timeout: 5000ms Error: element(s) not found Call log: - Expect "toBeVisible" with timeout 5000ms - waiting for getByTestId('restart-needed') 61 | await expectModalHidden(modal); 62 | > 63 | await expect(page.getByTestId("restart-needed")).toBeVisible(); | ^ 64 | 65 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 66 | await expectModalVisible(modal); at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:63:54

Check failure on line 63 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save

2) [chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save Retry #4 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toBeVisible() failed Locator: getByTestId('restart-needed') Expected: visible Timeout: 5000ms Error: element(s) not found Call log: - Expect "toBeVisible" with timeout 5000ms - waiting for getByTestId('restart-needed') 61 | await expectModalHidden(modal); 62 | > 63 | await expect(page.getByTestId("restart-needed")).toBeVisible(); | ^ 64 | 65 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 66 | await expectModalVisible(modal); at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:63:54

Check failure on line 63 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save

2) [chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save Retry #3 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toBeVisible() failed Locator: getByTestId('restart-needed') Expected: visible Timeout: 5000ms Error: element(s) not found Call log: - Expect "toBeVisible" with timeout 5000ms - waiting for getByTestId('restart-needed') 61 | await expectModalHidden(modal); 62 | > 63 | await expect(page.getByTestId("restart-needed")).toBeVisible(); | ^ 64 | 65 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 66 | await expectModalVisible(modal); at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:63:54

Check failure on line 63 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save

2) [chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toBeVisible() failed Locator: getByTestId('restart-needed') Expected: visible Timeout: 5000ms Error: element(s) not found Call log: - Expect "toBeVisible" with timeout 5000ms - waiting for getByTestId('restart-needed') 61 | await expectModalHidden(modal); 62 | > 63 | await expect(page.getByTestId("restart-needed")).toBeVisible(); | ^ 64 | 65 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 66 | await expectModalVisible(modal); at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:63:54

Check failure on line 63 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save

2) [chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toBeVisible() failed Locator: getByTestId('restart-needed') Expected: visible Timeout: 5000ms Error: element(s) not found Call log: - Expect "toBeVisible" with timeout 5000ms - waiting for getByTestId('restart-needed') 61 | await expectModalHidden(modal); 62 | > 63 | await expect(page.getByTestId("restart-needed")).toBeVisible(); | ^ 64 | 65 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 66 | await expectModalVisible(modal); at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:63:54

Check failure on line 63 in tests/config-control.spec.ts

View workflow job for this annotation

GitHub Actions / Integration

[chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save

2) [chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save Error: expect(locator).toBeVisible() failed Locator: getByTestId('restart-needed') Expected: visible Timeout: 5000ms Error: element(s) not found Call log: - Expect "toBeVisible" with timeout 5000ms - waiting for getByTestId('restart-needed') 61 | await expectModalHidden(modal); 62 | > 63 | await expect(page.getByTestId("restart-needed")).toBeVisible(); | ^ 64 | 65 | await controlEntry.getByRole("button", { name: "Edit" }).click(); 66 | await expectModalVisible(modal); at /home/runner/work/evcc/evcc/tests/config-control.spec.ts:63:54

await controlEntry.getByRole("button", { name: "Edit" }).click();
await expectModalVisible(modal);
await expect(residualPowerInput).toHaveValue("200");
await expect(residualPowerInput).not.toHaveValue(initialValue);
});
});
17 changes: 11 additions & 6 deletions tests/sponsor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,23 @@ test.describe("sponsor token", () => {
await page.goto("/#/config");
await enableExperimental(page);

// Open sponsor modal and enter token
await page
.getByTestId("generalconfig-sponsoring")
.getByRole("button", { name: "Edit" })
.click();
const sponsorEntry = page.getByTestId("generalconfig-sponsoring");
await expect(sponsorEntry).toContainText("---");

await sponsorEntry.getByRole("button", { name: "Edit" }).click();

const modal = page.getByTestId("sponsor-modal");
const textarea = modal.getByRole("textbox", { name: "Enter your token" });

await textarea.fill(EXPIRED_TOKEN);
// Try to save to trigger validation
await modal.getByRole("button", { name: "Save" }).click();
await expect(modal).toContainText("token is expired");

// Verify token is immediately visible in UI after failed save attempt
await expect(sponsorEntry).toContainText("invalid");
await expect(sponsorEntry).not.toContainText("---");

await sponsorEntry.getByRole("button", { name: "Edit" }).click();
await expect(modal.getByRole("textbox", { name: "Your token" })).toHaveValue(SHORT_TOKEN);
});
});
Loading