Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[![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

Expand Down Expand Up @@ -53,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
Expand Down
1 change: 0 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ machine:

# Add some environment variables
environment:
CIRCLE_ENV: dev

## Customize dependencies
dependencies:
Expand Down
16 changes: 12 additions & 4 deletions e2e/dashboard.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 15 additions & 7 deletions e2e/login.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Prior to the start of the tests, there should be a check like:

if (testUser == null || testPassword == null) {
// print out warning explaining that tests will fail unless TEST_USER and TEST_PASSWORD environment variables are set.
}

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$/);
Expand All @@ -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');
});
Expand Down