mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
Apply the page size select behavior to the other pages with the page size selector
This commit is contained in:
@@ -12,7 +12,7 @@ export default function pageSizeSelect({ resourceName, pageObject, pageObjectLis
|
||||
await setup.call(this);
|
||||
|
||||
assert.equal(pageObjectList.length, storedPageSize);
|
||||
assert.equal(pageObject.pageSizeSelect.selectedOption, '10');
|
||||
assert.equal(pageObject.pageSizeSelect.selectedOption, storedPageSize);
|
||||
});
|
||||
|
||||
test('when the page size user setting is unset, the default page size is 25', async function(assert) {
|
||||
|
||||
@@ -2,23 +2,27 @@ import { currentURL, settled } from '@ember/test-helpers';
|
||||
import { module, test } from 'qunit';
|
||||
import { setupApplicationTest } from 'ember-qunit';
|
||||
import { setupMirage } from 'ember-cli-mirage/test-support';
|
||||
import pageSizeSelect from './behaviors/page-size-select';
|
||||
import ClientsList from 'nomad-ui/tests/pages/clients/list';
|
||||
|
||||
module('Acceptance | clients list', function(hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
hooks.beforeEach(function() {
|
||||
window.localStorage.clear();
|
||||
});
|
||||
|
||||
test('/clients should list one page of clients', async function(assert) {
|
||||
// Make sure to make more nodes than 1 page to assert that pagination is working
|
||||
const nodesCount = 10;
|
||||
const pageSize = 8;
|
||||
const nodesCount = ClientsList.pageSize + 1;
|
||||
|
||||
server.createList('node', nodesCount);
|
||||
server.createList('agent', 1);
|
||||
|
||||
await ClientsList.visit();
|
||||
|
||||
assert.equal(ClientsList.nodes.length, pageSize);
|
||||
assert.equal(ClientsList.nodes.length, ClientsList.pageSize);
|
||||
assert.ok(ClientsList.hasPagination, 'Pagination found on the page');
|
||||
|
||||
const sortedNodes = server.db.nodes.sortBy('modifyIndex').reverse();
|
||||
@@ -174,6 +178,17 @@ module('Acceptance | clients list', function(hooks) {
|
||||
assert.equal(currentURL(), '/settings/tokens');
|
||||
});
|
||||
|
||||
pageSizeSelect({
|
||||
resourceName: 'client',
|
||||
pageObject: ClientsList,
|
||||
pageObjectList: ClientsList.nodes,
|
||||
async setup() {
|
||||
server.createList('node', ClientsList.pageSize);
|
||||
server.createList('agent', 1);
|
||||
await ClientsList.visit();
|
||||
},
|
||||
});
|
||||
|
||||
testFacet('Class', {
|
||||
facet: ClientsList.facets.class,
|
||||
paramName: 'class',
|
||||
|
||||
@@ -4,7 +4,7 @@ import { setupApplicationTest } from 'ember-qunit';
|
||||
import { setupMirage } from 'ember-cli-mirage/test-support';
|
||||
import { formatBytes } from 'nomad-ui/helpers/format-bytes';
|
||||
import TaskGroup from 'nomad-ui/tests/pages/jobs/job/task-group';
|
||||
import JobsList from 'nomad-ui/tests/pages/jobs/list';
|
||||
import pageSizeSelect from './behaviors/page-size-select';
|
||||
import moment from 'moment';
|
||||
|
||||
let job;
|
||||
@@ -61,7 +61,7 @@ module('Acceptance | task group detail', function(hooks) {
|
||||
previousAllocation: allocations[0].id,
|
||||
});
|
||||
|
||||
await TaskGroup.visit({ id: job.id, name: taskGroup.name });
|
||||
window.localStorage.clear();
|
||||
});
|
||||
|
||||
test('/jobs/:id/:task-group should list high-level metrics for the allocation', async function(assert) {
|
||||
@@ -69,6 +69,8 @@ module('Acceptance | task group detail', function(hooks) {
|
||||
const totalMemory = tasks.mapBy('Resources.MemoryMB').reduce(sum, 0);
|
||||
const totalDisk = taskGroup.ephemeralDisk.SizeMB;
|
||||
|
||||
await TaskGroup.visit({ id: job.id, name: taskGroup.name });
|
||||
|
||||
assert.equal(TaskGroup.tasksCount, `# Tasks ${tasks.length}`, '# Tasks');
|
||||
assert.equal(
|
||||
TaskGroup.cpu,
|
||||
@@ -90,6 +92,8 @@ module('Acceptance | task group detail', function(hooks) {
|
||||
});
|
||||
|
||||
test('/jobs/:id/:task-group should have breadcrumbs for job and jobs', async function(assert) {
|
||||
await TaskGroup.visit({ id: job.id, name: taskGroup.name });
|
||||
|
||||
assert.equal(TaskGroup.breadcrumbFor('jobs.index').text, 'Jobs', 'First breadcrumb says jobs');
|
||||
assert.equal(
|
||||
TaskGroup.breadcrumbFor('jobs.job.index').text,
|
||||
@@ -104,11 +108,15 @@ module('Acceptance | task group detail', function(hooks) {
|
||||
});
|
||||
|
||||
test('/jobs/:id/:task-group first breadcrumb should link to jobs', async function(assert) {
|
||||
await TaskGroup.visit({ id: job.id, name: taskGroup.name });
|
||||
|
||||
await TaskGroup.breadcrumbFor('jobs.index').visit();
|
||||
assert.equal(currentURL(), '/jobs', 'First breadcrumb links back to jobs');
|
||||
});
|
||||
|
||||
test('/jobs/:id/:task-group second breadcrumb should link to the job for the task group', async function(assert) {
|
||||
await TaskGroup.visit({ id: job.id, name: taskGroup.name });
|
||||
|
||||
await TaskGroup.breadcrumbFor('jobs.job.index').visit();
|
||||
assert.equal(
|
||||
currentURL(),
|
||||
@@ -124,7 +132,6 @@ module('Acceptance | task group detail', function(hooks) {
|
||||
clientStatus: 'running',
|
||||
});
|
||||
|
||||
await JobsList.visit();
|
||||
await TaskGroup.visit({ id: job.id, name: taskGroup.name });
|
||||
|
||||
assert.ok(
|
||||
@@ -140,6 +147,8 @@ module('Acceptance | task group detail', function(hooks) {
|
||||
});
|
||||
|
||||
test('each allocation should show basic information about the allocation', async function(assert) {
|
||||
await TaskGroup.visit({ id: job.id, name: taskGroup.name });
|
||||
|
||||
const allocation = allocations.sortBy('modifyIndex').reverse()[0];
|
||||
const allocationRow = TaskGroup.allocations.objectAt(0);
|
||||
|
||||
@@ -173,6 +182,8 @@ module('Acceptance | task group detail', function(hooks) {
|
||||
});
|
||||
|
||||
test('each allocation should show stats about the allocation', async function(assert) {
|
||||
await TaskGroup.visit({ id: job.id, name: taskGroup.name });
|
||||
|
||||
const allocation = allocations.sortBy('name')[0];
|
||||
const allocationRow = TaskGroup.allocations.objectAt(0);
|
||||
|
||||
@@ -208,6 +219,8 @@ module('Acceptance | task group detail', function(hooks) {
|
||||
});
|
||||
|
||||
test('when the allocation search has no matches, there is an empty message', async function(assert) {
|
||||
await TaskGroup.visit({ id: job.id, name: taskGroup.name });
|
||||
|
||||
await TaskGroup.search('zzzzzz');
|
||||
|
||||
assert.ok(TaskGroup.isEmpty, 'Empty state is shown');
|
||||
@@ -219,6 +232,8 @@ module('Acceptance | task group detail', function(hooks) {
|
||||
});
|
||||
|
||||
test('when the allocation has reschedule events, the allocation row is denoted with an icon', async function(assert) {
|
||||
await TaskGroup.visit({ id: job.id, name: taskGroup.name });
|
||||
|
||||
const rescheduleRow = TaskGroup.allocationFor(allocations[0].id);
|
||||
const normalRow = TaskGroup.allocationFor(allocations[1].id);
|
||||
|
||||
@@ -227,6 +242,8 @@ module('Acceptance | task group detail', function(hooks) {
|
||||
});
|
||||
|
||||
test('when the task group depends on volumes, the volumes table is shown', async function(assert) {
|
||||
await TaskGroup.visit({ id: job.id, name: taskGroup.name });
|
||||
|
||||
assert.ok(TaskGroup.hasVolumes);
|
||||
assert.equal(TaskGroup.volumes.length, Object.keys(taskGroup.volumes).length);
|
||||
});
|
||||
@@ -241,6 +258,8 @@ module('Acceptance | task group detail', function(hooks) {
|
||||
});
|
||||
|
||||
test('each row in the volumes table lists information about the volume', async function(assert) {
|
||||
await TaskGroup.visit({ id: job.id, name: taskGroup.name });
|
||||
|
||||
TaskGroup.volumes[0].as(volumeRow => {
|
||||
const volume = taskGroup.volumes[volumeRow.name];
|
||||
assert.equal(volumeRow.name, volume.Name);
|
||||
@@ -279,4 +298,19 @@ module('Acceptance | task group detail', function(hooks) {
|
||||
assert.ok(TaskGroup.error.isPresent, 'Error message is shown');
|
||||
assert.equal(TaskGroup.error.title, 'Not Found', 'Error message is for 404');
|
||||
});
|
||||
|
||||
pageSizeSelect({
|
||||
resourceName: 'allocation',
|
||||
pageObject: TaskGroup,
|
||||
pageObjectList: TaskGroup.allocations,
|
||||
async setup() {
|
||||
server.createList('allocation', TaskGroup.pageSize, {
|
||||
jobId: job.id,
|
||||
taskGroup: taskGroup.name,
|
||||
clientStatus: 'running',
|
||||
});
|
||||
|
||||
await TaskGroup.visit({ id: job.id, name: taskGroup.name });
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,6 +14,8 @@ import {
|
||||
import facet from 'nomad-ui/tests/pages/components/facet';
|
||||
|
||||
export default create({
|
||||
pageSize: 25,
|
||||
|
||||
visit: visitable('/clients'),
|
||||
|
||||
search: fillable('.search-box input'),
|
||||
@@ -59,6 +61,17 @@ export default create({
|
||||
headline: text('[data-test-empty-clients-list-headline]'),
|
||||
},
|
||||
|
||||
pageSizeSelect: {
|
||||
isPresent: isPresent('[data-test-page-size-select]'),
|
||||
open: clickable('[data-test-page-size-select] .ember-power-select-trigger'),
|
||||
selectedOption: text('[data-test-page-size-select] .ember-power-select-selected-item'),
|
||||
options: collection('.ember-power-select-option', {
|
||||
testContainer: '#ember-testing',
|
||||
resetScope: true,
|
||||
label: text(),
|
||||
}),
|
||||
},
|
||||
|
||||
error: {
|
||||
isPresent: isPresent('[data-test-error]'),
|
||||
title: text('[data-test-error-title]'),
|
||||
|
||||
@@ -13,7 +13,7 @@ import allocations from 'nomad-ui/tests/pages/components/allocations';
|
||||
import error from 'nomad-ui/tests/pages/components/error';
|
||||
|
||||
export default create({
|
||||
pageSize: 10,
|
||||
pageSize: 25,
|
||||
|
||||
visit: visitable('/jobs/:id/:name'),
|
||||
|
||||
@@ -51,4 +51,15 @@ export default create({
|
||||
emptyState: {
|
||||
headline: text('[data-test-empty-allocations-list-headline]'),
|
||||
},
|
||||
|
||||
pageSizeSelect: {
|
||||
isPresent: isPresent('[data-test-page-size-select]'),
|
||||
open: clickable('[data-test-page-size-select] .ember-power-select-trigger'),
|
||||
selectedOption: text('[data-test-page-size-select] .ember-power-select-selected-item'),
|
||||
options: collection('.ember-power-select-option', {
|
||||
testContainer: '#ember-testing',
|
||||
resetScope: true,
|
||||
label: text(),
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user