From 011bcf15c7eba8f7dcd45731f8e434b2eccf781e Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Thu, 9 Sep 2021 21:44:59 +0300 Subject: [PATCH] fix: close overlay on disconnection (#3825) --- client-src/index.js | 12 +- .../overlay.test.js.snap.webpack4 | 170 ++++++++++++------ .../overlay.test.js.snap.webpack5 | 170 ++++++++++++------ test/e2e/overlay.test.js | 89 +++++++-- 4 files changed, 322 insertions(+), 119 deletions(-) diff --git a/client-src/index.js b/client-src/index.js index 5dd697e983..63251d7992 100644 --- a/client-src/index.js +++ b/client-src/index.js @@ -161,12 +161,12 @@ const onSocketMessage = { log.warn(strippedWarnings[i]); } - const needShowOverlay = + const needShowOverlayForWarnings = typeof options.overlay === "boolean" ? options.overlay : options.overlay && options.overlay.warnings; - if (needShowOverlay) { + if (needShowOverlayForWarnings) { show(warnings, "warnings"); } @@ -185,12 +185,12 @@ const onSocketMessage = { log.error(strippedErrors[i]); } - const needShowOverlay = + const needShowOverlayForErrors = typeof options.overlay === "boolean" ? options.overlay : options.overlay && options.overlay.errors; - if (needShowOverlay) { + if (needShowOverlayForErrors) { show(errors, "errors"); } }, @@ -200,6 +200,10 @@ const onSocketMessage = { close() { log.info("Disconnected!"); + if (options.overlay) { + hide(); + } + sendMessage("Close"); }, }; diff --git a/test/e2e/__snapshots__/overlay.test.js.snap.webpack4 b/test/e2e/__snapshots__/overlay.test.js.snap.webpack4 index 804589bc46..d8a4d50c72 100644 --- a/test/e2e/__snapshots__/overlay.test.js.snap.webpack4 +++ b/test/e2e/__snapshots__/overlay.test.js.snap.webpack4 @@ -1,5 +1,33 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`overlay should not show a warning when "client.overlay" is "false": page html 1`] = ` +" + + +" +`; + +exports[`overlay should not show a warning when "client.overlay.warnings" is "false": page html 1`] = ` +" + + +" +`; + +exports[`overlay should not show an error when "client.overlay" is "false": page html 1`] = ` +" + + +" +`; + +exports[`overlay should not show an error when "client.overlay.errors" is "false": page html 1`] = ` +" + + +" +`; + exports[`overlay should not show initially, then show on an error and allow to close: overlay html 1`] = ` "
- - -" -`; - -exports[`overlay should not show on a warning when "client.overlay.warnings" is "false": page html 1`] = ` -" - - -" -`; - -exports[`overlay should not show on an error when "client.overlay" is "false": page html 1`] = ` -" - - -" -`; - -exports[`overlay should not show on an error when "client.overlay.errors" is "false": page html 1`] = ` -" - - -" -`; - -exports[`overlay should show on a warning and error for initial compilation and protects against xss: overlay html 1`] = ` +exports[`overlay should show a warning and error for initial compilation and protects against xss: overlay html 1`] = ` "
+ +" +`; + +exports[`overlay should show a warning and hide them after closing connection: page html 2`] = ` +" + + +" +`; + +exports[`overlay should show a warning for initial compilation: overlay html 1`] = ` "
+ +" +`; + +exports[`overlay should show a warning and hide them after closing connection: page html 2`] = ` +" + + +" +`; + +exports[`overlay should show a warning for initial compilation: overlay html 1`] = ` "