jwir3 / arbitrator

A synchronization engine for ArbiterSports to Google Calendar
GNU General Public License v3.0
3 stars 0 forks source link

Add spectron testing capability #99

Open jwir3 opened 7 years ago

jwir3 commented 7 years ago

There is a the capability to run end-to-end tests using spectron in electron-boilerplate. One difficulty we have, though, is that the google login prompt is shown first. We should be able to have basic functionality without displaying this prompt.

The tasks for this ticket include:

jwir3 commented 7 years ago

A simple patch that starts this:

diff --git a/e2e/Launch.e2e.js b/e2e/Launch.e2e.js
new file mode 100644
index 0000000..e73dee4
--- /dev/null
+++ b/e2e/Launch.e2e.js
@@ -0,0 +1,38 @@
+import { expect } from 'chai';
+import testUtils from './utils';
+
+describe('Core Functionality', function () {
+    beforeEach(testUtils.beforeEach);
+    afterEach(testUtils.afterEach);
+
+    it('shows an application window with the title Arbitrator and title bar text Arbitrator', function () {
+      var app = this.app;
+      var expectedTitle = 'BarfBag';
+      app.client.waitUntilWindowLoaded();
+      app.client.getTitle().then(function(title) {
+        console.log("Checking title");
+        expect(title).to.eq(expectedTitle);
+        expect(app.client.browserWindow.isVisible()).to.be.truthy;
+      });
+
+      // app.client.getText('#pageTitle').then((pageTitle) => {
+      //   expect(pageTitle).to.equal('Arbitrator');
+      // });
+
+      // app.client.
+    });
+
+    // it ('displays the navigation drawer when the hamburger menu is clicked', function () {
+    //   var app = this.app;
+    //   app.client.click('#hamburger').then(() => {
+    //     console.log("Clicked hamburger icon");
+    //     app.client.waitForVisible('#nav-drawer').then(() => {
+    //       console.log("Nav drawer appears to be visible");
+    //     });
+    //     // app.client.isVisible('#nav-drawer').then((visibility) => {
+    //     //   console.log("Testing nav drawer functionality");
+    //     //   expect(visibility).to.be.falsy;
+    //     // });
+    //   });
+    // });
+});
diff --git a/e2e/LocationPreferences.e2e.js b/e2e/LocationPreferences.e2e.js
new file mode 100644
index 0000000..1d103b6
--- /dev/null
+++ b/e2e/LocationPreferences.e2e.js
@@ -0,0 +1,15 @@
+import { expect } from 'chai';
+import testUtils from './utils';
+
+describe('Location Preferences', function () {
+    beforeEach(testUtils.beforeEach);
+    afterEach(testUtils.afterEach);
+
+    it('shows the location preferences view when clicked from the nav drawer', function () {
+      var app = this.app;
+      // expect(app.client.browserWindow.isVisible()).to.be.truthy;
+      // app.client.getTitle().then((title) => {
+      //   expect(title).to.equal('Arbitrator');
+      // });
+    });
+});
diff --git a/e2e/hello_world.e2e.js b/e2e/hello_world.e2e.js
deleted file mode 100644
index 2a38b93..0000000
--- a/e2e/hello_world.e2e.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import { expect } from 'chai';
-import testUtils from './utils';
-
-describe('application launch', function () {
-
-    beforeEach(testUtils.beforeEach);
-    afterEach(testUtils.afterEach);
-
-    it('shows hello world text on screen after launch', function () {
-        return this.app.client.getText('#greet').then(function (text) {
-            expect(text).to.equal('Hello World!');
-        });
-    });
-});
diff --git a/package.json b/package.json
index 8f48ddd..83cf2f8 100644
--- a/package.json
+++ b/package.json
@@ -64,8 +64,7 @@
     "rollup": "^0.34.7",
     "rollup-plugin-istanbul": "^1.1.0",
     "source-map-support": "^0.4.2",
-    "spectron": "^3.3.0"
+    "spectron": "^3.4.0"
   },
-  "dependencies": {
-  }
+  "dependencies": {}
 }