Files
superset2/superset-frontend/playwright/utils/constants.ts
Joe Li 335a08a81b feat(embedded-e2e): add Playwright E2E tests for embedded dashboards
Adds five tests covering the embedded dashboard flow against the
world_health example: render, hideTitle UI config, chart rendering,
allowed_domains referrer check, and guest-token data access. Includes:

- A chromium-embedded Playwright project, excluded from the main
  project via testIgnore so it can be opted into separately.
- An EmbeddedPage page object and API helpers for embedding/guest
  tokens plus dashboard lookup by slug.
- A static test app (embedded-app/index.html) loaded from a minimal
  Node static server. Playwright bridges the guest-token fetch from
  Node into the browser via page.exposeFunction.
- EMBEDDED timeout/config constants.

Workflow integration and test-environment configuration land in a
follow-up commit.
2026-05-11 16:11:17 -07:00

93 lines
3.1 KiB
TypeScript

/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Timeout constants for Playwright tests.
* Only define timeouts that differ from Playwright defaults or are semantically important.
*
* Default Playwright timeouts (from playwright.config.ts):
* - Test timeout: 30000ms (30s)
* - Expect timeout: 8000ms (8s)
*
* Use these constants instead of magic numbers for better maintainability.
*/
export const TIMEOUT = {
/**
* Global setup timeout (matches test timeout for cold CI starts)
*/
GLOBAL_SETUP: 30000, // 30s for global setup auth
/**
* Page navigation and load timeouts
*/
PAGE_LOAD: 10000, // 10s for page transitions (login → welcome, dataset → explore)
/**
* Form and UI element load timeouts
*/
FORM_LOAD: 5000, // 5s for forms to become visible (login form, modals)
/**
* API response timeout for operations like export/download
*/
API_RESPONSE: 15000, // 15s for API responses and downloads
/**
* Confirmation dialog wait (e.g., "Confirm save", "Are you sure?")
*/
CONFIRM_DIALOG: 2000, // 2s for confirmation dialogs that may or may not appear
/**
* File import/upload operations (upload + server processing)
*/
FILE_IMPORT: 30000, // 30s for file import operations
/**
* UI transition timeout (tab close, popover dismiss, dropdown close)
*/
UI_TRANSITION: 5000, // 5s ceiling for Ant Design animations (~300-500ms actual)
/**
* SQL query execution (query → backend processing → results)
*/
QUERY_EXECUTION: 15000, // 15s for SQL queries that may take longer than default expect timeout
/**
* Extended test timeout for multi-step tests (page load + query execution + assertions).
* Use with test.setTimeout() when the default 30s test timeout is insufficient.
*/
SLOW_TEST: 60000, // 60s for tests that chain multiple slow operations
} as const;
/**
* Embedded dashboard test app configuration.
* The test app is served by a Node.js http server started in the test fixture.
*/
export const EMBEDDED = {
/** Port for the embedded test app static server */
APP_PORT: 9000,
/** Full URL for the embedded test app */
APP_URL: 'http://localhost:9000',
/** Timeout for iframe to appear in the DOM */
IFRAME_LOAD: 15000, // 15s
/** Timeout for dashboard content to render inside the iframe */
DASHBOARD_RENDER: 30000, // 30s
} as const;