Files
zeekay 40d120dbf7 refactor(api): say /v1/ in the Python callers
Every first-party Python caller and test now names the mount the API actually
answers on. Mechanical: URL literals only, and only where the /api/ was ours --
a preceding word character means it was a module path like insights/api/ or a
third-party host like slack.com/api/, and those are untouched.

Left saying /api/, each for a reason rather than for safety:
- products/warehouse_sources/.../sources/** is a catalogue of vendor endpoints
- services/llm-gateway deploys separately and is under a code freeze, so moving
  its two calls would break it during the skew
- the mcp_store and Slack/Teams redirect_uris are registered with third parties
  and must byte-match what was registered
- the Wizard and Raycast client-metadata paths are OAuth client_ids
- /api/surveys and /api/feature_flag/local_evaluation are SDK aliases the
  ingress routes to the Rust fleets, held by released SDK versions

Test URLconfs moved with the requests that call them, and the Datastore
user-selection fixtures now carry the leading slash that request.path has.
2026-08-08 18:38:44 -07:00

50 lines
2.4 KiB
TypeScript

import { PlaywrightWorkspaceSetupResult, expect, test } from '@playwright-utils/workspace-test-base'
import { Page } from '@playwright/test'
test.describe('Survey Settings', () => {
let workspace: PlaywrightWorkspaceSetupResult | null = null
test.beforeAll(async ({ playwrightSetup }) => {
workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true, no_demo_data: true })
})
test.beforeEach(async ({ page, playwrightSetup }) => {
await playwrightSetup.loginAndNavigateToTeam(page, workspace!)
await page.goToMenuItem('surveys')
})
async function toggleSurveysSettingsAndWaitResponse(page: Page): Promise<void> {
const responsePromise = page.waitForResponse(
(resp) => resp.url().includes('/v1/environments/') && resp.request().method() === 'PATCH'
)
await page.locator('[data-attr="opt-in-surveys-switch"]').click()
await responsePromise
await expect(page.getByTestId('opt-in-surveys-switch')).not.toBeDisabled()
await expect(page.getByText('Surveys opt in updated').first()).toBeVisible()
await page.getByTestId('toast-close-button').first().click()
await expect(page.getByText('Surveys opt in updated')).toHaveCount(0)
}
test('toggles survey opt in on the survey settings page', async ({ page }) => {
await expect(page.locator('h1')).toContainText('Surveys')
await expect(page).toHaveTitle('Surveys • Insights')
await page.getByRole('tab', { name: 'Settings' }).click()
await expect(page.getByTestId('opt-in-surveys-switch')).not.toBeDisabled()
await expect(page.getByText('Surveys opt in updated')).not.toBeVisible()
await toggleSurveysSettingsAndWaitResponse(page)
await toggleSurveysSettingsAndWaitResponse(page)
})
test('toggles survey opt in on the org settings page', async ({ page }) => {
await expect(page.locator('h1')).toContainText('Surveys')
await expect(page).toHaveTitle('Surveys • Insights')
await page.goToMenuItem('settings')
await page.locator('#main-content').getByRole('link', { name: 'Surveys', exact: true }).click()
await expect(page.getByTestId('opt-in-surveys-switch')).not.toBeDisabled()
await expect(page.getByText('Surveys opt in updated')).not.toBeVisible()
await toggleSurveysSettingsAndWaitResponse(page)
await toggleSurveysSettingsAndWaitResponse(page)
})
})