Skip to content

Conversation

@exetico
Copy link
Member

@exetico exetico commented Apr 4, 2025

First iteration of introducing tests for ha-floorplan.

This is by no mean finished, and I need to look more into playwright, in order to validate if it's actually needed to have both a dedicated end-to-end test (browser based), and a simple dom-solution in test (like ´@testing-library/jest-dom` already used in the Jest tests).

The PR also touches quite a few components, in order to make test possible.

There's still a long way to go, for every feature to be tested; and done the most efficient way. But, this is the beginning.

I'll revisit this in a few days, and if I don't see anything problematic, I'll merge it, and keep working in a new branch, once I found time to do so.

@github-actions github-actions bot added the workflow-modified Pay extra attention to the changes label Apr 4, 2025
@exetico exetico added the enhancement New feature or request label Apr 4, 2025
@exetico
Copy link
Member Author

exetico commented Apr 5, 2025

The SVG now covers all floorplan-services:

floorplan.class_toggle | Toggle a CSS class of the SVG element(s) | class (string)
floorplan.class_set | Set the CSS class of the SVG element(s) | class (string)
floorplan.dataset_set | Set a data attribute of the SVG element(s) | key (string)value (string)
floorplan.style_set | Set the CSS style of the of the SVG element(s) | style (string)
floorplan.text_set | Set the text of the SVG element(s) | text (string)shift_y_axis: 2em
floorplan.image_set | Set the image of the SVG element(s) | image (string)image_refresh_interval (number)cache (boolean)
floorplan.execute | Execute your own JS, defined in service_data |  (array)

But, I still need to test the objects exposed within custom JS:

Object Description
config Floorplan configuration
util Utility library
functions Custom functions
entity State object for the HA current entity
entities (or states) State objects for all HA entities
hass Home Assistant hass object
element current SVG element
elements current SVG elements
action Make action-executions to ha-floorplan

I didn't mean to close the PR. The UI jumped, while I did try and press "Update comment".

@exetico exetico closed this Apr 5, 2025
@github-actions github-actions bot added the workflow-modified Pay extra attention to the changes label Apr 8, 2025
@github-actions
Copy link

github-actions bot commented Apr 8, 2025

⚠️ Warning: This PR modifies workflow files in the .github/workflows/ folder. Please ensure these changes are intentional and secure.

@ExperienceLovelace ExperienceLovelace deleted a comment from github-actions bot Apr 8, 2025
@github-actions
Copy link

github-actions bot commented Apr 8, 2025

Test Results

 2 files   8 suites   45s ⏱️
47 tests 47 ✅ 0 💤 0 ❌
39 runs  39 ✅ 0 💤 0 ❌

Results for commit f0f7016.

♻️ This comment has been updated with latest results.

@exetico
Copy link
Member Author

exetico commented Apr 8, 2025

Today's work does add:

  • Very simple configuration handling test (more to come, see it.todo)
  • Testing of event solution (used by action() helper-function)
  • Testing action triggers

Before merging, I'd like to:

  • Secure that playwright test are also executed (requires a few things to be installed, so secure that it play's nicely with GitHub Actions)
  • Fix styling mix-match of camelCase and snake_case (I'm struggling, as I've used snake_case in my normal job for a few years, but ha-floorplan does suse camelCase).

As mentioned before:
Once merged, I'd like community feedback, on basis of more unique usage of ha-floorplan, to cover specific needs, which are already required by the users, as that's already in place in their personal floorplan-solutions.

It would also be great to have some sort of testing within Home Assistant, but that's for another day.

@exetico
Copy link
Member Author

exetico commented Apr 11, 2025

Today I've introduced:

  • Playwright test does run on GitHub, and on every pull request. The scope are still very limited, but a nice add-on, if we ever need it, for more in-dept test, done in a browser, instead of by jest-dom related packages.
  • Fixed variable naming for consistency, in favor of camelCase. I actually emjoy using snake_case with a Shift+Space defined as underscore, but as the project does us camelCase right now, let's use that.

Things to be considered for iteration 2:

  • I'd like community feedback, on basis of more unique usage of ha-floorplan, to cover specific needs, which are already required by the users, as that's already in place in their personal floorplan-solutions.
  • It would also be great to have some sort of testing within Home Assistant, but that's for another day.

@exetico exetico merged commit 4df91fc into master Apr 11, 2025
3 checks passed
@exetico exetico deleted the dev/testing_impl_step_1 branch April 11, 2025 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request workflow-modified Pay extra attention to the changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants