You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by jd...@apache.org on 2020/07/27 19:20:57 UTC

[qpid-dispatch] branch master updated: DISPATCH-1725 Fix the flaky tests in Jest Web Console suite (#785)

This is an automated email from the ASF dual-hosted git repository.

jdanek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git


The following commit(s) were added to refs/heads/master by this push:
     new a91e3d5  DISPATCH-1725 Fix the flaky tests in Jest Web Console suite (#785)
a91e3d5 is described below

commit a91e3d5ba188cf9e5143721560fe39a476cc74f2
Author: Jiri Daněk <jd...@redhat.com>
AuthorDate: Mon Jul 27 21:20:51 2020 +0200

    DISPATCH-1725 Fix the flaky tests in Jest Web Console suite (#785)
---
 .../react/src/overview/dashboard/inflightChart.test.js    | 10 +++++++---
 .../react/src/overview/dashboard/throughputChart.test.js  | 15 +++++++--------
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/console/react/src/overview/dashboard/inflightChart.test.js b/console/react/src/overview/dashboard/inflightChart.test.js
index a9f319a..985a066 100644
--- a/console/react/src/overview/dashboard/inflightChart.test.js
+++ b/console/react/src/overview/dashboard/inflightChart.test.js
@@ -23,7 +23,10 @@ import { service, login, TEST_PORT } from "../../serviceTest";
 import InflightChart from "./inflightChart";
 import InflightChartData from "./inflightData";
 
-it("renders the InflightChart component", () => {
+it("renders the InflightChart component", (done) => {
+  // the chart only renders if parent's clientWidth != 0
+  Object.defineProperty(window.HTMLDivElement.prototype, 'clientWidth', {value: 1});
+
   const props = {
     service,
     chartData: new InflightChartData(service)
@@ -34,8 +37,9 @@ it("renders the InflightChart component", () => {
     expect(service.management.connection.is_connected()).toBe(true);
 
     const { getByLabelText } = render(<InflightChart {...props} />);
-
     // make sure it rendered the component
-    setTimeout(() => expect(getByLabelText("inflight-chart")).toBeInTheDocument(), 1);
+    expect(getByLabelText("Messages in flight")).toBeInTheDocument();
+
+    done()
   });
 });
diff --git a/console/react/src/overview/dashboard/throughputChart.test.js b/console/react/src/overview/dashboard/throughputChart.test.js
index dc3e75b..269d8fc 100644
--- a/console/react/src/overview/dashboard/throughputChart.test.js
+++ b/console/react/src/overview/dashboard/throughputChart.test.js
@@ -23,7 +23,10 @@ import { service, login, TEST_PORT } from "../../serviceTest";
 import ThroughputChartData from "./throughputData";
 import ThroughputChart from "./throughputChart";
 
-it("renders the ThroughputChart component", () => {
+it("renders the ThroughputChart component", (done) => {
+  // the chart only renders if parent's clientWidth != 0
+  Object.defineProperty(window.HTMLDivElement.prototype, 'clientWidth', {value: 1});
+
   const props = {
     service,
     chartData: new ThroughputChartData(service)
@@ -33,13 +36,9 @@ it("renders the ThroughputChart component", () => {
   login(() => {
     expect(service.management.connection.is_connected()).toBe(true);
 
-    const { getByLabelText, queryByLabelText } = render(<ThroughputChart {...props} />);
-
-    // the component should initially render
-    // blank until it gets the contianer's width.
-    expect(queryByLabelText("throughput-chart")).toBe(null);
+    const { getByLabelText } = render(<ThroughputChart {...props} />);
+    expect(getByLabelText("Messages delivered per second")).toBeInTheDocument();
 
-    // yeild, so that this componentDidMount method can fire
-    setTimeout(() => expect(getByLabelText("throughput-chart")).toBeInTheDocument(), 1);
+    done();
   });
 });


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org