Skip to content

[Testing E2E] Add Test Scenario for User Billing Page#40

Merged
jinnaWan merged 7 commits into
mainfrom
CB-77
Apr 24, 2025
Merged

[Testing E2E] Add Test Scenario for User Billing Page#40
jinnaWan merged 7 commits into
mainfrom
CB-77

Conversation

@jinnaWan
Copy link
Copy Markdown
Collaborator

Summary

image

Backend:

  • Disable billing worker in test environment
  • Add endpoints for trigger billing worker action(/billing/trigger/overdue/{instance_name}, /billing/trigger/expired/{instance_name})
  • Fix logic subscription logic
  • Make user billing overview include OVERDUE transaction

Testing

  • Add test scenario and page for user billing page
  • We can now choose which user to login to each page test case

@jinnaWan jinnaWan requested review from Copilot and nut1414 April 24, 2025 07:34
@jinnaWan
Copy link
Copy Markdown
Collaborator Author

@nut1414 pls help review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds an end‐to‐end test scenario for the User Billing page while updating both backend and frontend components for billing and subscription functionality. Key changes include:

  • Adding endpoints to trigger overdue and expired subscription actions in the backend and corresponding API client methods.
  • Updating the data models, test fixtures, and E2E tests to support the new billing page scenario.
  • Enhancing UI components with new data-testid attributes for more robust test automation.

Reviewed Changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/e2e/pages/user/init.py Updated exported page classes to include UserBillingPage.
test/e2e/pages/instance/instance_list_page.py Added new element and method for instance list assertions.
test/e2e/data/models.py Introduced TransactionData model for transaction-related fixtures.
test/e2e/data/constant.py Added new enums for TransactionType and TransactionStatus.
test/e2e/conftest.py Extended fixture configuration with new user marker support.
test/e2e/api/client.py Introduced billing-related API methods.
frontend/src/pages/User/UserBillingPage.tsx Added data-testid for the billing page container.
frontend/src/pages/Instance/InstanceListPage.tsx Added data-testid for the instance list component.
frontend/src/hooks/User/useUserBilling.ts Adjusted filtering to exclude scheduled transactions from response.
frontend/src/constant/CurrencyConstant.ts Revised currency formatting for numbers to include decimals.
frontend/src/components/User/Billing/TopUpMenu.tsx Added data-testid attributes for key interactive elements.
frontend/src/components/User/Billing/OverviewMenu.tsx Added data-testid attributes for billing overview display items.
frontend/src/components/User/Billing/HistoryMenu.tsx Added data-testid attribute to the history menu component.
frontend/src/components/Common/Table.tsx Updated table markup with conditional data-testid for testing.
backend/src/core/startup.py Adjusted billing worker startup to be conditional on test environment.
backend/src/core/sql/operations/subscription.py Added utility to query subscription by instance identifier/name.
backend/src/core/sql/operations/billing.py Modified upcoming payment computation to include overdue statuses.
backend/src/core/service/subscription.py Changed subscription creation logic for setting payment dates.
backend/src/core/service/billing.py Integrated test environment guard into billing trigger endpoints.
backend/src/core/routers/billing.py Exposed new billing trigger endpoints via the API router.
Comments suppressed due to low confidence (1)

backend/src/core/service/subscription.py:29

  • Changing next_payment_date to the current time instead of adding PAYMENT_INTERVAL (as in the previous behavior) may result in subscriptions being due immediately. Verify that this intended logic is correct or consider reinstating the interval addition to ensure future-dated payments.
next_payment_date = DateTimeUtils.now_dt()

Copy link
Copy Markdown
Owner

@nut1414 nut1414 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been on my mind for awhile now: should we keep only one terminal/console? The current implementation have root terminal and console to login which I think will definitely raise some question to why have both.

Comment thread test/e2e/pages/user/user_billing_page.py
@jinnaWan jinnaWan merged commit 7e7b192 into main Apr 24, 2025
1 check passed
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.

3 participants