Skip to content
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d01c07f
initial setup
ginnyyadav Jan 7, 2021
229cc8d
Update login.spec.js
ginnyyadav Jan 7, 2021
7e12185
Update yarn.lock
ginnyyadav Jan 7, 2021
dedd28b
introduce page objects
ginnyyadav Jan 8, 2021
9ccaca1
create basic smoke test
ginnyyadav Jan 8, 2021
c680474
rename config file
ginnyyadav Jan 8, 2021
43fee77
attempt to run spectron on CI
ginnyyadav Jan 8, 2021
266707d
attmept to dismiss modal driver on ci
ginnyyadav Jan 9, 2021
83e23d1
attempt at modal driver update dismiss button
ginnyyadav Jan 9, 2021
f12ae9c
dismissing driver modal attempt
ginnyyadav Jan 9, 2021
747de4a
get spectron tests to run on appveyor
ginnyyadav Jan 9, 2021
84fd7bb
create env variables for sensitive info
ginnyyadav Jan 26, 2021
b7fb43f
fix appveyor variables
ginnyyadav Jan 26, 2021
e30eefa
Revert "fix appveyor variables"
ginnyyadav Jan 26, 2021
e90bd84
versioning
ginnyyadav Jan 26, 2021
aa73bf9
remove mocha in favor of jest
ginnyyadav Jan 28, 2021
6476acb
reconfigure file structure for jest
ginnyyadav Jan 28, 2021
3aa1907
run tests with jest command
ginnyyadav Jan 28, 2021
77c7ae5
don't run spectron tests with unit tests
ginnyyadav Jan 28, 2021
8b2f71c
initial tests with better syntax
ginnyyadav Jan 28, 2021
e4b92d1
more specific selectors for links
ginnyyadav Jan 28, 2021
d0df5d9
verify we reached the upload screen
ginnyyadav Jan 28, 2021
37b5c33
add selectors for test implementation later
ginnyyadav Jan 28, 2021
3ee3068
update readme to reflect spectron tests
ginnyyadav Jan 28, 2021
6b5d8b2
attempt at fixing windows execution
ginnyyadav Jan 28, 2021
1ab0eec
another attempt at fixing path for windows
ginnyyadav Jan 29, 2021
8d07102
removing all cross-platform non-friendly paths
ginnyyadav Jan 29, 2021
53b1d91
works locally on windows now
ginnyyadav Jan 29, 2021
d3a74c0
set global jest timeout modify paths once more
ginnyyadav Feb 1, 2021
869f857
simplify login
ginnyyadav Feb 3, 2021
0f8fa63
run jest with default configuration
ginnyyadav Feb 3, 2021
08a0b82
fix driver modal dismiss
ginnyyadav Feb 3, 2021
81877b4
make sure uploader is alway in focus
ginnyyadav Feb 3, 2021
3b92fde
update lock-file
ginnyyadav Feb 3, 2021
123972a
longer timeout for windows
ginnyyadav Feb 3, 2021
fae161d
add remote desktop for troubleshooting
ginnyyadav Feb 3, 2021
ac5aa2b
set rdp password in project
ginnyyadav Feb 3, 2021
5e4f75c
wait for login button to load before clicking on it
ginnyyadav Feb 3, 2021
82afaae
waiting for login button to be visible
ginnyyadav Feb 3, 2021
0cc20df
pause for login button to load
ginnyyadav Feb 3, 2021
3c47c7b
make sure uploader windows close on windows
ginnyyadav Feb 3, 2021
b83d16b
Update README.md
ginnyyadav Feb 4, 2021
a5f6f42
remove run from yarn command
ginnyyadav Feb 4, 2021
764cc48
Delete package-lock.json
ginnyyadav Feb 4, 2021
f174a26
Merge branch 'integrate-spectron' of https://github.com/tidepool-org/…
ginnyyadav Feb 4, 2021
f01ad83
remove test versioning for merge
ginnyyadav Feb 10, 2021
e959c4f
Merge branch 'master' into integrate-spectron
ginnyyadav Feb 11, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
# Test
- run: yarn lint
- run: yarn test
- run: yarn run spectron-test

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- run: yarn run spectron-test
- run: yarn spectron-test

- run: greenkeeper-lockfile-upload
# Package
- run: if [ -z "$CIRCLE_PR_NUMBER" ]; then yarn package; else echo "Forked repo; no package built."; fi
Expand Down
1 change: 1 addition & 0 deletions .mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
timeout: false
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tidepool-uploader",
"productName": "tidepool-uploader",
"version": "2.34.0",
"version": "2.34.0-integrate-spectron.1",
"description": "Tidepool Project Universal Uploader",
"main": "./main.prod.js",
"author": {
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ test_script:
- node --version
- yarn lint
- yarn test
- yarn run spectron-test

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- yarn run spectron-test
- yarn spectron-test

- cmd: IF /I "%ROLLBAR_POST_TOKEN%"=="" ( ECHO Missing Rollbar POST token; no package built. ) ELSE ( yarn package )
# submit uploader release to antivirus vendors if tagged
- cmd: IF /I %APPVEYOR_REPO_TAG% == True ( yarn av-whitelist ) ELSE ( echo Not a tagged release. )
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tidepool-uploader",
"version": "2.34.0",
"version": "2.34.0-integrate-spectron.1",
"description": "Tidepool Project Universal Uploader",
"private": true,
"main": "main.prod.js",
Expand Down Expand Up @@ -31,7 +31,8 @@
"package-win": "npm run build && electron-builder --win --x64",
"package-mac": "npm run build && electron-builder --mac",
"package-linux": "npm run build && electron-builder --linux",
"package-all": "npm run build && electron-builder -mwl"
"package-all": "npm run build && electron-builder -mwl",
"spectron-test": "yarn build && mocha -r esm"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've migrated from mocha to jest a while ago. I'm just wondering whether the spectron tests will work with jest, or is it only possible with mocha?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops, didn't realize that, totally will work with jest, will make it so!

},
"dependencies": {
"@hot-loader/react-dom": "16.14.0",
Expand Down Expand Up @@ -129,6 +130,7 @@
"babel-plugin-transform-define": "2.0.0",
"babel-plugin-transform-react-remove-prop-types": "0.4.24",
"chai": "4.2.0",
"chai-as-promised": "7.1.1",
"concurrently": "5.3.0",
"cross-env": "7.0.2",
"css-loader": "3.6.0",
Expand All @@ -145,8 +147,8 @@
"eslint-formatter-pretty": "3.0.1",
"eslint-import-resolver-webpack": "0.12.2",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jsx-a11y": "6.4.1",
"eslint-plugin-jest": "23.20.0",
"eslint-plugin-jsx-a11y": "6.4.1",
"eslint-plugin-lodash": "7.1.0",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-react": "7.21.5",
Expand All @@ -162,6 +164,7 @@
"json-loader": "0.5.7",
"less-loader": "6.2.0",
"mini-css-extract-plugin": "0.12.0",
"mocha": "8.2.1",
"node-hid": "1.1.0",
"object-invariant-test-helper": "0.1.1",
"open": "7.3.0",
Expand All @@ -175,8 +178,8 @@
"style-loader": "1.3.0",
"terser-webpack-plugin": "3.1.0",
"url-loader": "2.3.0",
"webpack-bundle-analyzer": "3.9.0",
"webpack": "4.44.2",
"webpack-bundle-analyzer": "3.9.0",
"webpack-cli": "3.3.12",
"webpack-dev-middleware": "3.7.2",
"webpack-dev-server": "3.11.0",
Expand Down
Empty file removed test/e2e.js
Empty file.
9 changes: 0 additions & 9 deletions test/example.js

This file was deleted.

53 changes: 53 additions & 0 deletions test/login.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* eslint-disable no-undef */
import LoginScreen from './src/LoginScreen';
import Base from './src/Base';
import { startApp, stopApp } from './utilities';

describe('Smoke Test', () => {
let app;
before(async () => {
app = await startApp();
});


after(async () => {
await stopApp(app);
});

it('should open', async () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually async? I don't see an await.

Base.appIsOpen().should.eventually.equal(1);
});

it('should see if driver modal exists', async () => {
let check = await app.client.isExisting(LoginScreen.driverDismiss);
if (check){
await app.client.click(LoginScreen.driverDismiss);
};
});

it('should have all UI elements', async () => {
await LoginScreen.signUpLink.should.eventually.exist;
await LoginScreen.tidepoolLogo.should.eventually.exist;
await LoginScreen.uploaderLogo.getText()
.should.eventually.equal('Uploader');
await LoginScreen.forgotPasswordLink.should.eventually.exist;
await LoginScreen.supportLink.getText()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember we had an issue for a while where the support link wasn't working. Can we also add tests here to check that the URLs don't 404?

.should.eventually.equal('Get Support');
await LoginScreen.privacyLink.getText()
.should.eventually.equal('Privacy and Terms of Use');
await LoginScreen.jdrfText.should.eventually.exist;
await LoginScreen.jdrfLogo.should.eventually.exist;
await LoginScreen.version.should.eventually.exist;

});

it('should login', async () => {
await LoginScreen.usernameInput.setValue(LoginScreen.loginUsername);
await LoginScreen.usernameInput.getValue()
.should.eventually.equal(LoginScreen.loginUsername);
await LoginScreen.passwordInput.setValue(LoginScreen.loginPassword);
await LoginScreen.passwordInput.getValue()
.should.eventually.equal(LoginScreen.loginPassword);
await LoginScreen.loginButton.click();
});
});
3 changes: 3 additions & 0 deletions test/specConfig/Config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const spectronUserEmail = process.env.SPECTRON_USER_EMAIL;

export const spectronUserPassword = process.env.SPECTRON_USER_PASSWORD;
11 changes: 11 additions & 0 deletions test/src/Base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

class Base {
setApp = function(app) {
this.app = app;
}
appIsOpen() {
return this.app.client.waitUntilWindowLoaded().getWindowCount();
}
};

export default new Base();
54 changes: 54 additions & 0 deletions test/src/LoginScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import {spectronUserEmail, spectronUserPassword} from './../specConfig/Config';

class LoginScreen {
setApp = function(app) {
this.app = app;
};
get loginUsername() {
return spectronUserEmail;
};
get loginPassword() {
return spectronUserPassword;
};
get usernameInput() {
return this.app.client.$('[placeholder="Email"]');
};
get passwordInput() {
return this.app.client.$('[placeholder="Password"]');
};
get loginButton() {
return this.app.client.$('button[type="submit"]');
};
get signUpLink() {
return this.app.client.$('[href*="signup"]');
};
get tidepoolLogo() {
return this.app.client.$('img[class*="logo"]');
};
get uploaderLogo() {
return this.app.client.$('div[class*="heroText"]');
};
get forgotPasswordLink() {
return this.app.client.$('a[href*="request-password"]');
};
get supportLink(){
return this.app.client.$('a[href="http://support.tidepool.org/"]');
};
get privacyLink(){
return this.app.client.$('a[href="http://tidepool.org/legal/"]');
};
get jdrfText() {
return this.app.client.$('span[class*="jdrfText"]');
};
get jdrfLogo() {
return this.app.client.$('img[class*="jdrfImage"]');
};
get version() {
return this.app.client.$('div[class*="version"]');
};
get driverDismiss() {
return 'button[class*="btnSecondary"]';
}
};

export default new LoginScreen();
29 changes: 29 additions & 0 deletions test/utilities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Application } from 'spectron';
import { should, use } from 'chai';
import chaiAsPromised from 'chai-as-promised';
import electron from 'electron';
import path from 'path';
import LoginScreen from './src/LoginScreen';
import Base from './src/Base';

global.before(() => {
should();
use(chaiAsPromised);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding a comment here to explain why chaiAsPromised is necessary here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this won't be here if we use jest i think.

});

export async function startApp() {
const app = new Application({
path: electron,
args: [path.join(__dirname, '../app')],
});
chaiAsPromised.transferPromiseness = app.transferPromiseness;
LoginScreen.setApp(app);
Base.setApp(app);
return app.start();
}

export async function stopApp(app) {
if (app && app.isRunning()) {
await app.stop();
}
}
Loading