Skip to content

feat: Add search terms and products added to cart widgets#429

Open
kallilsouza wants to merge 1 commit into
mainfrom
feature/add-search-terms-and-added-to-cart-widgets-to-conversations-dashboard
Open

feat: Add search terms and products added to cart widgets#429
kallilsouza wants to merge 1 commit into
mainfrom
feature/add-search-terms-and-added-to-cart-widgets-to-conversations-dashboard

Conversation

@kallilsouza

@kallilsouza kallilsouza commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

What

  • Extended CreateConversationsDashboard to provision the conversations dashboard together with its initial widgets (conversations.search_term and conversations.product_added_to_cart) inside a single atomic transaction.
  • Introduced a CONVERSATIONS_DASHBOARD_WIDGETS constant and a private _create_widgets helper to centralize the list of default widgets.
  • Added a new test module test_conversations_dashboard_creation.py covering the happy path, duplicate-dashboard guard, and rollback behavior when widget creation fails.

Why

The new widgets will be used to inform the frontend application to render the new cards for search terms and products added to cart.

Notes

  • There is no config intentionally, because it is not necessary for this case.
  • Existing dashboards will receive the new widgets with the execution of scripts to create them.
  • The name of the widget as it is in the database will NOT be rendered for the user, the frontend application will use translated strings for each language.

Sequence diagram

sequenceDiagram
    participant Caller
    participant UseCase as CreateConversationsDashboard
    participant DB as Database
    participant DashboardModel as Dashboard
    participant WidgetModel as Widget
    Caller->>UseCase: create_dashboard(project)
    UseCase->>DashboardModel: filter(project, name=CONVERSATIONS_DASHBOARD_NAME).exists()
    DashboardModel->>DB: SELECT
    DB-->>DashboardModel: result
    DashboardModel-->>UseCase: exists?
    alt Dashboard already exists
        UseCase-->>Caller: raise Exception
    else Dashboard does not exist
        UseCase->>DB: BEGIN transaction
        UseCase->>DashboardModel: create(project, config, ...)
        DashboardModel->>DB: INSERT dashboard
        DB-->>DashboardModel: dashboard
        DashboardModel-->>UseCase: dashboard
        loop for each widget in CONVERSATIONS_DASHBOARD_WIDGETS
            UseCase->>WidgetModel: create(dashboard, name, type, source, ...)
            WidgetModel->>DB: INSERT widget
            DB-->>WidgetModel: widget
        end
        alt Any creation fails
            UseCase->>DB: ROLLBACK
            UseCase-->>Caller: raise Exception
        else All succeed
            UseCase->>DB: COMMIT
            UseCase-->>Caller: dashboard
        end
    end
Loading

- Introduced tests to validate the creation of the conversations dashboard, ensuring it persists with the expected fields and associated widgets.
- Added checks for handling existing dashboards and rollback behavior during widget creation failures.
- Refactored the dashboard creation logic to include widget creation within a transaction.
@kallilsouza kallilsouza marked this pull request as ready for review June 8, 2026 14:35
@kallilsouza kallilsouza changed the title feat: add unit tests for conversations dashboard creation feat: Add search terms and products added to cart widgets Jun 8, 2026
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