Skip to content

Conversation

@Maschga
Copy link
Collaborator

@Maschga Maschga commented Jan 19, 2026

WIP
Ref #26782
\cc @naltatis

@evcc-bot evcc-bot added enhancement New feature or request ux User experience/ interface labels Jan 19, 2026
@naltatis naltatis changed the title add tests Messaging: add tests Jan 19, 2026
@andig andig marked this pull request as ready for review January 19, 2026 16:51
@andig andig merged commit 37178dc into evcc-io:feat/config-messengers Jan 19, 2026
7 checks passed
@andig
Copy link
Member

andig commented Jan 19, 2026

Ich hab sie einfach mal übernommen, Review geht ja auch im anderen PR ;)

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • Both tests repeat await start(); await page.goto("/#/config"); and querying the messaging card; consider moving this common setup into a beforeEach or helper to keep the suite DRY and focused on the behavioral differences.
  • The toContainText(["Configured", "no"].join("")) / "yes" checks couple the test to the exact concatenated text; if possible, target the label and value separately (e.g. distinct test ids or roles) to make the assertions more robust against layout/text changes.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Both tests repeat `await start(); await page.goto("/#/config");` and querying the messaging card; consider moving this common setup into a `beforeEach` or helper to keep the suite DRY and focused on the behavioral differences.
- The `toContainText(["Configured", "no"].join(""))` / `"yes"` checks couple the test to the exact concatenated text; if possible, target the label and value separately (e.g. distinct test ids or roles) to make the assertions more robust against layout/text changes.

## Individual Comments

### Comment 1
<location> `tests/config-messaging.spec.ts:32-40` </location>
<code_context>
-    }
-    await page.keyboard.type("# hello world");
+    const editor = modal.getByTestId("yaml-editor");
+    const editorContent = [
+      "events:",
+      "  start:",
+      "    title: Charge started",
+      "    msg: Started charging",
+    ].join("\n");
+
+    await editorClear(editor);
+    await editorPaste(editor, page, editorContent);
+
     await page.getByRole("button", { name: "Save" }).click();
</code_context>

<issue_to_address>
**issue (testing):** Add a test case for invalid/unsupported YAML to cover the error path of the messaging configuration modal.

The current tests only cover the happy path. Please add a test that opens the messaging modal, inputs invalid YAML (both syntactically invalid and structurally invalid, e.g. missing required `events` fields), clicks Save, and asserts that: (a) the save is rejected (modal remains open), and (b) the expected validation error message/state is shown. This will protect the messaging config validation from regressions.
</issue_to_address>

### Comment 2
<location> `tests/config-messaging.spec.ts:45-52` </location>
<code_context>
     await expectModalHidden(modal);

-    page.reload();
+    // restart button appears
+    const restartButton = await page
+      .getByTestId("bottom-banner")
+      .getByRole("button", { name: "Restart" });
+    await expect(restartButton).toBeVisible();
+
+    await restart();
+    await page.reload();

-    await page.getByTestId("messaging").getByRole("button", { name: "edit" }).click();
</code_context>

<issue_to_address>
**suggestion (testing):** Consider asserting the restart banner behavior after restart to fully exercise the flow.

You’re already verifying that the restart banner appears and that config persists through restart. To cover the full UX, also assert that after `await restart()` and reload the restart button is no longer shown (or has the expected post-restart state), so the test validates the entire lifecycle.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +32 to +40
const editorContent = [
"events:",
" start:",
" title: Charge started",
" msg: Started charging",
].join("\n");

await editorClear(editor);
await editorPaste(editor, page, editorContent);
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (testing): Add a test case for invalid/unsupported YAML to cover the error path of the messaging configuration modal.

The current tests only cover the happy path. Please add a test that opens the messaging modal, inputs invalid YAML (both syntactically invalid and structurally invalid, e.g. missing required events fields), clicks Save, and asserts that: (a) the save is rejected (modal remains open), and (b) the expected validation error message/state is shown. This will protect the messaging config validation from regressions.

Comment on lines +45 to +52
// restart button appears
const restartButton = await page
.getByTestId("bottom-banner")
.getByRole("button", { name: "Restart" });
await expect(restartButton).toBeVisible();

await restart();
await page.reload();
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (testing): Consider asserting the restart banner behavior after restart to fully exercise the flow.

You’re already verifying that the restart banner appears and that config persists through restart. To cover the full UX, also assert that after await restart() and reload the restart button is no longer shown (or has the expected post-restart state), so the test validates the entire lifecycle.

@Maschga Maschga deleted the feat/config-messengers-tests branch January 19, 2026 16:59
@naltatis
Copy link
Member

I missed the testcase config from evcc.yaml. Since this was WIP I did not comment yet. But the existing test here is fine.

@Maschga
Copy link
Collaborator Author

Maschga commented Jan 19, 2026

I didn't have enough time for that this morning.
@naltatis I sent you a DM regarding the configuration of evcc.yaml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ux User experience/ interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants