2018-07-10 08:11:27 +00:00
|
|
|
import { currentURL } from 'ember-native-dom-helpers';
|
2017-09-19 14:47:10 +00:00
|
|
|
import { test } from 'qunit';
|
|
|
|
import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance';
|
2018-07-10 08:11:27 +00:00
|
|
|
import ClientsList from 'nomad-ui/tests/pages/clients/list';
|
2017-09-19 14:47:10 +00:00
|
|
|
|
|
|
|
function minimumSetup() {
|
|
|
|
server.createList('node', 1);
|
|
|
|
server.createList('agent', 1);
|
|
|
|
}
|
|
|
|
|
2017-10-28 01:23:41 +00:00
|
|
|
moduleForAcceptance('Acceptance | clients list');
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2017-10-28 01:23:41 +00:00
|
|
|
test('/clients should list one page of clients', function(assert) {
|
2017-09-19 14:47:10 +00:00
|
|
|
// Make sure to make more nodes than 1 page to assert that pagination is working
|
|
|
|
const nodesCount = 10;
|
|
|
|
const pageSize = 8;
|
|
|
|
|
|
|
|
server.createList('node', nodesCount);
|
|
|
|
server.createList('agent', 1);
|
|
|
|
|
2018-07-10 08:11:27 +00:00
|
|
|
ClientsList.visit();
|
2017-09-19 14:47:10 +00:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-07-10 08:11:27 +00:00
|
|
|
assert.equal(ClientsList.nodes.length, pageSize);
|
|
|
|
assert.ok(ClientsList.hasPagination, 'Pagination found on the page');
|
2017-09-19 14:47:10 +00:00
|
|
|
|
|
|
|
const sortedNodes = server.db.nodes.sortBy('modifyIndex').reverse();
|
|
|
|
|
2018-07-10 08:11:27 +00:00
|
|
|
ClientsList.nodes.forEach((node, index) => {
|
|
|
|
assert.equal(node.id, sortedNodes[index].id.split('-')[0], 'Clients are ordered');
|
|
|
|
});
|
2017-09-19 14:47:10 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('each client record should show high-level info of the client', function(assert) {
|
|
|
|
minimumSetup();
|
|
|
|
const node = server.db.nodes[0];
|
|
|
|
|
2018-07-10 08:11:27 +00:00
|
|
|
ClientsList.visit();
|
2017-09-19 14:47:10 +00:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-07-10 08:11:27 +00:00
|
|
|
const nodeRow = ClientsList.nodes.objectAt(0);
|
2017-09-19 14:47:10 +00:00
|
|
|
const allocations = server.db.allocations.where({ nodeId: node.id });
|
|
|
|
|
2018-07-10 08:11:27 +00:00
|
|
|
assert.equal(nodeRow.id, node.id.split('-')[0], 'ID');
|
|
|
|
assert.equal(nodeRow.name, node.name, 'Name');
|
|
|
|
assert.equal(nodeRow.status, node.status, 'Status');
|
|
|
|
assert.equal(nodeRow.drain, node.drain + '', 'Draining');
|
|
|
|
assert.equal(nodeRow.eligibility, node.schedulingEligibility, 'Eligibility');
|
|
|
|
assert.equal(nodeRow.address, node.httpAddr);
|
|
|
|
assert.equal(nodeRow.datacenter, node.datacenter, 'Datacenter');
|
|
|
|
assert.equal(nodeRow.allocations, allocations.length, '# Allocations');
|
2017-09-19 14:47:10 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('each client should link to the client detail page', function(assert) {
|
|
|
|
minimumSetup();
|
|
|
|
const node = server.db.nodes[0];
|
|
|
|
|
2018-07-10 08:11:27 +00:00
|
|
|
ClientsList.visit();
|
|
|
|
|
2017-09-26 07:47:16 +00:00
|
|
|
andThen(() => {
|
2018-07-10 08:11:27 +00:00
|
|
|
ClientsList.nodes.objectAt(0).clickRow();
|
2017-09-26 07:47:16 +00:00
|
|
|
});
|
2017-09-19 14:47:10 +00:00
|
|
|
|
|
|
|
andThen(() => {
|
2017-10-28 01:23:41 +00:00
|
|
|
assert.equal(currentURL(), `/clients/${node.id}`);
|
2017-09-19 14:47:10 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-09-30 01:33:57 +00:00
|
|
|
test('when there are no clients, there is an empty message', function(assert) {
|
|
|
|
server.createList('agent', 1);
|
|
|
|
|
2018-07-10 08:11:27 +00:00
|
|
|
ClientsList.visit();
|
2017-09-30 01:33:57 +00:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-07-10 08:11:27 +00:00
|
|
|
assert.ok(ClientsList.isEmpty);
|
|
|
|
assert.equal(ClientsList.empty.headline, 'No Clients');
|
2017-09-30 01:33:57 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-05-30 18:20:59 +00:00
|
|
|
test('when there are clients, but no matches for a search term, there is an empty message', function(assert) {
|
2017-09-30 01:33:57 +00:00
|
|
|
server.createList('agent', 1);
|
|
|
|
server.create('node', { name: 'node' });
|
|
|
|
|
2018-07-10 08:11:27 +00:00
|
|
|
ClientsList.visit();
|
2017-09-30 01:33:57 +00:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-07-10 08:11:27 +00:00
|
|
|
ClientsList.search('client');
|
2017-09-30 01:33:57 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
andThen(() => {
|
2018-07-10 08:11:27 +00:00
|
|
|
assert.ok(ClientsList.isEmpty);
|
|
|
|
assert.equal(ClientsList.empty.headline, 'No Matches');
|
2017-09-30 01:33:57 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-05-30 18:20:59 +00:00
|
|
|
test('when accessing clients is forbidden, show a message with a link to the tokens page', function(assert) {
|
2017-10-24 23:08:01 +00:00
|
|
|
server.create('agent');
|
|
|
|
server.create('node', { name: 'node' });
|
|
|
|
server.pretender.get('/v1/nodes', () => [403, {}, null]);
|
|
|
|
|
2018-07-10 08:11:27 +00:00
|
|
|
ClientsList.visit();
|
2017-10-24 23:08:01 +00:00
|
|
|
|
|
|
|
andThen(() => {
|
2018-07-10 08:11:27 +00:00
|
|
|
assert.equal(ClientsList.error.title, 'Not Authorized');
|
2017-10-24 23:08:01 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
andThen(() => {
|
2018-07-10 08:11:27 +00:00
|
|
|
ClientsList.error.seekHelp();
|
2017-10-24 23:08:01 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(currentURL(), '/settings/tokens');
|
|
|
|
});
|
|
|
|
});
|