Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Fix flaky cursor-filtering diagnostics test (#83398)

Sébastien0feec26aea18
diff --git a/e2e/test-host-app/data-apps/data-app-dev-diagnostics.cy.spec.ts b/e2e/test-host-app/data-apps/data-app-dev-diagnostics.cy.spec.ts
index ae16093dcf4..fda8e35f0ef 100644
--- a/e2e/test-host-app/data-apps/data-app-dev-diagnostics.cy.spec.ts
+++ b/e2e/test-host-app/data-apps/data-app-dev-diagnostics.cy.spec.ts
@@ -111,21 +111,38 @@ describe("Embedding SDK: data-app dev diagnostics", () => {
});
it("serves the report to shell agents, with cursor filtering", () => {
+ // Retry the full read-then-cursor pair until no POST sneaks between
+ // the two GETs. Under CPU throttling the reporter's batched timer can
+ // jitter enough to land a POST in that gap, so a single-pass idle
+ // guard before the first GET is not enough.
+ const verifyStableCursor = (attempt = 0): Cypress.Chainable<void> => {
+ return cy.request(DIAGNOSTICS_URL).then(({ body: report }) => {
+ expect(report.manifest?.errors).to.have.length(0);
+ expect(report.clients).to.be.gte(1);
+
+ return cy
+ .request(`${DIAGNOSTICS_URL}?startEventId=${report.nextEventId}`)
+ .then(({ body: filtered }) => {
+ if (filtered.entries.length === 0) {
+ return;
+ }
+ if (attempt >= 20) {
+ throw new Error("Cursor never stabilized");
+ }
+ return cy
+ .wait(250, { log: false })
+ .then(() => verifyStableCursor(attempt + 1));
+ });
+ });
+ };
+
readDiagnosticsUntil(
DIAGNOSTICS_URL,
"a blocked-network entry and a healthy connection",
(report) =>
report.entries.some((entry) => entry.kind === "blocked-network") &&
report.connection?.reachable === true,
- ).then((report) => {
- expect(report.manifest?.errors).to.have.length(0);
- expect(report.clients).to.be.gte(1);
-
- // A reader that has consumed everything sees an empty page, not a replay.
- cy.request(`${DIAGNOSTICS_URL}?startEventId=${report.nextEventId}`)
- .its("body.entries")
- .should("be.empty");
- });
+ ).then(() => verifyStableCursor());
});
it("keeps the buffer across a page reload, with continuous event ids", () => {