From 1e5a1f8df1b46d9db6cc13e469cca6c8247b1980 Mon Sep 17 00:00:00 2001 From: Gustavo Alves Date: Fri, 14 Apr 2017 18:13:05 -0300 Subject: [PATCH 1/3] Test environment variables --- circle.yml | 1 - e2e/dashboard.spec.js | 16 ++++++++++++---- e2e/login.spec.js | 22 +++++++++++++++------- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/circle.yml b/circle.yml index 93fc2e9..131afaf 100644 --- a/circle.yml +++ b/circle.yml @@ -5,7 +5,6 @@ machine: # Add some environment variables environment: - CIRCLE_ENV: dev ## Customize dependencies dependencies: diff --git a/e2e/dashboard.spec.js b/e2e/dashboard.spec.js index 112452a..b6af000 100644 --- a/e2e/dashboard.spec.js +++ b/e2e/dashboard.spec.js @@ -3,17 +3,25 @@ describe('The dashboard view', function () { var page; var mainPage; + var testUser = process.env.TEST_USER; + var testPassword = process.env.TEST_PASSWORD; + var testPort = process.env.TEST_PORT || 3000; beforeEach(function () { - browser.get('http://localhost:3000/'); + browser.get('http://localhost:' + testPort + '/'); page = require('./login.po'); mainPage = require('./main.po'); - page.usernameInput.sendKeys('amy_admin'); - page.passwordInput.sendKeys('topcoder1'); - page.loginButton.click(); + }); + + it('should have environment variables defined', function(){ + expect(testUser).toBeDefined(); + expect(testPassword).toBeDefined(); }); it('should find members', function() { + page.usernameInput.sendKeys(testUser); + page.passwordInput.sendKeys(testPassword); + page.loginButton.click(); mainPage.searchHandleInput.sendKeys('sah2ed'); mainPage.searchButton.click(); expect(mainPage.users.count()).toBe(1); diff --git a/e2e/login.spec.js b/e2e/login.spec.js index 2e46633..ec57407 100644 --- a/e2e/login.spec.js +++ b/e2e/login.spec.js @@ -3,13 +3,21 @@ describe('The login view', function () { var page; var mainPage; + var testUser = process.env.TEST_USER; + var testPassword = process.env.TEST_PASSWORD; + var testPort = process.env.TEST_PORT || 3000; beforeEach(function () { - browser.get('http://localhost:3000/'); + browser.get('http://localhost:' + testPort + '/'); page = require('./login.po'); mainPage = require('./main.po'); }); + it('should have environment variables defined', function(){ + expect(testUser).toBeDefined(); + expect(testPassword).toBeDefined(); + }); + it('should display the correct form heading', function() { expect(page.loginHeader.getText()).toBe('ADMIN APP LOGIN'); //expect(page.imgEl.getAttribute('src')).toMatch(/assets\/images\/yeoman.png$/); @@ -27,20 +35,20 @@ describe('The login view', function () { it('login should succeed for correct credentials', function () { //expect(page.thumbnailEls.count()).toBeGreaterThan(5); - page.usernameInput.sendKeys('amy_admin'); - page.passwordInput.sendKeys('topcoder1'); + page.usernameInput.sendKeys(testUser); + page.passwordInput.sendKeys(testPassword); page.loginButton.click(); expect(mainPage.isUserLoggedIn.isDisplayed()).toBeTruthy(); - expect(mainPage.loggedInUser.getText()).toBe('amy_admin'); + expect(mainPage.loggedInUser.getText()).toBe(testUser); }); it('logout should work after login', function () { //expect(page.thumbnailEls.count()).toBeGreaterThan(5); - page.usernameInput.sendKeys('amy_admin'); - page.passwordInput.sendKeys('topcoder1'); + page.usernameInput.sendKeys(testUser); + page.passwordInput.sendKeys(testPassword); page.loginButton.click(); expect(mainPage.isUserLoggedIn.isDisplayed()).toBeTruthy(); - expect(mainPage.loggedInUser.getText()).toBe('amy_admin'); + expect(mainPage.loggedInUser.getText()).toBe(testUser); mainPage.logout.click(); expect(page.loginHeader.getText()).toBe('ADMIN APP LOGIN'); }); From 62207d4c37f8baa549f7218da55387b417f44994 Mon Sep 17 00:00:00 2001 From: Gustavo Alves Date: Fri, 14 Apr 2017 20:11:00 -0300 Subject: [PATCH 2/3] Updated README --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index cea1c58..6dd8a2f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![CircleCI](https://circleci.com/gh/GSTVAC/admin-app.svg?style=svg)](https://circleci.com/gh/GSTVAC/admin-app) + # support-admin-app Support application @@ -37,6 +39,15 @@ The following configuration parameters are available: | AUTH0_TOKEN_NAME | Auth0 token name | | AUTH0_REFRESH_TOKEN_NAME | Auth0 refresh token name | +Environment variables: + +| Name | Description | +| --- | --- | +| BUILD_ENV | Build environment. Default is `dev` | +| TEST_USER | App user to use on tests | +| TEST_PASSWORD | App password to use on tests | +| TEST_PORT | Local port used to run the tests. Default is 3000 | + ## Start the Application Simply execute the following command to start the app in development mode (with browsersync) From 9eb2d1e72233b34b27e55be2de8ee0bc4c58d14f Mon Sep 17 00:00:00 2001 From: Gustavo Alves Date: Sun, 16 Apr 2017 12:49:45 -0300 Subject: [PATCH 3/3] README updates --- README.md | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6dd8a2f..ab65426 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -[![CircleCI](https://circleci.com/gh/GSTVAC/admin-app.svg?style=svg)](https://circleci.com/gh/GSTVAC/admin-app) - +[![CircleCI](https://circleci.com/gh/topcoder-platform/admin-app.svg?style=svg)](https://circleci.com/gh/topcoder-platform/admin-app) # support-admin-app Support application @@ -39,15 +38,6 @@ The following configuration parameters are available: | AUTH0_TOKEN_NAME | Auth0 token name | | AUTH0_REFRESH_TOKEN_NAME | Auth0 refresh token name | -Environment variables: - -| Name | Description | -| --- | --- | -| BUILD_ENV | Build environment. Default is `dev` | -| TEST_USER | App user to use on tests | -| TEST_PASSWORD | App password to use on tests | -| TEST_PORT | Local port used to run the tests. Default is 3000 | - ## Start the Application Simply execute the following command to start the app in development mode (with browsersync) @@ -64,6 +54,15 @@ npm run build ## Execute E2E Tests +Before executing the end-to-end (e2e) protractor tests, these environment variables should be set: + +| Name | Description | Default Value | +| --- | --- | --- | +| BUILD_ENV | Deployment configuration to be tested by e2e tests. | See [Configuration](#configuration) for possible values. Defaults to `dev`. | +| TEST_USER | Account username to use for e2e tests. | No default. Must be set. | +| TEST_PASSWORD | Account password to use for e2e tests. | No default. Must be set. | +| TEST_PORT | Port from which to serve the app for e2e tests. | Defaults to `3000`. | + ```npm test``` ## Fallback instruction in case the npm scripts fail