Skip to content

Commit

Permalink
Move breadcrumbs objects into shared layout object (#9576)
Browse files Browse the repository at this point in the history
Various page objects had breadcrumbs and breadcrumbFor within them, this
moves those to the existing Layout page object that contains shared page objects.
  • Loading branch information
backspace authored Dec 10, 2020
1 parent 7af6669 commit 2211ec7
Show file tree
Hide file tree
Showing 19 changed files with 127 additions and 205 deletions.
7 changes: 4 additions & 3 deletions ui/tests/acceptance/client-detail-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import moment from 'moment';
import ClientDetail from 'nomad-ui/tests/pages/clients/detail';
import Clients from 'nomad-ui/tests/pages/clients/list';
import Jobs from 'nomad-ui/tests/pages/jobs/list';
import Layout from 'nomad-ui/tests/pages/layout';

let node;
let managementToken;
Expand Down Expand Up @@ -53,16 +54,16 @@ module('Acceptance | client detail', function(hooks) {
assert.equal(document.title, `Client ${node.name} - Nomad`);

assert.equal(
ClientDetail.breadcrumbFor('clients.index').text,
Layout.breadcrumbFor('clients.index').text,
'Clients',
'First breadcrumb says clients'
);
assert.equal(
ClientDetail.breadcrumbFor('clients.client').text,
Layout.breadcrumbFor('clients.client').text,
node.id.split('-')[0],
'Second breadcrumb says the node short id'
);
await ClientDetail.breadcrumbFor('clients.index').visit();
await Layout.breadcrumbFor('clients.index').visit();
assert.equal(currentURL(), '/clients', 'First breadcrumb links back to clients');
});

Expand Down
7 changes: 4 additions & 3 deletions ui/tests/acceptance/client-monitor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import ClientMonitor from 'nomad-ui/tests/pages/clients/monitor';
import Layout from 'nomad-ui/tests/pages/layout';

let node;
let managementToken;
Expand Down Expand Up @@ -34,10 +35,10 @@ module('Acceptance | client monitor', function(hooks) {
test('/clients/:id/monitor should have a breadcrumb trail linking back to clients', async function(assert) {
await ClientMonitor.visit({ id: node.id });

assert.equal(ClientMonitor.breadcrumbFor('clients.index').text, 'Clients');
assert.equal(ClientMonitor.breadcrumbFor('clients.client').text, node.id.split('-')[0]);
assert.equal(Layout.breadcrumbFor('clients.index').text, 'Clients');
assert.equal(Layout.breadcrumbFor('clients.client').text, node.id.split('-')[0]);

await ClientMonitor.breadcrumbFor('clients.index').visit();
await Layout.breadcrumbFor('clients.index').visit();
assert.equal(currentURL(), '/clients');
});

Expand Down
8 changes: 4 additions & 4 deletions ui/tests/acceptance/optimize-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Response from 'ember-cli-mirage/response';
import moment from 'moment';

import Optimize from 'nomad-ui/tests/pages/optimize';
import PageLayout from 'nomad-ui/tests/pages/layout';
import Layout from 'nomad-ui/tests/pages/layout';
import JobsList from 'nomad-ui/tests/pages/jobs/list';

let managementToken, clientToken;
Expand Down Expand Up @@ -68,15 +68,15 @@ module('Acceptance | optimize', function(hooks) {
const currentTaskGroup = this.job1.taskGroups.models[0];
const nextTaskGroup = this.job2.taskGroups.models[0];

assert.equal(Optimize.breadcrumbFor('optimize').text, 'Recommendations');
assert.equal(Layout.breadcrumbFor('optimize').text, 'Recommendations');

assert.equal(
Optimize.recommendationSummaries[0].slug,
`${this.job1.name} / ${currentTaskGroup.name}`
);

assert.equal(
Optimize.breadcrumbFor('optimize.summary').text,
Layout.breadcrumbFor('optimize.summary').text,
`${this.job1.name} / ${currentTaskGroup.name}`
);

Expand Down Expand Up @@ -342,7 +342,7 @@ module('Acceptance | optimize', function(hooks) {
await Optimize.visit();

assert.equal(currentURL(), '/jobs');
assert.ok(PageLayout.gutter.optimize.isHidden);
assert.ok(Layout.gutter.optimize.isHidden);
});

test('it reloads partially-loaded jobs', async function(assert) {
Expand Down
7 changes: 4 additions & 3 deletions ui/tests/acceptance/plugin-detail-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import moment from 'moment';
import { formatBytes } from 'nomad-ui/helpers/format-bytes';
import PluginDetail from 'nomad-ui/tests/pages/storage/plugins/detail';
import Layout from 'nomad-ui/tests/pages/layout';

module('Acceptance | plugin detail', function(hooks) {
setupApplicationTest(hooks);
Expand All @@ -26,9 +27,9 @@ module('Acceptance | plugin detail', function(hooks) {
test('/csi/plugins/:id should have a breadcrumb trail linking back to Plugins and Storage', async function(assert) {
await PluginDetail.visit({ id: plugin.id });

assert.equal(PluginDetail.breadcrumbFor('csi.index').text, 'Storage');
assert.equal(PluginDetail.breadcrumbFor('csi.plugins').text, 'Plugins');
assert.equal(PluginDetail.breadcrumbFor('csi.plugins.plugin').text, plugin.id);
assert.equal(Layout.breadcrumbFor('csi.index').text, 'Storage');
assert.equal(Layout.breadcrumbFor('csi.plugins').text, 'Plugins');
assert.equal(Layout.breadcrumbFor('csi.plugins.plugin').text, plugin.id);
});

test('/csi/plugins/:id should show the plugin name in the title', async function(assert) {
Expand Down
22 changes: 12 additions & 10 deletions ui/tests/acceptance/regions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import JobsList from 'nomad-ui/tests/pages/jobs/list';
import ClientsList from 'nomad-ui/tests/pages/clients/list';
import PageLayout from 'nomad-ui/tests/pages/layout';
import Layout from 'nomad-ui/tests/pages/layout';
import Allocation from 'nomad-ui/tests/pages/allocations/detail';

module('Acceptance | regions (only one)', function(hooks) {
Expand All @@ -29,7 +29,7 @@ module('Acceptance | regions (only one)', function(hooks) {

await JobsList.visit();

assert.notOk(PageLayout.navbar.regionSwitcher.isPresent, 'No region switcher');
assert.notOk(Layout.navbar.regionSwitcher.isPresent, 'No region switcher');
assert.equal(document.title, 'Jobs - Nomad');
});

Expand All @@ -38,7 +38,7 @@ module('Acceptance | regions (only one)', function(hooks) {

await JobsList.visit();

assert.notOk(PageLayout.navbar.regionSwitcher.isPresent, 'No region switcher');
assert.notOk(Layout.navbar.regionSwitcher.isPresent, 'No region switcher');
});

test('pages do not include the region query param', async function(assert) {
Expand All @@ -60,8 +60,8 @@ module('Acceptance | regions (only one)', function(hooks) {

await JobsList.visit();
await JobsList.jobs.objectAt(0).clickRow();
await PageLayout.gutter.visitClients();
await PageLayout.gutter.visitServers();
await Layout.gutter.visitClients();
await Layout.gutter.visitServers();
server.pretender.handledRequests.forEach(req => {
assert.notOk(req.url.includes('region='), req.url);
});
Expand All @@ -84,7 +84,7 @@ module('Acceptance | regions (many)', function(hooks) {
test('the region switcher is rendered in the nav bar and the region is in the page title', async function(assert) {
await JobsList.visit();

assert.ok(PageLayout.navbar.regionSwitcher.isPresent, 'Region switcher is shown');
assert.ok(Layout.navbar.regionSwitcher.isPresent, 'Region switcher is shown');
assert.equal(document.title, 'Jobs - global - Nomad');
});

Expand Down Expand Up @@ -159,11 +159,13 @@ module('Acceptance | regions (many)', function(hooks) {
await JobsList.visit({ region });

await JobsList.jobs.objectAt(0).clickRow();
await PageLayout.gutter.visitClients();
await PageLayout.gutter.visitServers();
await Layout.gutter.visitClients();
await Layout.gutter.visitServers();
const [
, // License request
, // Token/policies request
,
,
// License request
// Token/policies request
regionsRequest,
defaultRegionRequest,
...appRequests
Expand Down
54 changes: 28 additions & 26 deletions ui/tests/acceptance/search-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { module, test } from 'qunit';
import { currentURL, triggerEvent, visit } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import PageLayout from 'nomad-ui/tests/pages/layout';
import Layout from 'nomad-ui/tests/pages/layout';
import JobsList from 'nomad-ui/tests/pages/jobs/list';
import { selectSearch } from 'ember-power-select/test-support';
import sinon from 'sinon';
Expand Down Expand Up @@ -36,9 +36,9 @@ module('Acceptance | search', function(hooks) {
let presearchJobsRequestCount = getRequestCount(server, '/v1/jobs');
let presearchNodesRequestCount = getRequestCount(server, '/v1/nodes');

await selectSearch(PageLayout.navbar.search.scope, 'xy');
await selectSearch(Layout.navbar.search.scope, 'xy');

PageLayout.navbar.search.as(search => {
Layout.navbar.search.as(search => {
assert.equal(search.groups.length, 2);

search.groups[0].as(jobs => {
Expand Down Expand Up @@ -66,18 +66,18 @@ module('Acceptance | search', function(hooks) {
'a nodes request should happen when not in the clients hierarchy'
);

await PageLayout.navbar.search.groups[0].options[0].click();
await Layout.navbar.search.groups[0].options[0].click();
assert.equal(currentURL(), '/jobs/xyz');

await selectSearch(PageLayout.navbar.search.scope, otherNode.id.substr(0, 3));
await selectSearch(Layout.navbar.search.scope, otherNode.id.substr(0, 3));

await PageLayout.navbar.search.groups[1].options[0].click();
await Layout.navbar.search.groups[1].options[0].click();
assert.equal(currentURL(), `/clients/${otherNode.id}`);

presearchJobsRequestCount = getRequestCount(server, '/v1/jobs');
presearchNodesRequestCount = getRequestCount(server, '/v1/nodes');

await selectSearch(PageLayout.navbar.search.scope, 'zzzzzzzzzzz');
await selectSearch(Layout.navbar.search.scope, 'zzzzzzzzzzz');

assert.equal(
getRequestCount(server, '/v1/jobs'),
Expand All @@ -92,7 +92,7 @@ module('Acceptance | search', function(hooks) {

clock.tick(COLLECTION_CACHE_DURATION * 2);

await selectSearch(PageLayout.navbar.search.scope, otherNode.id.substr(0, 3));
await selectSearch(Layout.navbar.search.scope, otherNode.id.substr(0, 3));

assert.equal(
getRequestCount(server, '/v1/jobs'),
Expand All @@ -112,9 +112,9 @@ module('Acceptance | search', function(hooks) {

await visit('/');

await selectSearch(PageLayout.navbar.search.scope, 'trae');
await selectSearch(Layout.navbar.search.scope, 'trae');

PageLayout.navbar.search.as(search => {
Layout.navbar.search.as(search => {
search.groups[0].as(jobs => {
assert.equal(jobs.options[0].text, 'traefik');
assert.equal(jobs.options[0].formattedText, '*trae*fik');
Expand All @@ -124,18 +124,18 @@ module('Acceptance | search', function(hooks) {
});
});

await selectSearch(PageLayout.navbar.search.scope, 'ra');
await selectSearch(Layout.navbar.search.scope, 'ra');

PageLayout.navbar.search.as(search => {
Layout.navbar.search.as(search => {
search.groups[0].as(jobs => {
assert.equal(jobs.options[0].formattedText, 't*ra*efik');
assert.equal(jobs.options[1].formattedText, 't*ra*cking');
});
});

await selectSearch(PageLayout.navbar.search.scope, 'sensor');
await selectSearch(Layout.navbar.search.scope, 'sensor');

PageLayout.navbar.search.as(search => {
Layout.navbar.search.as(search => {
search.groups[0].as(jobs => {
assert.equal(jobs.options[0].formattedText, '*s*mtp-*sensor*');
});
Expand All @@ -151,9 +151,9 @@ module('Acceptance | search', function(hooks) {

await visit('/');

await selectSearch(PageLayout.navbar.search.scope, 'job');
await selectSearch(Layout.navbar.search.scope, 'job');

PageLayout.navbar.search.as(search => {
Layout.navbar.search.as(search => {
search.groups[0].as(jobs => {
assert.equal(jobs.name, 'Jobs (showing 10 of 15)');
assert.equal(jobs.options.length, 10);
Expand All @@ -166,13 +166,15 @@ module('Acceptance | search', function(hooks) {

const idPrefix = nodeToMatchById.id.substr(0, 5);

const nodeToMatchByName = server.create('node', { name: `node-name-with-id-piece-${idPrefix}`});
const nodeToMatchByName = server.create('node', {
name: `node-name-with-id-piece-${idPrefix}`,
});

await visit('/');

await selectSearch(PageLayout.navbar.search.scope, idPrefix);
await selectSearch(Layout.navbar.search.scope, idPrefix);

PageLayout.navbar.search.as(search => {
Layout.navbar.search.as(search => {
search.groups[1].as(clients => {
assert.equal(clients.options[0].text, nodeToMatchById.name);
assert.equal(clients.options[1].text, nodeToMatchByName.name);
Expand All @@ -183,23 +185,23 @@ module('Acceptance | search', function(hooks) {
test('clicking the search field starts search immediately', async function(assert) {
await visit('/');

assert.notOk(PageLayout.navbar.search.field.isPresent);
assert.notOk(Layout.navbar.search.field.isPresent);

await PageLayout.navbar.search.click();
await Layout.navbar.search.click();

assert.ok(PageLayout.navbar.search.field.isPresent);
assert.ok(Layout.navbar.search.field.isPresent);
});

test('pressing slash starts a search', async function(assert) {
await visit('/');

assert.notOk(PageLayout.navbar.search.field.isPresent);
assert.notOk(Layout.navbar.search.field.isPresent);

await triggerEvent('.page-layout', 'keydown', {
keyCode: 191, // slash
});

assert.ok(PageLayout.navbar.search.field.isPresent);
assert.ok(Layout.navbar.search.field.isPresent);
});

test('pressing slash when an input element is focused does not start a search', async function(assert) {
Expand All @@ -208,11 +210,11 @@ module('Acceptance | search', function(hooks) {

await visit('/');

assert.notOk(PageLayout.navbar.search.field.isPresent);
assert.notOk(Layout.navbar.search.field.isPresent);

await JobsList.search.click();
await JobsList.search.keydown({ keyCode: 191 });

assert.notOk(PageLayout.navbar.search.field.isPresent);
assert.notOk(Layout.navbar.search.field.isPresent);
});
});
7 changes: 4 additions & 3 deletions ui/tests/acceptance/server-monitor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import ServerMonitor from 'nomad-ui/tests/pages/servers/monitor';
import Layout from 'nomad-ui/tests/pages/layout';

let agent;
let managementToken;
Expand Down Expand Up @@ -33,10 +34,10 @@ module('Acceptance | server monitor', function(hooks) {
test('/servers/:id/monitor should have a breadcrumb trail linking back to servers', async function(assert) {
await ServerMonitor.visit({ name: agent.name });

assert.equal(ServerMonitor.breadcrumbFor('servers.index').text, 'Servers');
assert.equal(ServerMonitor.breadcrumbFor('servers.server').text, agent.name);
assert.equal(Layout.breadcrumbFor('servers.index').text, 'Servers');
assert.equal(Layout.breadcrumbFor('servers.server').text, agent.name);

await ServerMonitor.breadcrumbFor('servers.index').visit();
await Layout.breadcrumbFor('servers.index').visit();
assert.equal(currentURL(), '/servers');
});

Expand Down
Loading

0 comments on commit 2211ec7

Please sign in to comment.