Skip to content

Add Playwright E2E tests for Task Tracker custom component#24

Merged
gensyn merged 4 commits intomainfrom
copilot/add-playwright-tests-for-task-tracker
Mar 26, 2026
Merged

Add Playwright E2E tests for Task Tracker custom component#24
gensyn merged 4 commits intomainfrom
copilot/add-playwright-tests-for-task-tracker

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 26, 2026

  • Create docker-compose.yaml (HA + playwright-tests)
  • Create run_playwright_tests.sh shell script
  • Create tests/playwright/Dockerfile
  • Create tests/playwright/entrypoint.sh
  • Create tests/playwright/ha-init-wrapper.sh
  • Create tests/playwright/pytest.ini
  • Create tests/playwright/requirements.txt
  • Create tests/playwright/conftest.py
  • Create tests/playwright/test_integration_setup.py
  • Create tests/playwright/test_services.py
  • Create tests/playwright/test_frontend.py
  • Create tests/playwright/test_configuration.py
  • Create tests/playwright/test_security.py
  • Create tests/playwright/README.md
  • Create .github/workflows/playwright-tests.yml
  • Update .gitignore to exclude playwright-results/
  • Add run_workflows_locally.sh to run all CI workflows + Playwright E2E locally
  • Fix KeyError: 'entry_id' in _add_integration: HA config flow API does not always include entry_id at the top level; now tries result["result"]["entry_id"] and falls back to diffing the config-entry list

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] Add Playwright tests for Task Tracker component Add Playwright E2E tests for Task Tracker custom component Mar 26, 2026
Copilot AI requested a review from gensyn March 26, 2026 10:00
@gensyn
Copy link
Copy Markdown
Owner

gensyn commented Mar 26, 2026

@copilot Please also import the logic to run GitHub workflows locally.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 26, 2026

@copilot Please also import the logic to run GitHub workflows locally.

Added run_workflows_locally.sh in commit 43d2e76. It mirrors the logic from ssh_command: installs Docker and act if missing, runs test.yml, pylint.yml, and integration-tests.yml via act, then delegates to run_playwright_tests.sh for the Playwright E2E suite (since docker compose run can't run inside act's Docker-in-Docker). Skips GitHub-infrastructure workflows (hassfest, validate, release) that can't run meaningfully offline.

@gensyn
Copy link
Copy Markdown
Owner

gensyn commented Mar 26, 2026

@copilot Some problems with the Playwright tests:

=============================================================================================================================================== test session starts ================================================================================================================================================
platform linux -- Python 3.12.13, pytest-8.4.2, pluggy-1.6.0 -- /usr/local/bin/python3.12
cachedir: .pytest_cache
rootdir: /app/tests/playwright
configfile: pytest.ini
plugins: base-url-2.1.0, playwright-0.7.2
collected 38 items                                                                                                                                                                                                                                                                                                 

test_configuration.py::TestConfiguration::test_interval_type_day PASSED                                                                                                                                                                                                                                      [  2%]
test_configuration.py::TestConfiguration::test_interval_type_week PASSED                                                                                                                                                                                                                                     [  5%]
test_configuration.py::TestConfiguration::test_interval_type_month PASSED                                                                                                                                                                                                                                    [  7%]
test_configuration.py::TestConfiguration::test_interval_type_year PASSED                                                                                                                                                                                                                                     [ 10%]
test_configuration.py::TestConfiguration::test_sensor_reflects_task_interval ERROR                                                                                                                                                                                                                           [ 13%]
test_configuration.py::TestConfiguration::test_mark_as_done_then_due_after_interval ERROR                                                                                                                                                                                                                    [ 15%]
test_configuration.py::TestConfiguration::test_sensor_starts_in_due_state ERROR                                                                                                                                                                                                                              [ 18%]
test_configuration.py::TestConfiguration::test_multiple_tasks_independent PASSED                                                                                                                                                                                                                             [ 21%]
test_configuration.py::TestConfiguration::test_due_in_attribute_reflects_interval ERROR                                                                                                                                                                                                                      [ 23%]
test_frontend.py::TestFrontend::test_home_assistant_frontend_loads PASSED                                                                                                                                                                                                                                    [ 26%]
test_frontend.py::TestFrontend::test_integrations_page_accessible PASSED                                                                                                                                                                                                                                     [ 28%]
test_frontend.py::TestFrontend::test_developer_tools_page_loads PASSED                                                                                                                                                                                                                                       [ 31%]
test_frontend.py::TestFrontend::test_task_tracker_visible_in_integrations ERROR                                                                                                                                                                                                                              [ 34%]
test_frontend.py::TestFrontend::test_task_tracker_panel_accessible ERROR                                                                                                                                                                                                                                     [ 36%]
test_frontend.py::TestFrontend::test_service_call_via_developer_tools ERROR                                                                                                                                                                                                                                  [ 39%]
test_frontend.py::TestFrontend::test_config_page_shows_integration_info ERROR                                                                                                                                                                                                                                [ 42%]
test_frontend.py::TestFrontend::test_no_javascript_errors_on_main_page PASSED                                                                                                                                                                                                                                [ 44%]
test_integration_setup.py::TestIntegrationSetup::test_add_integration PASSED                                                                                                                                                                                                                                 [ 47%]
test_integration_setup.py::TestIntegrationSetup::test_add_multiple_integrations PASSED                                                                                                                                                                                                                       [ 50%]
test_integration_setup.py::TestIntegrationSetup::test_remove_integration FAILED                                                                                                                                                                                                                              [ 52%]
test_integration_setup.py::TestIntegrationLifecycle::test_full_lifecycle FAILED                                                                                                                                                                                                                              [ 55%]
test_security.py::TestSecurity::test_api_requires_authentication PASSED                                                                                                                                                                                                                                      [ 57%]
test_security.py::TestSecurity::test_states_api_requires_authentication PASSED                                                                                                                                                                                                                               [ 60%]
test_security.py::TestSecurity::test_config_entries_api_requires_authentication PASSED                                                                                                                                                                                                                       [ 63%]
test_security.py::TestSecurity::test_mark_as_done_requires_valid_entity ERROR                                                                                                                                                                                                                                [ 65%]
test_security.py::TestSecurity::test_set_last_done_date_requires_valid_entity ERROR                                                                                                                                                                                                                          [ 68%]
test_security.py::TestSecurity::test_set_last_done_date_requires_valid_date ERROR                                                                                                                                                                                                                            [ 71%]
test_security.py::TestSecurity::test_mark_as_done_missing_entity_id ERROR                                                                                                                                                                                                                                    [ 73%]
test_security.py::TestSecurity::test_set_last_done_date_missing_date ERROR                                                                                                                                                                                                                                   [ 76%]
test_services.py::TestServices::test_services_registered ERROR                                                                                                                                                                                                                                               [ 78%]
test_services.py::TestServices::test_mark_as_done_sets_done_state ERROR                                                                                                                                                                                                                                      [ 81%]
test_services.py::TestServices::test_mark_as_done_updates_last_done_attribute ERROR                                                                                                                                                                                                                          [ 84%]
test_services.py::TestServices::test_set_last_done_date_overdue ERROR                                                                                                                                                                                                                                        [ 86%]
test_services.py::TestServices::test_set_last_done_date_today ERROR                                                                                                                                                                                                                                          [ 89%]
test_services.py::TestServices::test_set_last_done_date_stores_attribute ERROR                                                                                                                                                                                                                               [ 92%]
test_services.py::TestServices::test_mark_as_done_invalid_entity_id ERROR                                                                                                                                                                                                                                    [ 94%]
test_services.py::TestServices::test_set_last_done_date_invalid_entity_id ERROR                                                                                                                                                                                                                              [ 97%]
test_services.py::TestServices::test_sensor_attributes_present ERROR                                                                                                                                                                                                                                         [100%]

====================================================================================================================================================== ERRORS ======================================================================================================================================================
______________________________________________________________________________________________________________________ ERROR at setup of TestConfiguration.test_sensor_reflects_task_interval ______________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
__________________________________________________________________________________________________________________ ERROR at setup of TestConfiguration.test_mark_as_done_then_due_after_interval ___________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
_______________________________________________________________________________________________________________________ ERROR at setup of TestConfiguration.test_sensor_starts_in_due_state ________________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
___________________________________________________________________________________________________________________ ERROR at setup of TestConfiguration.test_due_in_attribute_reflects_interval ____________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
_____________________________________________________________________________________________________________________ ERROR at setup of TestFrontend.test_task_tracker_visible_in_integrations _____________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
________________________________________________________________________________________________________________________ ERROR at setup of TestFrontend.test_task_tracker_panel_accessible _________________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
_______________________________________________________________________________________________________________________ ERROR at setup of TestFrontend.test_service_call_via_developer_tools _______________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
______________________________________________________________________________________________________________________ ERROR at setup of TestFrontend.test_config_page_shows_integration_info ______________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
______________________________________________________________________________________________________________________ ERROR at setup of TestSecurity.test_mark_as_done_requires_valid_entity ______________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
___________________________________________________________________________________________________________________ ERROR at setup of TestSecurity.test_set_last_done_date_requires_valid_entity ___________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
____________________________________________________________________________________________________________________ ERROR at setup of TestSecurity.test_set_last_done_date_requires_valid_date ____________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
________________________________________________________________________________________________________________________ ERROR at setup of TestSecurity.test_mark_as_done_missing_entity_id ________________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
_______________________________________________________________________________________________________________________ ERROR at setup of TestSecurity.test_set_last_done_date_missing_date ________________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
_____________________________________________________________________________________________________________________________ ERROR at setup of TestServices.test_services_registered ______________________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
_________________________________________________________________________________________________________________________ ERROR at setup of TestServices.test_mark_as_done_sets_done_state _________________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
___________________________________________________________________________________________________________________ ERROR at setup of TestServices.test_mark_as_done_updates_last_done_attribute ___________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
__________________________________________________________________________________________________________________________ ERROR at setup of TestServices.test_set_last_done_date_overdue __________________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
___________________________________________________________________________________________________________________________ ERROR at setup of TestServices.test_set_last_done_date_today ___________________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
_____________________________________________________________________________________________________________________ ERROR at setup of TestServices.test_set_last_done_date_stores_attribute ______________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
________________________________________________________________________________________________________________________ ERROR at setup of TestServices.test_mark_as_done_invalid_entity_id ________________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
_____________________________________________________________________________________________________________________ ERROR at setup of TestServices.test_set_last_done_date_invalid_entity_id _____________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
__________________________________________________________________________________________________________________________ ERROR at setup of TestServices.test_sensor_attributes_present ___________________________________________________________________________________________________________________________
conftest.py:319: in ensure_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
===================================================================================================================================================== FAILURES =====================================================================================================================================================
___________________________________________________________________________________________________________________________________ TestIntegrationSetup.test_remove_integration ___________________________________________________________________________________________________________________________________
test_integration_setup.py:58: in test_remove_integration
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
___________________________________________________________________________________________________________________________________ TestIntegrationLifecycle.test_full_lifecycle ___________________________________________________________________________________________________________________________________
test_integration_setup.py:95: in test_full_lifecycle
    entry_id: str = result["entry_id"]
                    ^^^^^^^^^^^^^^^^^^
E   KeyError: 'entry_id'
------------------------------------------------------------------------------------------------------------------------------ generated xml file: /app/playwright-results/junit.xml -------------------------------------------------------------------------------------------------------------------------------
============================================================================================================================================= short test summary info ==============================================================================================================================================
FAILED test_integration_setup.py::TestIntegrationSetup::test_remove_integration - KeyError: 'entry_id'
FAILED test_integration_setup.py::TestIntegrationLifecycle::test_full_lifecycle - KeyError: 'entry_id'
ERROR test_configuration.py::TestConfiguration::test_sensor_reflects_task_interval - KeyError: 'entry_id'
ERROR test_configuration.py::TestConfiguration::test_mark_as_done_then_due_after_interval - KeyError: 'entry_id'
ERROR test_configuration.py::TestConfiguration::test_sensor_starts_in_due_state - KeyError: 'entry_id'
ERROR test_configuration.py::TestConfiguration::test_due_in_attribute_reflects_interval - KeyError: 'entry_id'
ERROR test_frontend.py::TestFrontend::test_task_tracker_visible_in_integrations - KeyError: 'entry_id'
ERROR test_frontend.py::TestFrontend::test_task_tracker_panel_accessible - KeyError: 'entry_id'
ERROR test_frontend.py::TestFrontend::test_service_call_via_developer_tools - KeyError: 'entry_id'
ERROR test_frontend.py::TestFrontend::test_config_page_shows_integration_info - KeyError: 'entry_id'
ERROR test_security.py::TestSecurity::test_mark_as_done_requires_valid_entity - KeyError: 'entry_id'
ERROR test_security.py::TestSecurity::test_set_last_done_date_requires_valid_entity - KeyError: 'entry_id'
ERROR test_security.py::TestSecurity::test_set_last_done_date_requires_valid_date - KeyError: 'entry_id'
ERROR test_security.py::TestSecurity::test_mark_as_done_missing_entity_id - KeyError: 'entry_id'
ERROR test_security.py::TestSecurity::test_set_last_done_date_missing_date - KeyError: 'entry_id'
ERROR test_services.py::TestServices::test_services_registered - KeyError: 'entry_id'
ERROR test_services.py::TestServices::test_mark_as_done_sets_done_state - KeyError: 'entry_id'
ERROR test_services.py::TestServices::test_mark_as_done_updates_last_done_attribute - KeyError: 'entry_id'
ERROR test_services.py::TestServices::test_set_last_done_date_overdue - KeyError: 'entry_id'
ERROR test_services.py::TestServices::test_set_last_done_date_today - KeyError: 'entry_id'
ERROR test_services.py::TestServices::test_set_last_done_date_stores_attribute - KeyError: 'entry_id'
ERROR test_services.py::TestServices::test_mark_as_done_invalid_entity_id - KeyError: 'entry_id'
ERROR test_services.py::TestServices::test_set_last_done_date_invalid_entity_id - KeyError: 'entry_id'
ERROR test_services.py::TestServices::test_sensor_attributes_present - KeyError: 'entry_id'
===================================================================================================================================== 2 failed, 14 passed, 22 errors in 23.16s ==================================================================================================================================

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 26, 2026

@copilot Some problems with the Playwright tests:

...

Fixed in commit 430871b. The HA config flow API doesn't include entry_id at the top level of the create_entry response. _add_integration now resolves it in order: (1) top-level entry_id if present, (2) result["result"]["entry_id"] (the nested location used by some HA versions), (3) falls back to diffing the config-entry list before/after the flow. All callers that do result["entry_id"] get a guaranteed value.

@gensyn gensyn marked this pull request as ready for review March 26, 2026 10:37
@gensyn gensyn merged commit a5c93b6 into main Mar 26, 2026
5 checks passed
@gensyn gensyn deleted the copilot/add-playwright-tests-for-task-tracker branch March 26, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants