Skip to content

Commit bbe3909

Browse files
fix(cypresS): fix cypress flakiness in ingestionV2/sources.js (#15260)
Co-authored-by: Chris Collins <chriscollins3456@gmail.com>
1 parent 522d8e7 commit bbe3909

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

smoke-test/tests/cypress/cypress/e2e/ingestionV2/utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,13 @@ export const updateIngestionSource = (
9696
updatedSourceName,
9797
options = undefined,
9898
) => {
99+
cy.interceptGraphQLOperation("getIngestionSource");
99100
cy.contains("td", sourceName)
100101
.siblings("td")
101102
.find('[data-testid="ingestion-more-options"]')
102103
.click();
103104
cy.get("body .ant-dropdown-menu").contains("Edit").click();
105+
cy.waitForGraphQLOperation("getIngestionSource");
104106
cy.waitTextVisible("Edit Data Source");
105107
cy.get('[data-testid="recipe-builder-next-button"]').scrollIntoView().click();
106108
cy.waitTextVisible("Configure an Ingestion Schedule");

smoke-test/tests/cypress/cypress/e2e/utils.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ export const aliasQuery = (req, operationName) => {
1212
}
1313
};
1414

15+
// Alias graphql operation (query or mutation)
16+
export const aliasGraphQLOperation = (req, operationName) => {
17+
if (hasOperationName(req, operationName)) {
18+
req.alias = `gql${operationName}`;
19+
}
20+
};
21+
1522
export const getThemeV2Interceptor = (isEnabled) => (req, res) => {
1623
if (hasOperationName(req, "appConfig")) {
1724
res.body.data.appConfig.featureFlags.themeV2Enabled = isEnabled;

smoke-test/tests/cypress/cypress/support/commands.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// -- This is a parent command --
1313

1414
import dayjs from "dayjs";
15-
import { hasOperationName } from "../e2e/utils";
15+
import { hasOperationName, aliasGraphQLOperation } from "../e2e/utils";
1616

1717
function selectorWithtestId(id) {
1818
return `[data-testid="${id}"]`;
@@ -627,6 +627,19 @@ Cypress.Commands.add("setIsThemeV2Enabled", (isEnabled) => {
627627
});
628628
});
629629

630+
Cypress.Commands.add("interceptGraphQLOperation", (operationName) => {
631+
cy.intercept("POST", "/api/v2/graphql", (req) => {
632+
aliasGraphQLOperation(req, operationName);
633+
});
634+
});
635+
636+
Cypress.Commands.add(
637+
"waitForGraphQLOperation",
638+
(operationName, options = {}) => {
639+
cy.wait(`@gql${operationName}`, options);
640+
},
641+
);
642+
630643
Cypress.on("uncaught:exception", (err) => {
631644
const resizeObserverLoopLimitErrMessage =
632645
"ResizeObserver loop limit exceeded";

0 commit comments

Comments
 (0)