Skip to content

Commit 81da26b

Browse files
authored
fix(test): prevent infinite Cypress hang in StubWindowNAssert (#42201)
## Description `DeployModeHelper.StubWindowNAssert()` stubs `window.open` with a `callsFake` that sets `window.location.href = url`, navigating the current Cypress tab to an external docs URL (docs.appsmith.com). If that external site is slow or unreachable from CI, Cypress blocks indefinitely — there is no built-in timeout for cross-origin page loads. Observed in CE run [33826464528](https://github.com/appsmithorg/appsmith/actions/runs/33826464528), shard 27: `GoogleSheets_spec.ts` test 2 ("Bug #25004 - Verify Google Sheets documentation opens") hung for **3h49m** before the 6h GH runner default timeout cancelled the job. The same spec completed in ~1min on Sep 1, 2, 3, and 7 — the hang was triggered by external site unreachability, not a code change. ### Root cause The stub redirects the current page to docs.appsmith.com via `window.location.href = url`. Cypress waits for `document.readyState === "complete"` before executing the next queued command. If the external page never finishes loading, Cypress hangs forever — no timeout applies to cross-origin page loads. ### Fix Stub `window.open` without any navigation. Assert the stub was called with the expected URL string (via `stub.firstCall.args[0]`) instead of navigating to the external page and checking `cy.url()`. This: - Tests the same intent: "clicking Learn More calls `window.open` with the correct docs URL" - Eliminates the external dependency entirely - Is deterministic — stub assertions are synchronous ### Impact All callers of `StubWindowNAssert` benefit: - `GoogleSheets_spec.ts` (the spec that hung) - `DSDocs_Spec.ts` (9 callers) - `Snowflake_Basic_Spec.ts` - `Table.ts` → `AssertURLColumnNavigation` - EE: `SCIMConfigResourcesViaUI_spec.ts` No caller depends on the navigation side-effect — each either ends the test afterward or continues with actions on the (unchanged) current page. Fixes https://linear.app/appsmith/issue/APP-15927 ## Automation /ok-to-test tags="@tag.Datasource" ### 🔍 Cypress test results <!-- This section is auto-populated by Cypress. Do not edit --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/34156440825> > Commit: f3cb9b8 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=34156440825&attempt=2" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Datasource` > Spec: > <hr>Tue, 08 Sep 2026 04:56:22 UTC <!-- end of auto-generated comment: Cypress test results --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved validation for links that open in a new window. - Updated documentation link handling to use the current SMTP documentation destination. - Prevented link checks from navigating away from the current page. - **Tests** - Streamlined datasource documentation checks for more reliable test execution. - Improved compatibility with existing link-validation scenarios. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 3d74c59 commit 81da26b

3 files changed

Lines changed: 22 additions & 18 deletions

File tree

app/client/cypress/e2e/Regression/ServerSide/QueryPane/DSDocs_Spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe(
9494
pluginActionForm.toolbar.openContextMenu();
9595
deployMode.StubWindowNAssert(
9696
dataSources._queryDoc,
97-
"connect-data/reference/using-smtp",
97+
"using-smtp",
9898
"getPluginForm",
9999
);
100100
});

app/client/cypress/e2e/Regression/ServerSide/QueryPane/GoogleSheets_spec.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ import {
55
locators,
66
agHelper,
77
} from "../../../../support/Objects/ObjectsCore";
8-
import {
9-
AppSidebar,
10-
AppSidebarButton,
11-
} from "../../../../support/Pages/EditorNavigation";
128

139
describe(
1410
"Google Sheets datasource row objects placeholder",
@@ -60,10 +56,7 @@ describe(
6056
"querying-google-sheets#create-queries",
6157
"getPluginForm",
6258
);
63-
agHelper.GetNClick(locators._visibleTextSpan("Don't save"));
64-
agHelper.Sleep();
65-
AppSidebar.navigate(AppSidebarButton.Editor, true);
66-
agHelper.Sleep();
59+
dataSources.SaveDSFromDialog(false);
6760
});
6861
},
6962
);

app/client/cypress/support/Pages/DeployModeHelper.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,30 @@ export class DeployMode {
112112
public StubWindowNAssert(
113113
selector: string,
114114
expectedUrl: string,
115-
networkCall: string,
115+
// networkCall kept for backward compatibility; no longer used
116+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
117+
networkCall?: string,
116118
) {
117-
this.StubbingWindow();
119+
// Stub window.open WITHOUT navigating to the external URL.
120+
// The old implementation set window.location.href = url, which
121+
// caused a cross-origin navigation to docs.appsmith.com. If that
122+
// site was slow or unreachable from CI, Cypress hung indefinitely
123+
// (no built-in timeout for cross-origin page loads) — see run
124+
// 33826464528 shard 27 where GoogleSheets_spec hung for 4 hours.
125+
//
126+
// The test intent is "the link calls window.open with the correct
127+
// docs URL", NOT "docs.appsmith.com is reachable". Asserting on
128+
// the stub's first argument achieves the same coverage without any
129+
// external dependency.
130+
cy.window({ timeout: 60000 }).then((win: any) => {
131+
cy.stub(win, "open").as("windowStub");
132+
});
118133
this.agHelper.GetNClick(selector, 0, false, 0);
119-
this.agHelper.Sleep(4000);
120-
cy.get("@windowStub").should("be.calledOnce");
121-
cy.url().should("contain", expectedUrl);
122134
this.agHelper.Sleep(2000);
123-
cy.window({ timeout: 60000 }).then((win) => {
124-
win.history.back();
135+
cy.get("@windowStub").should("be.calledOnce");
136+
cy.get("@windowStub").then((stub: any) => {
137+
expect(stub.firstCall.args[0]).to.contain(expectedUrl);
125138
});
126-
this.assertHelper.AssertNetworkResponseData("@" + networkCall);
127-
this.assertHelper.AssertDocumentReady();
128139
}
129140

130141
public NavigateBacktoEditor(toastToCheck = "") {

0 commit comments

Comments
 (0)