tests(incidents_v2): fix flakiness by waiting for sibling specific test id (#14589)

This commit is contained in:
Gabe Lyons 2025-08-28 21:50:14 -07:00 committed by GitHub
parent d8281bfb41
commit edddd5b371
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 8 deletions

View File

@ -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 ? (
<Dropdown placement="bottom" menu={{ items: siblingSelectionOptions }}>
<CreateButton
disabled={!canEditIncidents}
data-testid="create-incident-btn-main"
data-testid={getTestId()}
className="create-incident-button"
>
<PlusOutlined /> Create
@ -72,7 +79,7 @@ export const CreateIncidentButton = ({ privileges, setShowIncidentBuilder, setEn
<CreateButton
onClick={() => setShowIncidentBuilder(true)}
disabled={!canEditIncidents}
data-testid="create-incident-btn-main"
data-testid={getTestId()}
className="create-incident-button"
>
<PlusOutlined /> Create

View File

@ -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