Skip to content

Add Playwright E2E test suite for Task Tracker#23

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-e2e-tests-for-task-tracker
Draft

Add Playwright E2E test suite for Task Tracker#23
Copilot wants to merge 2 commits intomainfrom
copilot/add-e2e-tests-for-task-tracker

Conversation

Copy link
Contributor

Copilot AI commented Mar 19, 2026

Adds a comprehensive Playwright end-to-end test suite targeting a live Home Assistant instance, covering the full Task Tracker integration surface: config flow, sensor/button entities, frontend assets, and custom services.

Structure

tests/playwright/
├── conftest.py               # Fixtures: HA REST helpers, browser context, entry lifecycle
├── test_integration_setup.py # Config flow: create, verify, delete, duplicate rejection
├── test_sensors.py           # Sensor state, attributes, service-driven transitions
├── test_buttons.py           # Button creation, press via API, device registry membership
├── test_frontend.py          # JS assets served, Lovelace/panel/dev-tools pages render
├── test_services.py          # mark_as_done / set_last_done_date: happy path + error cases
├── requirements.txt
└── README.md

40 tests total across 5 test modules.

Key design points

  • Auth: long-lived HA_TOKEN injected into browser localStorage — no UI login flow needed
  • Isolation: task_tracker_entry fixture creates a config entry per-test and deletes it on teardown; all tests are idempotent
  • API-first where possible: pure REST tests (ha_get/ha_post/call_service fixtures) avoid browser overhead; Playwright browser is only used where UI rendering matters
  • Configuration: HOMEASSISTANT_URL (default http://localhost:8123) and HA_TOKEN env vars

CI

.github/workflows/playwright.yml spins up HA as a Docker service container, runs the onboarding flow to obtain a token, installs the component, and executes the suite.

Original prompt

Goal

Add comprehensive Playwright end-to-end tests for the Task Tracker Home Assistant custom component.

Background

Task Tracker is a Home Assistant custom component that provides task management functionality with sensors, buttons, and frontend cards. This integration needs thorough E2E testing using Playwright to ensure all functionality works correctly in a real Home Assistant environment.

Requirements

Create Playwright tests in the tests/playwright directory that cover:

  1. Integration Setup Tests (test_integration_setup.py):

    • Test adding the Task Tracker integration via config flow
    • Verify integration appears in the integrations list
    • Test integration configuration options
  2. Sensor Tests (test_sensors.py):

    • Test task sensor creation and state
    • Verify sensor attributes (task count, pending tasks, completed tasks)
    • Test sensor updates when tasks change
  3. Button Tests (test_buttons.py):

    • Test button entity creation
    • Test button press functionality
    • Verify button actions (e.g., complete task, clear completed)
  4. Frontend Tests (test_frontend.py):

    • Test task tracker card rendering
    • Test adding new tasks via UI
    • Test completing tasks via UI
    • Test deleting tasks via UI
    • Test task list updates
  5. Service Tests (test_services.py):

    • Test task creation service
    • Test task completion service
    • Test task deletion service
    • Test task update service

Technical Details

  • Use Playwright with Python
  • Create a conftest.py with fixtures for:
    • Home Assistant instance connection
    • Authentication token management
    • Browser context with Home Assistant session
    • Integration setup/teardown
  • Use environment variables for configuration:
  • Add proper waits for async operations
  • Include error handling and retry logic
  • Add comprehensive assertions

File Structure

tests/
└── playwright/
    ├── conftest.py
    ├── test_integration_setup.py
    ├── test_sensors.py
    ├── test_buttons.py
    ├── test_frontend.py
    ├── test_services.py
    └── README.md

Additional Files

Create:

  • tests/playwright/README.md - Documentation on how to run the tests
  • tests/playwright/requirements.txt - Python dependencies for tests
  • .github/workflows/playwright.yml - GitHub Actions workflow for CI (optional)

Notes

  • Tests should be idempotent and not depend on each other
  • Clean up any created entities after tests
  • Use meaningful test names and add docstrings
  • Handle authentication properly
  • Test should work with the docker-compose setup provided

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: I have mutliple repositories containing Home Assistant custom components (@gensyn/task_tracker, @gensyn/ssh_command, @gensyn/ssh_docker) that I want to thorougly test using Playwright. For that I plan to spin up a Home Assistant instance in a Docker container solely for testing purposes, but I need a target for testing SSH servers and Docker hosts as well. For that I want to create a Docker container, that uses Docker-in-Docker to spin up two instances of @billchurch/ssh_test. This way, the outer Docker container can be the target of SSH Docker, and the contained SSH servers can be used for testing SSH Command. Task Tracker does not have outside dependencies.
Create a Dockerfile file and a docker-compose.yaml file that serve my described purpose and provide them here.
After that, create Playwright tests for each of my mentioned repositories. Put them in their respective repository in a new branch under "tests/playwright" and create a pull request for each repository.

Assistant: I'll help you set up the testing infrastructure and create Playwright tests for your Home Assistant custom components. Let me start by gathering information about your repositories and then provide the Docker configuration files and create the PRs.

Assistant: Great! Now let me provide you with the Docker configuration files and then create the Playwright tests for each repository.

Docker Configuration Files

Here are the Dockerfile and docker-compose.yaml files for your testing setup:

# Use a Docker-in-Docker base image
FROM docker:24-dind

# Install necessary packages
RUN apk add --no-cache \
    openssh \
    openssh-server \
    bash \
    curl \
    py3-pip \
    python3

# Setup SSH server
RUN ssh-keygen -A && \
    mkdir -p /root/.ssh && \
    chmod 700 /root/.ssh

# Set root password for SSH access
RUN echo 'root:testpassword' | chpasswd

# Configure SSH to allow root login with password
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
    sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config

# Create startup script to launch SSH...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

<!-- START COPILOT CODING AGENT TIPS -->
---

📍 Connect Copilot coding agent with [Jira](https://gh.io/cca-jira-docs), [Azure Boards](https://gh.io/cca-azure-boards-docs) or [Linear](https://gh.io/cca-linear-docs) to delegate work to Copilot in one click without leaving your project management tool.

Co-authored-by: gensyn <36128035+gensyn@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Playwright end-to-end tests for Task Tracker component Add Playwright E2E test suite for Task Tracker Mar 19, 2026
Copilot AI requested a review from gensyn March 19, 2026 09:32
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