Skip to content

Commit

Permalink
[Chore #159033109] Write end-to-end test
Browse files Browse the repository at this point in the history
1. Update readme with instructions for end to end testing
2. install and setup nightwatch module, selenium and jdk for end to end testing
3. Modify script to run end2end test in package.json
4. Write end2end test for center
5. Write end2end tests for users
6. Write end to end tests for events
7. Implement feedback on component test: better description

[Finishes  #159033109]
  • Loading branch information
Anaeze Nsoffor authored and Anaeze Nsoffor committed Jul 17, 2018
1 parent 8f0b229 commit ddd5204
Show file tree
Hide file tree
Showing 42 changed files with 3,947 additions and 182 deletions.
4 changes: 3 additions & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ checks:
exclude_paths:
- "server/migrations"
- "server/tests"
- "client/__test__"
- "client/__test__"
- "e2e_files"
- "end2end"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ npm-debug.log.3159501567
.DS_Store
template/.DS_Store
dist
/reports
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ Given you manage an events center, this app will help you accept applications to


## Testing the Application
1. "npm test" → run API tests
2. "npm run test:e2e" → Runs end-to-end unit tests
3. "npm run test:react" → Runs frontend tests
1. API test → "npm run test:api"
2. End-to-end test → Install latest JDK, Set superAdmin username and password using `SUPER_ADMIN` and `SUPER_ADMIN_PASS` respectively in your .env file, then run "npm run test:e2e"
3. Frontend test → "npm run test:react"

## Documentation

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Tests for addEvent component should render self without crashing 1`] = `
exports[`Tests for centerDetails component should render self without crashing 1`] = `
<div>
<h2>
Loading...
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Tests for addEvent component should render self without crashing 1`] = `
exports[`Tests for centerList component should render self without crashing 1`] = `
<div
className="mx-sm-auto col-sm-11"
>
Expand All @@ -11,6 +11,7 @@ exports[`Tests for addEvent component should render self without crashing 1`] =
</b>
<Filter
handleSearch={[Function]}
id="filter-centers"
placeholder="Filter by name or location..."
/>
<div
Expand Down
55 changes: 0 additions & 55 deletions client/__test__/components/__snapshots__/centerRouter.test.js.snap

This file was deleted.

9 changes: 5 additions & 4 deletions client/__test__/components/__snapshots__/sidebar.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Tests for addEvent component should render self without crashing 1`] = `
exports[`Tests for sidebar component should render self without crashing 1`] = `
<div
aria-hidden="true"
aria-labelledby="myModalSidebarLabel"
Expand Down Expand Up @@ -29,6 +29,7 @@ exports[`Tests for addEvent component should render self without crashing 1`] =
</h5>
<div
data-dismiss="modal"
id="toggle-sidebar"
>
<Icon
alt="close"
Expand All @@ -52,21 +53,21 @@ exports[`Tests for addEvent component should render self without crashing 1`] =
/>
<ListItem
alt="myCenters"
class="nav-item"
class="nav-item center-list"
event={[Function]}
icon="glyphicons-503-map.png"
title="Centers"
/>
<ListItem
alt="myProfile"
class="nav-item"
class="nav-item user-profile"
event={[Function]}
icon="glyphicons-4-user.png"
title="MyProfile"
/>
<ListItem
alt="userList"
class="nav-item allUsers"
class="nav-item all-users"
event={[Function]}
icon="glyphicons-44-group.png"
title="All Users"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Tests for addEvent component should render self without crashing 1`] = `
exports[`Tests for signin component should render self without crashing 1`] = `
<Redirect
push={false}
to="/dashboard"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Tests for addEvent component should render self without crashing 1`] = `
exports[`Tests for signup component should render self without crashing 1`] = `
<form
className="formDiv"
id="signupForm"
Expand Down
9 changes: 2 additions & 7 deletions client/__test__/components/centerDetails.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {

configure({ adapter: new Adapter() });

describe('Tests for addEvent component', () => {
describe('Tests for centerDetails component', () => {
const props = {
match: {
params: {
Expand All @@ -28,12 +28,7 @@ describe('Tests for addEvent component', () => {
const wrapper = shallow(<CenterDetailsComponent {...props} />);
expect(wrapper).toMatchSnapshot();
});
it('should render call setPage function when comopnent unmounts', () => {
const wrapper = shallow(<CenterDetailsComponent {...props} />);
wrapper.unmount();
expect(props.setPage).toHaveBeenCalled();
});
it('should render call setPage function when comopnent unmounts', () => {
it('should call setPage function when comopnent unmounts', () => {
const wrapper = shallow(<CenterDetailsComponent {...props} />);
wrapper.unmount();
expect(props.setPage).toHaveBeenCalled();
Expand Down
2 changes: 1 addition & 1 deletion client/__test__/components/centerList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CenterList } from '../../src/components/centerListComponent';

configure({ adapter: new Adapter() });

describe('Tests for addEvent component', () => {
describe('Tests for centerList component', () => {
const props = {
centers: [],
match: {},
Expand Down
28 changes: 0 additions & 28 deletions client/__test__/components/centerRouter.test.js

This file was deleted.

2 changes: 1 addition & 1 deletion client/__test__/components/manageDetailsHeader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function setup() {
};
}

describe('Tests for addEvent component', () => {
describe('Tests for manageDetailsHeader component', () => {
it('should render self without crashing', () => {
const { enzymeWrapper } = setup();
expect(enzymeWrapper.length).toBe(1);
Expand Down
2 changes: 1 addition & 1 deletion client/__test__/components/manageEvent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function setup() {
};
}

describe('Tests for addEvent component', () => {
describe('Tests for manageEvent component', () => {
it('should render self without crashing', () => {
const { enzymeWrapper, props } = setup();
expect(enzymeWrapper.length).toBe(1);
Expand Down
2 changes: 1 addition & 1 deletion client/__test__/components/sidebar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {

configure({ adapter: new Adapter() });

describe('Tests for addEvent component', () => {
describe('Tests for sidebar component', () => {
const props = {
match: {},
setProfileDetails: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion client/__test__/components/signin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {

configure({ adapter: new Adapter() });

describe('Tests for addEvent component', () => {
describe('Tests for signin component', () => {
const props = {
history: {},
setSubmitState: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion client/__test__/components/signup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SignupComponent, mapDispatchToProps } from '../../src/components/signup

configure({ adapter: new Adapter() });

describe('Tests for addEvent component', () => {
describe('Tests for signup component', () => {
const props = {
changeState: jest.fn(),
changeSubmitState: jest.fn(),
Expand Down
29 changes: 15 additions & 14 deletions client/src/components/addCenterComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ const inputAttrs = (inputType, inputName, placeholder, className, ref, required,
required,
autocomplete,
});

const mapDispatchToProps = dispatch => ({
setCenterDetails: center => dispatch(setCenterDetails(center)),
setSubmitState: submitState => dispatch(setSubmitState(submitState)),
setCenterDefaults: submitState => dispatch(setCenterDefaults(submitState)),
});
const actionCreators = {
setCenterDetails,
setSubmitState,
setCenterDefaults,
};

const mapStateToProps = state => ({
modalTitle: state.page.modalTitle,
Expand Down Expand Up @@ -121,7 +120,7 @@ export class AddCenterComponent extends React.Component {
'text',
'centername',
'Center Name',
'form-control input-sm',
'form-control input-sm center-name',
input => (this.name = input),
'required'
)}
Expand All @@ -133,7 +132,7 @@ export class AddCenterComponent extends React.Component {
'file',
'centerImage',
'Center Image',
'form-control input-sm',
'form-control input-sm center-image',
input => (this.picture = input),
required
)}
Expand All @@ -145,7 +144,7 @@ export class AddCenterComponent extends React.Component {
'text',
'street',
'Address',
'form-control input-sm',
'form-control input-sm center-address',
input => (this.address = input),
'required',
'street-address'
Expand All @@ -158,7 +157,7 @@ export class AddCenterComponent extends React.Component {
'text',
'city',
'State/City',
'form-control input-sm',
'form-control input-sm center-city',
input => (this.location = input),
'required',
'address-level2'
Expand All @@ -171,7 +170,7 @@ export class AddCenterComponent extends React.Component {
'number',
'capacity',
'Capacity',
'form-control input-sm',
'form-control input-sm center-capacity',
input => (this.capacity = input),
'required'
)}
Expand All @@ -183,7 +182,7 @@ export class AddCenterComponent extends React.Component {
'number',
'bookingAmount',
'Booking price(per day)',
'form-control input-sm',
'form-control input-sm center-price',
input => (this.price = input),
'required'
)}
Expand All @@ -192,14 +191,16 @@ export class AddCenterComponent extends React.Component {
<select
required
ref={input => (this.availability = input)}
className="custom-select-sm"
className="custom-select-sm center-availability"
id="set-availability"
>
<Option value="" text="Availability" disabled selected />
<Option value="open" text="open" />
<Option value="close" text="close" />
</select>
</div>
<ModalFooter
id="add-center-button"
type="submit"
disabled={this.props.disabled}
display={this.props.visibility}
Expand All @@ -213,7 +214,7 @@ export class AddCenterComponent extends React.Component {
);
}
}
export const AddCenter = connect(mapStateToProps, mapDispatchToProps)(AddCenterComponent);
export const AddCenter = connect(mapStateToProps, actionCreators)(AddCenterComponent);
AddCenterComponent.propTypes = {
modalTitle: PropTypes.string,
required: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
Expand Down
Loading

0 comments on commit ddd5204

Please sign in to comment.