diff --git a/datahub-web-react/src/app/entityV2/shared/tabs/Incident/CreateIncidentButton.tsx b/datahub-web-react/src/app/entityV2/shared/tabs/Incident/CreateIncidentButton.tsx index cd228d8027..53d62ef6e3 100644 --- a/datahub-web-react/src/app/entityV2/shared/tabs/Incident/CreateIncidentButton.tsx +++ b/datahub-web-react/src/app/entityV2/shared/tabs/Incident/CreateIncidentButton.tsx @@ -11,7 +11,7 @@ import { useIsSeparateSiblingsMode } from '@src/app/entity/shared/siblingUtils'; import PlatformIcon from '@src/app/sharedV2/icons/PlatformIcon'; export const CreateIncidentButton = ({ privileges, setShowIncidentBuilder, setEntity }: CreateIncidentButtonProps) => { - const { entityData, urn: entityUrn, entityType: dataEntityType } = useEntityData(); + const { entityData, urn: entityUrn, entityType: dataEntityType, loading } = useEntityData(); const isHideSiblingMode = useIsSeparateSiblingsMode(); @@ -55,13 +55,20 @@ export const CreateIncidentButton = ({ privileges, setShowIncidentBuilder, setEn ), })); + // Dynamic test IDs based on loading state + const getTestId = () => { + if (loading) return 'create-incident-btn-loading'; + if (isSiblingMode) return 'create-incident-btn-main-with-siblings'; + return 'create-incident-btn-main'; + }; + return ( <> {isSiblingMode ? ( Create @@ -72,7 +79,7 @@ export const CreateIncidentButton = ({ privileges, setShowIncidentBuilder, setEn setShowIncidentBuilder(true)} disabled={!canEditIncidents} - data-testid="create-incident-btn-main" + data-testid={getTestId()} className="create-incident-button" > Create diff --git a/smoke-test/tests/cypress/cypress/e2e/incidentsV2/v2_incidents.js b/smoke-test/tests/cypress/cypress/e2e/incidentsV2/v2_incidents.js index ffbb779f2b..df910a136a 100644 --- a/smoke-test/tests/cypress/cypress/e2e/incidentsV2/v2_incidents.js +++ b/smoke-test/tests/cypress/cypress/e2e/incidentsV2/v2_incidents.js @@ -180,13 +180,13 @@ describe("incidents", () => { "/dataset/urn:li:dataset:(urn:li:dataPlatform:bigquery,cypress_project.jaffle_shop.customers,PROD)/Incidents?is_lineage_mode=false&separate_siblings=false", ); - // Wait for the page to load properly and button to be interactive - cy.findByTestId("create-incident-btn-main", { timeout: 10000 }).should( - "be.visible", - ); + // Wait for loading to complete and use the correct test ID for sibling mode + cy.findByTestId("create-incident-btn-main-with-siblings", { + timeout: 10000, + }).should("be.visible"); // Click the button (this opens a dropdown when separate_siblings=false and siblings exist) - cy.findByTestId("create-incident-btn-main").click(); + cy.findByTestId("create-incident-btn-main-with-siblings").click(); // For separate_siblings=false mode, we need to select a sibling from the dropdown first // Wait for dropdown to appear and select the first option