apisix-dashboard icon indicating copy to clipboard operation
apisix-dashboard copied to clipboard

test(e2e): add comprehensive service CRUD tests and UI utility functions

Open DSingh0304 opened this issue 1 month ago • 5 comments

Why submit this pull request?

  • [ ] Bugfix
  • [x] New feature provided
  • [ ] Improve performance
  • [ ] Backport patches

What changes will this PR take into?

This PR adds comprehensive E2E tests for the Services resource, covering all CRUD operations and list page functionality.

Test Coverage (5 tests, all passing ✅):

  • List page tests (services.list.spec.ts) - 3 tests

    • Navigation to services page
    • Pagination using table controls
    • Pagination using URL search parameters
  • CRUD with required fields (services.crud-required-fields.spec.ts) - 1 test

    • Uses minimal fields (name only)
    • Tests create, read, update, and delete operations
    • Verifies label addition during edit
  • CRUD with all fields (services.crud-all-fields.spec.ts) - 1 test

    • Uses all available fields (name, description, labels, upstream nodes, hosts, WebSocket)
    • Tests complete create and delete operations with complex configurations

Files Added:

  • e2e/utils/ui/services.ts - UI helper functions for form filling and verification with proper selector disambiguation
  • e2e/tests/services.list.spec.ts - List page and pagination tests
  • e2e/tests/services.crud-required-fields.spec.ts - Minimal fields CRUD tests
  • e2e/tests/services.crud-all-fields.spec.ts - All fields CRUD tests

Implementation Details:

  • Proper selector disambiguation using .first() to avoid conflicts between service and upstream fields (name, description, labels)
  • Handles hidden WebSocket switch using JavaScript evaluation
  • Upstream node configuration (host, port, weight) properly filled and verified
  • Follows test patterns from upstreams and routes
  • Proper cleanup with deleteAllServices helper
  • Auto-generated ID capture and verification

Related issues

resolve #3085

Checklist:

  • [x] Did you explain what problem does this PR solve? Or what new features have been added?
  • [x] Have you added corresponding test cases?
  • [ ] Have you modified the corresponding document? (N/A - E2E tests don't require documentation updates)
  • [x] Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first (Yes, only adds tests, no breaking changes)

DSingh0304 avatar Nov 19 '25 06:11 DSingh0304

@Baoyuantop i had to delete that PR because of some of git issues but I recovered the commits and raised the new PR the changes are same as they were in the previous PR the CI issue has also been resolved. I think it should pass the e2e test as it does locally.

DSingh0304 avatar Nov 19 '25 07:11 DSingh0304

Fixed CI timing issues by increasing timeouts to 30s across all toast message assertions and critical backend operations. All 76 E2E tests now pass successfully. The changes ensure reliable test execution in slower CI environments while maintaining the principle that API calls are only used for setup/teardown all CRUD operations use UI interactions as required.

DSingh0304 avatar Nov 21 '25 11:11 DSingh0304

Hi @DSingh0304, please confirm this comment: https://github.com/apache/apisix-dashboard/pull/3258#discussion_r2567283586

Baoyuantop avatar Dec 08 '25 08:12 Baoyuantop

@SkyeYoung The 'serial' mode prevents race conditions during test cleanup. Services have dependent resources (routes/stream routes), and parallel execution was causing intermittent failures when tests tried to delete services that still had active dependencies.

CI likely passed before due to timing luck or fewer parallel tests. As we added more service tests, the race condition became more consistent.

Quoting https://github.com/apache/apisix-dashboard/pull/3258#discussion_r2567283586

DSingh0304 avatar Dec 08 '25 09:12 DSingh0304

Hi @DSingh0304, please confirm this comment: #3258 (comment)

Hey @Baoyuantop , Done.

DSingh0304 avatar Dec 08 '25 09:12 DSingh0304