-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Messaging: add tests #26803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Messaging: add tests #26803
Conversation
|
Ich hab sie einfach mal übernommen, Review geht ja auch im anderen PR ;) |
There was a problem hiding this 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 abeforeEachor 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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| const editorContent = [ | ||
| "events:", | ||
| " start:", | ||
| " title: Charge started", | ||
| " msg: Started charging", | ||
| ].join("\n"); | ||
|
|
||
| await editorClear(editor); | ||
| await editorPaste(editor, page, editorContent); |
There was a problem hiding this comment.
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.
| // restart button appears | ||
| const restartButton = await page | ||
| .getByTestId("bottom-banner") | ||
| .getByRole("button", { name: "Restart" }); | ||
| await expect(restartButton).toBeVisible(); | ||
|
|
||
| await restart(); | ||
| await page.reload(); |
There was a problem hiding this comment.
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.
|
I missed the testcase config from evcc.yaml. Since this was WIP I did not comment yet. But the existing test here is fine. |
|
I didn't have enough time for that this morning. |
WIP
Ref #26782
\cc @naltatis