From 2793b2213f46f01c6e556be60b96204b7c64801d Mon Sep 17 00:00:00 2001
From: Ben Wheeler <wheeler.benjamin@gmail.com>
Date: Mon, 3 Dec 2018 14:39:40 -0500
Subject: [PATCH] got sounds test passing; problem was reloading url caused
 navigation alert

---
 src/lib/project-saver-hoc.jsx   | 6 ++++--
 test/integration/sounds.test.js | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/lib/project-saver-hoc.jsx b/src/lib/project-saver-hoc.jsx
index 0ddcd967f..af66847a4 100644
--- a/src/lib/project-saver-hoc.jsx
+++ b/src/lib/project-saver-hoc.jsx
@@ -50,7 +50,9 @@ const ProjectSaverHOC = function (WrappedComponent) {
         }
         componentWillMount () {
             if (typeof window === 'object') {
-                window.addEventListener('beforeunload', this.leavePageConfirm);
+                // Note: it might be better to use a listener instead of assigning onbeforeunload;
+                // but then it'd be hard to turn this listening off in our tests
+                window.onbeforeunload = () => this.leavePageConfirm;
             }
         }
         componentDidUpdate (prevProps) {
@@ -92,7 +94,7 @@ const ProjectSaverHOC = function (WrappedComponent) {
         }
         componentWillUnmount () {
             this.clearAutoSaveTimeout();
-            window.removeEventListener('beforeunload', this.leavePageConfirm);
+            window.onbeforeunload = undefined; // eslint-disable-line no-undefined
         }
         leavePageConfirm (e) {
             if (this.props.projectChanged) {
diff --git a/test/integration/sounds.test.js b/test/integration/sounds.test.js
index ca1a3d275..3877ada3f 100644
--- a/test/integration/sounds.test.js
+++ b/test/integration/sounds.test.js
@@ -32,6 +32,7 @@ describe('Working with sounds', () => {
 
         // Delete the sound
         await rightClickText('Meow', scope.soundsTab);
+        await driver.sleep(500); // Wait a moment for context menu; only needed for local testing
         await clickText('delete', scope.soundsTab);
 
         // Add it back
-- 
GitLab