Skip to content

Test Specification: Feedback Submission

See Test Specs Overview for application architecture and test environment setup.

Feature Gating

The Feedback feature is gated on the FEEDBACK_INBOX_ID environment variable. All tests in this spec probe /teams/api/config at the start of each test to detect whether the feature is enabled in the current stack:

  • When the feature is disabled, the "button is hidden" test runs and the submission tests skip themselves.
  • When the feature is enabled, the submission and cancel tests run and the "button is hidden" test skips itself.

This lets the spec run safely against any deployment (local dev, preview, staging, production) without requiring a specific configuration.

Seed Data Requirements

  • A single test user with valid authentication credentials (no multi-user setup required)
  • When the feature is enabled: the configured feedback inbox must exist in the database and be resolvable by /api/config
  • No write access to the feedback inbox is required — the bypass is the whole point

PUT Interception

The submit test intercepts PUT /teams/api/threads/* via page.route() and fulfills a mocked 201 response. This:

  • Keeps the configured feedback inbox clean across E2E runs (especially important on preview apps where the target is support-demo@box.ox.io)
  • Still exercises the full UI flow (modal open, form validation, submit click, modal close)
  • Leaves the server-side bypass path to be covered by spec/backend/routes/threads-mutations.test.ts

Test Scenarios

1.1 Feedback Button is Hidden When the Feature is Disabled

Objective: Verify that the sidebar does not render a Feedback button when FEEDBACK_INBOX_ID is not configured on the backend.

Preconditions:

  1. User is logged into the Teams application
  2. /api/config does NOT return a feedback field (skip test otherwise)

Test Steps:

  1. Navigate to the Teams application root URL (/)
  2. Wait for the application to load

Expected Results:

  • No element with role="button" and accessible name "Feedback" exists on the page (toHaveCount(0))

1.2 Submit Feedback via the Sidebar Button

Objective: Verify that an authenticated user can open the feedback modal, fill in subject and comment, and submit — with form validation and UI flow working end-to-end.

Preconditions:

  1. User is logged into the Teams application
  2. /api/config returns a feedback field with inboxId and inboxName (skip test otherwise)

Test Steps:

  1. Navigate to the Teams application root URL (/)
  2. Verify the Feedback button is visible in the sidebar
  3. Click the Feedback button
  4. Verify the Send Feedback heading is visible (modal opened)
  5. Verify the dialog contains the inbox name from /api/config (read-only display)
  6. Verify the Submit button is disabled while both fields are empty
  7. Fill the subject textbox (Write Subject of the Thread...) with a random subject
  8. Verify the Submit button is still disabled (subject alone is not enough)
  9. Fill the comment textbox (Write your comment here...) with a random sentence
  10. Verify the Submit button is now enabled
  11. Intercept PUT /teams/api/threads/* via page.route() to return a mocked 201 response; other methods pass through with route.continue()
  12. Click the Submit button
  13. Verify the Send Feedback heading is no longer visible (modal closed)
  14. Verify the PUT interception was triggered (putSeen flag)

Expected Results:

  • Button is visible when the feature is enabled
  • Modal opens with the configured inbox name displayed read-only
  • Submit is disabled until both subject AND comment have non-empty values
  • Clicking Submit closes the modal and triggers exactly one PUT request
  • The feedback inbox is NOT polluted (PUT was intercepted and never reached the backend)

Notes:

  • The inbox name displayed in the modal is the one resolved server-side from the DB, not from the raw FEEDBACK_INBOX_ID value — this verifies the /api/config name lookup
  • Subject and comment use faker-generated values so multiple runs do not collide

1.3 Cancel Closes the Modal Without Submitting and Preserves Draft

Objective: Verify that clicking Cancel closes the modal without triggering a submit, and that the subject field retains its value when the modal is reopened.

Preconditions:

  1. User is logged into the Teams application
  2. /api/config returns a feedback field (skip test otherwise)

Test Steps:

  1. Click the Feedback button in the sidebar
  2. Verify the Send Feedback heading is visible
  3. Fill the subject textbox with draft subject
  4. Click the Cancel button
  5. Verify the Send Feedback heading is no longer visible (modal closed)
  6. Click the Feedback button again to reopen the modal
  7. Verify the subject textbox still contains draft subject

Expected Results:

  • Cancel closes the modal without issuing any PUT request
  • Reopening the modal preserves the previously typed subject
  • Only a successful Submit (not Cancel) clears the form

Notes:

  • Draft preservation is intentional — users may close the modal to copy something from another thread and return to finish writing
  • This behavior is asymmetric with Cancel/Submit: Submit clears, Cancel keeps
  • Test file: e2e/tests/feedback.spec.js
  • Feature spec: Feedback Submission
  • Backend unit tests: spec/backend/routes/threads-mutations.test.ts, spec/backend/routes/config.test.ts, spec/backend/resolve-inbox.test.ts
  • Frontend unit tests: spec/frontend/stores/threads-feedback.test.ts