Set up preliminary tests for users
This commit is contained in:
parent
a47f233493
commit
2d7d22f847
5 changed files with 88 additions and 8 deletions
|
@ -10,7 +10,10 @@ export function testConfig() {
|
||||||
this.namespace = '/api/hymenobacter';
|
this.namespace = '/api/hymenobacter';
|
||||||
this.timing = 0;
|
this.timing = 0;
|
||||||
|
|
||||||
|
this.get('/users');
|
||||||
|
this.post('/users');
|
||||||
this.get('/users/:id');
|
this.get('/users/:id');
|
||||||
|
this.put('/users/:id');
|
||||||
|
|
||||||
this.get('/species');
|
this.get('/species');
|
||||||
this.post('/species');
|
this.post('/species');
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<h2>{{genus-name}} Users</h2>
|
<h2>{{genus-name}} Users</h2>
|
||||||
<h3>Total users: {{model.length}}</h3>
|
<h3 id="total-users">Total users: {{model.length}}</h3>
|
||||||
|
|
||||||
<table class="flakes-table">
|
<table class="flakes-table">
|
||||||
<thead>
|
<thead>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<div data-row-span="1">
|
<div data-row-span="1">
|
||||||
<div data-field-span="1">
|
<div data-field-span="1">
|
||||||
<label>Name</label>
|
<label>Name</label>
|
||||||
{{input value=user.name}}
|
{{input value=user.name class="user-name"}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div data-row-span="1">
|
<div data-row-span="1">
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
Cancel
|
Cancel
|
||||||
</a>
|
</a>
|
||||||
{{#if user.hasDirtyAttributes}}
|
{{#if user.hasDirtyAttributes}}
|
||||||
<button type="submit" class="button-green smaller">
|
<button type="submit" class="button-green smaller save-user">
|
||||||
Save
|
Save
|
||||||
</button>
|
</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -6,22 +6,22 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<label>Name</label>
|
<label>Name</label>
|
||||||
{{input value=user.name}}
|
{{input value=user.name class="user-name"}}
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<label>Email</label>
|
<label>Email</label>
|
||||||
{{input value=user.email}}
|
{{input value=user.email class="email"}}
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<label>Password</label>
|
<label>Password</label>
|
||||||
{{input type="password" value=user.password}}
|
{{input type="password" value=user.password class="password"}}
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<label>Password (confirm)</label>
|
<label>Password (confirm)</label>
|
||||||
{{input type="password" value=passwordConfirm}}
|
{{input type="password" value=passwordConfirm class="password-verify"}}
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<button type="submit" class="button-green smaller">
|
<button type="submit" class="button-green smaller save-user">
|
||||||
Submit
|
Submit
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
|
77
tests/acceptance/users-test.js
Normal file
77
tests/acceptance/users-test.js
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
import Ember from 'ember';
|
||||||
|
import { module, test } from 'qunit';
|
||||||
|
import startApp from '../helpers/start-app';
|
||||||
|
import { invalidateSession, authenticateSession } from '../helpers/ember-simple-auth';
|
||||||
|
|
||||||
|
module('Acceptance | users', {
|
||||||
|
beforeEach: function() {
|
||||||
|
this.application = startApp();
|
||||||
|
authenticateSession(this.application, {
|
||||||
|
access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiYWN0ZGIiLCJzdWIiOiIxIiwiZXhwIjoxNDQ2NTAyMjI2LCJpYXQiOjE0NDY0OTg2MjZ9.vIjKHAsp2TkCV505EbtCo2xQT-2oQkB-Nv5y0b6E7Mg"
|
||||||
|
});
|
||||||
|
server.create('users', { role: 'A', canEdit: true });
|
||||||
|
},
|
||||||
|
|
||||||
|
afterEach: function() {
|
||||||
|
Ember.run(this.application, 'destroy');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('visiting /users', function(assert) {
|
||||||
|
const users = server.createList('users', 19); // We already created one user in beforeEach
|
||||||
|
visit('/users');
|
||||||
|
|
||||||
|
andThen(function() {
|
||||||
|
assert.equal(currentURL(), '/users');
|
||||||
|
assert.equal(find(".flakes-table > tbody > tr").length, users.length + 1);
|
||||||
|
assert.equal(find("#total-users").text(), "Total users: 20");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
test('visiting /users/:id', function(assert) {
|
||||||
|
const user = server.create('users');
|
||||||
|
visit(`/users/${user.id}`);
|
||||||
|
|
||||||
|
andThen(function() {
|
||||||
|
assert.equal(currentURL(), `/users/${user.id}`);
|
||||||
|
assert.equal(find(".flakes-information-box > legend").text().trim(), user.name);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('editing /users/:id/edit', function(assert) {
|
||||||
|
const user = server.create('users', { 'canEdit': true });
|
||||||
|
visit(`/users/${user.id}/edit`);
|
||||||
|
|
||||||
|
andThen(function() {
|
||||||
|
assert.equal(currentURL(), `/users/${user.id}/edit`);
|
||||||
|
|
||||||
|
fillIn('.user-name', 'Revised User Name');
|
||||||
|
click('.save-user');
|
||||||
|
|
||||||
|
andThen(function() {
|
||||||
|
assert.equal(currentURL(), `/users/${user.id}`);
|
||||||
|
assert.equal(find(".flakes-information-box > legend").text().trim(), 'Revised User Name');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('creating /users/new', function(assert) {
|
||||||
|
invalidateSession(this.application);
|
||||||
|
visit(`/users/new`);
|
||||||
|
|
||||||
|
andThen(function() {
|
||||||
|
assert.equal(currentURL(), `/users/new`);
|
||||||
|
fillIn('.user-name', 'New User Name');
|
||||||
|
fillIn('.email', 'example@example.com');
|
||||||
|
fillIn('.password', 'Password1');
|
||||||
|
fillIn('.password-verify', 'Password1');
|
||||||
|
click('.save-user');
|
||||||
|
|
||||||
|
andThen(function() {
|
||||||
|
assert.equal(currentURL(), `/login`);
|
||||||
|
assert.equal(find(".flakes-message").text().trim(), `✖ You have successfully signed up.
|
||||||
|
Please check your email for further instructions.`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Reference in a new issue