From 30f97e93fc545877e817eea16712dd5a85273f63 Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Wed, 24 Jun 2020 17:42:09 -0400 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20Add=20breadcrumbs=20to?= =?UTF-8?q?=20groups=20pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add missing role breadcrumb tests --- ui/core/app/controllers/orgs/org/groups.js | 17 +++++ .../app/controllers/orgs/org/groups/group.js | 12 +++ .../app/controllers/orgs/org/groups/new.js | 18 +++++ .../templates/orgs/org/groups/group/index.hbs | 4 + .../app/templates/orgs/org/groups/index.hbs | 4 + ui/core/app/templates/orgs/org/groups/new.hbs | 5 ++ ui/core/tests/acceptance/bread-crumbs-test.js | 73 ++++++++++++++++--- .../unit/controllers/orgs/org/groups-test.js | 12 +++ .../controllers/orgs/org/groups/group-test.js | 12 +++ .../controllers/orgs/org/groups/new-test.js | 12 +++ 10 files changed, 158 insertions(+), 11 deletions(-) create mode 100644 ui/core/app/controllers/orgs/org/groups.js create mode 100644 ui/core/app/controllers/orgs/org/groups/group.js create mode 100644 ui/core/app/controllers/orgs/org/groups/new.js create mode 100644 ui/core/tests/unit/controllers/orgs/org/groups-test.js create mode 100644 ui/core/tests/unit/controllers/orgs/org/groups/group-test.js create mode 100644 ui/core/tests/unit/controllers/orgs/org/groups/new-test.js diff --git a/ui/core/app/controllers/orgs/org/groups.js b/ui/core/app/controllers/orgs/org/groups.js new file mode 100644 index 000000000..b6c1716e9 --- /dev/null +++ b/ui/core/app/controllers/orgs/org/groups.js @@ -0,0 +1,17 @@ +import Controller from '@ember/controller'; +import { inject as service } from '@ember/service'; + +export default class OrgsOrgGroupsController extends Controller { + // =services + + @service intl; + + // =attributes + + /** + * @type {string} + */ + get breadCrumb() { + return this.intl.t('resources.groups'); + } +} diff --git a/ui/core/app/controllers/orgs/org/groups/group.js b/ui/core/app/controllers/orgs/org/groups/group.js new file mode 100644 index 000000000..60ed4c93c --- /dev/null +++ b/ui/core/app/controllers/orgs/org/groups/group.js @@ -0,0 +1,12 @@ +import Controller from '@ember/controller'; +import { alias } from '@ember/object/computed'; + +export default class OrgsOrgGroupsGroupController extends Controller { + // =attributes + + /** + * @type {string} + */ + @alias('model.name') breadCrumb; + +} diff --git a/ui/core/app/controllers/orgs/org/groups/new.js b/ui/core/app/controllers/orgs/org/groups/new.js new file mode 100644 index 000000000..9ca97fbe5 --- /dev/null +++ b/ui/core/app/controllers/orgs/org/groups/new.js @@ -0,0 +1,18 @@ +import Controller from '@ember/controller'; +import { inject as service } from '@ember/service'; + +export default class OrgsOrgGroupsNewController extends Controller { + // =services + + @service intl; + + // =attributes + + /** + * @type {string} + */ + get breadCrumb() { + return this.intl.t('titles.new'); + } + +} diff --git a/ui/core/app/templates/orgs/org/groups/group/index.hbs b/ui/core/app/templates/orgs/org/groups/group/index.hbs index 71b756e0c..576796dae 100644 --- a/ui/core/app/templates/orgs/org/groups/group/index.hbs +++ b/ui/core/app/templates/orgs/org/groups/group/index.hbs @@ -1,5 +1,9 @@ + + + +

{{t "resources.group"}}

diff --git a/ui/core/app/templates/orgs/org/groups/index.hbs b/ui/core/app/templates/orgs/org/groups/index.hbs index c56fcb134..cf02056b2 100644 --- a/ui/core/app/templates/orgs/org/groups/index.hbs +++ b/ui/core/app/templates/orgs/org/groups/index.hbs @@ -1,5 +1,9 @@ + + + +

{{t "resources.groups"}}

diff --git a/ui/core/app/templates/orgs/org/groups/new.hbs b/ui/core/app/templates/orgs/org/groups/new.hbs index d2b85b3a2..64602883c 100644 --- a/ui/core/app/templates/orgs/org/groups/new.hbs +++ b/ui/core/app/templates/orgs/org/groups/new.hbs @@ -1,4 +1,9 @@ + + + + +

{{t "titles.new"}}

diff --git a/ui/core/tests/acceptance/bread-crumbs-test.js b/ui/core/tests/acceptance/bread-crumbs-test.js index 2b134ae0a..fdce9f1c8 100644 --- a/ui/core/tests/acceptance/bread-crumbs-test.js +++ b/ui/core/tests/acceptance/bread-crumbs-test.js @@ -10,12 +10,12 @@ module('Acceptance | breadcrumbs', function (hooks) { let org; let project; let hostCatalog; - let projectsURL; - let newProjectURL; - let projectURL; - let hostCatalogsURL; - let newHostCatalogURL; - let hostCatalogURL; + let role; + let group; + let projectsURL, projectURL, newProjectURL; + let hostCatalogsURL, hostCatalogURL, newHostCatalogURL; + let rolesURL, roleURL, newRoleURL; + let groupsURL, groupURL, newGroupURL; let crumbPath; @@ -23,18 +23,30 @@ module('Acceptance | breadcrumbs', function (hooks) { org = this.server.create('org'); project = this.server.create('project'); hostCatalog = this.server.create('host-catalog'); + role = this.server.create('role'); + group = this.server.create('group'); + projectsURL = `/orgs/${org.id}/projects`; newProjectURL = `${projectsURL}/new`; projectURL = `${projectsURL}/${project.id}`; + hostCatalogsURL = `${projectURL}/host-catalogs`; newHostCatalogURL = `${hostCatalogsURL}/new`; hostCatalogURL = `${hostCatalogsURL}/${hostCatalog.id}`; + + rolesURL = `/orgs/${org.id}/roles`; + newRoleURL = `${rolesURL}/new`; + roleURL = `${rolesURL}/${role.id}`; + + groupsURL = `/orgs/${org.id}/groups`; + newGroupURL = `${groupsURL}/new`; + groupURL = `${groupsURL}/${group.id}`; }); test('can navigate via breadcrumbs to projects from project', async function (assert) { assert.expect(3); await visit(projectURL); - assert.equal(currentURL(), projectURL, 'We begin on th expected page.'); + assert.equal(currentURL(), projectURL, 'We begin on the expected page.'); crumbPath = new URL(find('.rose-nav-breadcrumbs-link:last-child').href).pathname; assert.equal(crumbPath, projectURL, 'Last crumb has expected URL.'); await click(find('.rose-nav-breadcrumbs-link:first-child')); @@ -44,7 +56,7 @@ module('Acceptance | breadcrumbs', function (hooks) { test('can navigate via breadcrumbs to projects from new project', async function (assert) { assert.expect(3); await visit(newProjectURL); - assert.equal(currentURL(), newProjectURL, 'We begin on th expected page.'); + assert.equal(currentURL(), newProjectURL, 'We begin on the expected page.'); crumbPath = new URL(find('.rose-nav-breadcrumbs-link:last-child').href).pathname; assert.equal(crumbPath, newProjectURL, 'Last crumb has expected URL.'); await click(find('.rose-nav-breadcrumbs-link:first-child')); @@ -54,7 +66,7 @@ module('Acceptance | breadcrumbs', function (hooks) { test('can navigate via breadcrumbs to project from host catalogs', async function (assert) { assert.expect(3); await visit(hostCatalogsURL); - assert.equal(currentURL(), hostCatalogsURL, 'We begin on th expected page.'); + assert.equal(currentURL(), hostCatalogsURL, 'We begin on the expected page.'); crumbPath = new URL(find('.rose-nav-breadcrumbs-link:last-child').href).pathname; assert.equal(crumbPath, hostCatalogsURL, 'Last crumb has expected URL.'); await click(findAll('.rose-nav-breadcrumbs-link')[1]); @@ -64,7 +76,7 @@ module('Acceptance | breadcrumbs', function (hooks) { test('can navigate via breadcrumbs to host catalogs from host catalog', async function (assert) { assert.expect(3); await visit(hostCatalogURL); - assert.equal(currentURL(), hostCatalogURL, 'We begin on th expected page.'); + assert.equal(currentURL(), hostCatalogURL, 'We begin on the expected page.'); crumbPath = new URL(find('.rose-nav-breadcrumbs-link:last-child').href).pathname; assert.equal(crumbPath, hostCatalogURL, 'Last crumb has expected URL.'); await click(findAll('.rose-nav-breadcrumbs-link')[2]); @@ -74,11 +86,50 @@ module('Acceptance | breadcrumbs', function (hooks) { test('can navigate via breadcrumbs to host catalogs from new host catalog', async function (assert) { assert.expect(3); await visit(newHostCatalogURL); - assert.equal(currentURL(), newHostCatalogURL, 'We begin on th expected page.'); + assert.equal(currentURL(), newHostCatalogURL, 'We begin on the expected page.'); crumbPath = new URL(find('.rose-nav-breadcrumbs-link:last-child').href).pathname; assert.equal(crumbPath, newHostCatalogURL, 'Last crumb has expected URL.'); await click(findAll('.rose-nav-breadcrumbs-link')[2]); assert.equal(currentURL(), hostCatalogsURL, 'After navigating via breadcrumbs, we are one level up.'); }); + test('can navigate via breadcrumbs to roles from role', async function (assert) { + assert.expect(3); + await visit(roleURL); + assert.equal(currentURL(), roleURL, 'We begin on the expected page.'); + crumbPath = new URL(find('.rose-nav-breadcrumbs-link:last-child').href).pathname; + assert.equal(crumbPath, roleURL, 'Last crumb has expected URL.'); + await click(find('.rose-nav-breadcrumbs-link:first-child')); + assert.equal(currentURL(), rolesURL, 'After navigating via breadcrumbs, we are one level up.'); + }); + + test('can navigate via breadcrumbs to roles from new role', async function (assert) { + assert.expect(3); + await visit(newRoleURL); + assert.equal(currentURL(), newRoleURL, 'We begin on the expected page.'); + crumbPath = new URL(find('.rose-nav-breadcrumbs-link:last-child').href).pathname; + assert.equal(crumbPath, newRoleURL, 'Last crumb has expected URL.'); + await click(find('.rose-nav-breadcrumbs-link:first-child')); + assert.equal(currentURL(), rolesURL, 'After navigating via breadcrumbs, we are one level up.'); + }); + + test('can navigate via breadcrumbs to groups from group', async function (assert) { + assert.expect(3); + await visit(groupURL); + assert.equal(currentURL(), groupURL, 'We begin on the expected page.'); + crumbPath = new URL(find('.rose-nav-breadcrumbs-link:last-child').href).pathname; + assert.equal(crumbPath, groupURL, 'Last crumb has expected URL.'); + await click(find('.rose-nav-breadcrumbs-link:first-child')); + assert.equal(currentURL(), groupsURL, 'After navigating via breadcrumbs, we are one level up.'); + }); + + test('can navigate via breadcrumbs to groups from new group', async function (assert) { + assert.expect(3); + await visit(newGroupURL); + assert.equal(currentURL(), newGroupURL, 'We begin on the expected page.'); + crumbPath = new URL(find('.rose-nav-breadcrumbs-link:last-child').href).pathname; + assert.equal(crumbPath, newGroupURL, 'Last crumb has expected URL.'); + await click(find('.rose-nav-breadcrumbs-link:first-child')); + assert.equal(currentURL(), groupsURL, 'After navigating via breadcrumbs, we are one level up.'); + }); }); diff --git a/ui/core/tests/unit/controllers/orgs/org/groups-test.js b/ui/core/tests/unit/controllers/orgs/org/groups-test.js new file mode 100644 index 000000000..0ca58eed0 --- /dev/null +++ b/ui/core/tests/unit/controllers/orgs/org/groups-test.js @@ -0,0 +1,12 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Controller | orgs/org/groups', function(hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.lookup('controller:orgs/org/groups'); + assert.ok(controller); + }); +}); diff --git a/ui/core/tests/unit/controllers/orgs/org/groups/group-test.js b/ui/core/tests/unit/controllers/orgs/org/groups/group-test.js new file mode 100644 index 000000000..49cf5b3a6 --- /dev/null +++ b/ui/core/tests/unit/controllers/orgs/org/groups/group-test.js @@ -0,0 +1,12 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Controller | orgs/org/groups/group', function(hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.lookup('controller:orgs/org/groups/group'); + assert.ok(controller); + }); +}); diff --git a/ui/core/tests/unit/controllers/orgs/org/groups/new-test.js b/ui/core/tests/unit/controllers/orgs/org/groups/new-test.js new file mode 100644 index 000000000..ef02542c9 --- /dev/null +++ b/ui/core/tests/unit/controllers/orgs/org/groups/new-test.js @@ -0,0 +1,12 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Controller | orgs/org/groups/new', function(hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.lookup('controller:orgs/org/groups/new'); + assert.ok(controller); + }); +});