From 9a12ea51153eb27fbce5bbb148819603ecf26827 Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Thu, 11 Jun 2020 14:41:57 -0400 Subject: [PATCH 1/6] =?UTF-8?q?test:=20=F0=9F=92=8D=20Add=20breadcrumbs=20?= =?UTF-8?q?ui/core=20component=20integration=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ember-breadcrumbs addon template is overwritten in ui/core. Added tests for template update. --- .../rose/components/nav/_breadcrumbs.scss | 1 + ui/core/app/controllers/.gitkeep | 0 .../tests/acceptance/host-catalogs-test.js | 21 ++++++++++- ui/core/tests/acceptance/projects-test.js | 7 +++- .../components/bread-crumbs-test.js | 37 +++++++++++++++++-- 5 files changed, 59 insertions(+), 7 deletions(-) delete mode 100644 ui/core/app/controllers/.gitkeep diff --git a/addons/rose/addon/styles/rose/components/nav/_breadcrumbs.scss b/addons/rose/addon/styles/rose/components/nav/_breadcrumbs.scss index c07156279..e7ac5572e 100644 --- a/addons/rose/addon/styles/rose/components/nav/_breadcrumbs.scss +++ b/addons/rose/addon/styles/rose/components/nav/_breadcrumbs.scss @@ -11,6 +11,7 @@ color: var(--color); text-decoration: none; cursor: pointer; + display: inline-flex; &:hover { --color: var(--action); diff --git a/ui/core/app/controllers/.gitkeep b/ui/core/app/controllers/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/ui/core/tests/acceptance/host-catalogs-test.js b/ui/core/tests/acceptance/host-catalogs-test.js index acdacafa7..e07e85046 100644 --- a/ui/core/tests/acceptance/host-catalogs-test.js +++ b/ui/core/tests/acceptance/host-catalogs-test.js @@ -1,5 +1,5 @@ import { module, test } from 'qunit'; -import { visit, currentURL, click, fillIn, find } from '@ember/test-helpers'; +import { visit, currentURL, click, fillIn, find, findAll } from '@ember/test-helpers'; import { setupApplicationTest } from 'ember-qunit'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import a11yAudit from 'ember-a11y-testing/test-support/audit'; @@ -10,12 +10,29 @@ module('Acceptance | host catalogs', function(hooks) { setupMirage(hooks); test('visiting host catalogs', async function (assert) { - assert.expect(1); + assert.expect(5); this.server.createList('project', 1); this.server.createList('host-catalog', 1); await visit('/orgs/1/projects/1/host-catalogs'); await a11yAudit(); assert.equal(currentURL(), '/orgs/1/projects/1/host-catalogs'); + + assert.equal(findAll('.rose-layout-page-breadcrumbs a').length, 3); + assert.equal( + findAll('.rose-layout-page-breadcrumbs a')[0].textContent.trim(), + 'Projects', + 'Displays project breadcrumb' + ); + assert.equal( + findAll('.rose-layout-page-breadcrumbs a')[1].textContent.trim(), + this.server.db.projects[0].name, + 'Displays project name breadcrumb' + ); + assert.equal( + findAll('.rose-layout-page-breadcrumbs a')[2].textContent.trim(), + 'Host Catalogs', + 'Displays hostcatalog breadcrumb' + ); }); test('can navigate to host catalog form', async function(assert) { diff --git a/ui/core/tests/acceptance/projects-test.js b/ui/core/tests/acceptance/projects-test.js index 612da5ffb..832ce0529 100644 --- a/ui/core/tests/acceptance/projects-test.js +++ b/ui/core/tests/acceptance/projects-test.js @@ -10,11 +10,16 @@ module('Acceptance | projects', function (hooks) { setupMirage(hooks); test('visiting projects', async function (assert) { - assert.expect(1); + assert.expect(2); this.server.createList('project', 1); await visit('/orgs/1/projects'); await a11yAudit(); assert.equal(currentURL(), '/orgs/1/projects'); + assert.equal( + find('.rose-layout-page-breadcrumbs').textContent.trim(), + 'Projects', + 'Displays breadcrumbs' + ); }); test('saving a new project with invalid fields displays error messages', async function (assert) { diff --git a/ui/core/tests/integration/components/bread-crumbs-test.js b/ui/core/tests/integration/components/bread-crumbs-test.js index 47ba10bba..7ecb5ac86 100644 --- a/ui/core/tests/integration/components/bread-crumbs-test.js +++ b/ui/core/tests/integration/components/bread-crumbs-test.js @@ -1,13 +1,42 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; -//import { render } from '@ember/test-helpers'; -//import { hbs } from 'ember-cli-htmlbars'; +import { render, find, findAll } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; module('Integration | Component | bread-crumbs', function(hooks) { setupRenderingTest(hooks); - // TODO: need bread crumbs tests test('it renders', async function(assert) { - assert.ok(true); + this.set('breadCrumbs', [{label: 'Level 1'}]); + + await render(hbs``); + assert.equal(find('.rose-nav-breadcrumbs').textContent.trim(), 'Level 1'); + }); + + test('it renders with model', async function(assert) { + this.set('breadCrumbs', [{ + label: 'Level 2', + path: 'orgs.org.projects.project', + model: {project_id: 'project'}} + ]); + + await render(hbs``); + assert.equal(find('.rose-nav-breadcrumbs').textContent.trim(), 'Level 2'); + }); + + test('it renders multiple breadCrumbs', async function(assert) { + this.set('breadCrumbs', [{ + label: 'Level 1' + },{ + label: 'Level 2' + }, { + label: 'Level 3' + }]); + + await render(hbs``); + assert.equal(findAll('a').length, 3); + assert.equal(findAll('a')[0].textContent.trim(), 'Level 1'); + assert.equal(findAll('a')[1].textContent.trim(), 'Level 2'); + assert.equal(findAll('a')[2].textContent.trim(), 'Level 3'); }); }); From 376b00cca57455de47eadd983ff33eeeed35c9b9 Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Fri, 12 Jun 2020 15:02:42 -0400 Subject: [PATCH 2/6] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20Delete=20tests?= =?UTF-8?q?=20for=20breadcrumbs=20in=20core/pages=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove breadcrumb verification from core pages acceptance tests suite to be later added into it's own testfile --- .../tests/acceptance/host-catalogs-test.js | 21 ++----------------- ui/core/tests/acceptance/projects-test.js | 7 +------ 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/ui/core/tests/acceptance/host-catalogs-test.js b/ui/core/tests/acceptance/host-catalogs-test.js index e07e85046..acdacafa7 100644 --- a/ui/core/tests/acceptance/host-catalogs-test.js +++ b/ui/core/tests/acceptance/host-catalogs-test.js @@ -1,5 +1,5 @@ import { module, test } from 'qunit'; -import { visit, currentURL, click, fillIn, find, findAll } from '@ember/test-helpers'; +import { visit, currentURL, click, fillIn, find } from '@ember/test-helpers'; import { setupApplicationTest } from 'ember-qunit'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import a11yAudit from 'ember-a11y-testing/test-support/audit'; @@ -10,29 +10,12 @@ module('Acceptance | host catalogs', function(hooks) { setupMirage(hooks); test('visiting host catalogs', async function (assert) { - assert.expect(5); + assert.expect(1); this.server.createList('project', 1); this.server.createList('host-catalog', 1); await visit('/orgs/1/projects/1/host-catalogs'); await a11yAudit(); assert.equal(currentURL(), '/orgs/1/projects/1/host-catalogs'); - - assert.equal(findAll('.rose-layout-page-breadcrumbs a').length, 3); - assert.equal( - findAll('.rose-layout-page-breadcrumbs a')[0].textContent.trim(), - 'Projects', - 'Displays project breadcrumb' - ); - assert.equal( - findAll('.rose-layout-page-breadcrumbs a')[1].textContent.trim(), - this.server.db.projects[0].name, - 'Displays project name breadcrumb' - ); - assert.equal( - findAll('.rose-layout-page-breadcrumbs a')[2].textContent.trim(), - 'Host Catalogs', - 'Displays hostcatalog breadcrumb' - ); }); test('can navigate to host catalog form', async function(assert) { diff --git a/ui/core/tests/acceptance/projects-test.js b/ui/core/tests/acceptance/projects-test.js index 832ce0529..612da5ffb 100644 --- a/ui/core/tests/acceptance/projects-test.js +++ b/ui/core/tests/acceptance/projects-test.js @@ -10,16 +10,11 @@ module('Acceptance | projects', function (hooks) { setupMirage(hooks); test('visiting projects', async function (assert) { - assert.expect(2); + assert.expect(1); this.server.createList('project', 1); await visit('/orgs/1/projects'); await a11yAudit(); assert.equal(currentURL(), '/orgs/1/projects'); - assert.equal( - find('.rose-layout-page-breadcrumbs').textContent.trim(), - 'Projects', - 'Displays breadcrumbs' - ); }); test('saving a new project with invalid fields displays error messages', async function (assert) { From 8f9f0179957727c0519e9c312dbd00dde2460ded Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Mon, 15 Jun 2020 14:34:37 -0400 Subject: [PATCH 3/6] =?UTF-8?q?test:=20=F0=9F=92=8D=20Add=20acceptance=20t?= =?UTF-8?q?est=20for=20breadcrumbs=20in=20ui/core?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/core/tests/acceptance/bread-crumbs-test.js | 81 +++++++++++++++++++ .../components/bread-crumbs-test.js | 9 ++- 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 ui/core/tests/acceptance/bread-crumbs-test.js diff --git a/ui/core/tests/acceptance/bread-crumbs-test.js b/ui/core/tests/acceptance/bread-crumbs-test.js new file mode 100644 index 000000000..6e302588d --- /dev/null +++ b/ui/core/tests/acceptance/bread-crumbs-test.js @@ -0,0 +1,81 @@ +import { module, test } from 'qunit'; +import { visit, currentURL, click, findAll } from '@ember/test-helpers'; +import { setupApplicationTest } from 'ember-qunit'; +import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; + +module('Acceptance | breadcrumbs', function (hooks) { + setupApplicationTest(hooks); + setupMirage(hooks); + + test('visiting projects', async function (assert) { + assert.expect(2); + this.server.createList('project', 1); + await visit('/orgs/1/projects'); + assert.equal(findAll('.rose-nav-breadcrumbs a').length, 1); + await click('.rose-nav-breadcrumbs a'); + assert.equal(currentURL(), '/orgs/1/projects'); + }); + + test('visiting project', async function (assert) { + assert.expect(2); + this.server.createList('project', 1); + const projectURL = `/orgs/1/projects/${this.server.db.projects[0].id}`; + await visit(projectURL); + assert.equal(findAll('.rose-nav-breadcrumbs a').length, 2); + + await visit(projectURL); + await click(findAll('.rose-nav-breadcrumbs a')[1]); + assert.equal(currentURL(), projectURL); + }); + + test('visiting project creation', async function (assert) { + assert.expect(2); + this.server.createList('project', 1); + const projectURL = '/orgs/1/projects/new'; + await visit(projectURL); + assert.equal(findAll('.rose-nav-breadcrumbs a').length, 2); + + await visit(projectURL); + await click(findAll('.rose-nav-breadcrumbs a')[1]); + assert.equal(currentURL(), projectURL); + }); + + test('visiting host catalogs', async function (assert) { + assert.expect(2); + this.server.createList('project', 1); + this.server.createList('host-catalog', 1); + const hostcatalogsURL = `/orgs/1/projects/${this.server.db.projects[0].id}/host-catalogs`; + await visit(hostcatalogsURL); + assert.equal(findAll('.rose-nav-breadcrumbs a').length, 3); + + await visit(hostcatalogsURL); + await click(findAll('.rose-nav-breadcrumbs a')[2]); + assert.equal(currentURL(), hostcatalogsURL); + }); + + test('visiting host catalog', async function (assert) { + assert.expect(2); + this.server.createList('project', 1); + this.server.createList('host-catalog', 1); + const hostcatalogURL = `/orgs/1/projects/${this.server.db.projects[0].id}/host-catalogs/${this.server.db.hostCatalogs[0].id}`; + await visit(hostcatalogURL); + assert.equal(findAll('.rose-nav-breadcrumbs a').length, 4); + + await visit(hostcatalogURL); + await click(findAll('.rose-nav-breadcrumbs a')[3]); + assert.equal(currentURL(), hostcatalogURL); + }); + + test('visiting host catalog creation', async function (assert) { + assert.expect(2); + this.server.createList('project', 1); + this.server.createList('host-catalog', 1); + const hostcatalogURL = `/orgs/1/projects/${this.server.db.projects[0].id}/host-catalogs/new`; + await visit(hostcatalogURL); + assert.equal(findAll('.rose-nav-breadcrumbs a').length, 4); + + await visit(hostcatalogURL); + await click(findAll('.rose-nav-breadcrumbs a')[3]); + assert.equal(currentURL(), hostcatalogURL); + }); +}); diff --git a/ui/core/tests/integration/components/bread-crumbs-test.js b/ui/core/tests/integration/components/bread-crumbs-test.js index 7ecb5ac86..a6f3579c8 100644 --- a/ui/core/tests/integration/components/bread-crumbs-test.js +++ b/ui/core/tests/integration/components/bread-crumbs-test.js @@ -10,15 +10,20 @@ module('Integration | Component | bread-crumbs', function(hooks) { this.set('breadCrumbs', [{label: 'Level 1'}]); await render(hbs``); + // Default index route + assert.ok(find('.rose-nav-breadcrumbs a').href.match(/#$/)); assert.equal(find('.rose-nav-breadcrumbs').textContent.trim(), 'Level 1'); }); test('it renders with model', async function(assert) { + let store = this.owner.lookup('service:store'); + let project = store.createRecord('project', {id: '1234'}); + this.set('breadCrumbs', [{ label: 'Level 2', path: 'orgs.org.projects.project', - model: {project_id: 'project'}} - ]); + model: project + }]); await render(hbs``); assert.equal(find('.rose-nav-breadcrumbs').textContent.trim(), 'Level 2'); From f2f0144e5b7ccd07ad49841a272a41cb80aedc64 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Tue, 16 Jun 2020 09:40:03 -0400 Subject: [PATCH 4/6] =?UTF-8?q?test:=20=F0=9F=92=8D=20use=20breadcrumbs=20?= =?UTF-8?q?acceptance=20tests=20for=20navigation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/core/tests/acceptance/bread-crumbs-test.js | 98 ++++++++----------- 1 file changed, 41 insertions(+), 57 deletions(-) diff --git a/ui/core/tests/acceptance/bread-crumbs-test.js b/ui/core/tests/acceptance/bread-crumbs-test.js index 6e302588d..8515916d0 100644 --- a/ui/core/tests/acceptance/bread-crumbs-test.js +++ b/ui/core/tests/acceptance/bread-crumbs-test.js @@ -1,5 +1,5 @@ import { module, test } from 'qunit'; -import { visit, currentURL, click, findAll } from '@ember/test-helpers'; +import { visit, currentURL, click, find, findAll } from '@ember/test-helpers'; import { setupApplicationTest } from 'ember-qunit'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; @@ -7,75 +7,59 @@ module('Acceptance | breadcrumbs', function (hooks) { setupApplicationTest(hooks); setupMirage(hooks); - test('visiting projects', async function (assert) { + test('can navigate via breadcrumbs to projects from project', async function (assert) { assert.expect(2); - this.server.createList('project', 1); - await visit('/orgs/1/projects'); - assert.equal(findAll('.rose-nav-breadcrumbs a').length, 1); - await click('.rose-nav-breadcrumbs a'); - assert.equal(currentURL(), '/orgs/1/projects'); - }); - - test('visiting project', async function (assert) { - assert.expect(2); - this.server.createList('project', 1); - const projectURL = `/orgs/1/projects/${this.server.db.projects[0].id}`; + const project = this.server.create('project'); + const projectURL = `/orgs/1/projects/${project.id}`; await visit(projectURL); - assert.equal(findAll('.rose-nav-breadcrumbs a').length, 2); - - await visit(projectURL); - await click(findAll('.rose-nav-breadcrumbs a')[1]); - assert.equal(currentURL(), projectURL); + assert.equal(currentURL(), projectURL, 'We begin on th expected page.'); + await click(find('.rose-nav-breadcrumbs-link:first-child')); + assert.equal(currentURL(), '/orgs/1/projects', 'After navigating via breadcrumbs, we are one level up.'); }); - test('visiting project creation', async function (assert) { + test('can navigate via breadcrumbs to projects from new project', async function (assert) { assert.expect(2); - this.server.createList('project', 1); - const projectURL = '/orgs/1/projects/new'; - await visit(projectURL); - assert.equal(findAll('.rose-nav-breadcrumbs a').length, 2); - - await visit(projectURL); - await click(findAll('.rose-nav-breadcrumbs a')[1]); - assert.equal(currentURL(), projectURL); + const newProjectURL = `/orgs/1/projects/new`; + await visit(newProjectURL); + assert.equal(currentURL(), newProjectURL, 'We begin on th expected page.'); + await click(find('.rose-nav-breadcrumbs-link:first-child')); + assert.equal(currentURL(), '/orgs/1/projects', 'After navigating via breadcrumbs, we are one level up.'); }); - test('visiting host catalogs', async function (assert) { + test('can navigate via breadcrumbs to project from host catalogs', async function (assert) { assert.expect(2); - this.server.createList('project', 1); - this.server.createList('host-catalog', 1); - const hostcatalogsURL = `/orgs/1/projects/${this.server.db.projects[0].id}/host-catalogs`; - await visit(hostcatalogsURL); - assert.equal(findAll('.rose-nav-breadcrumbs a').length, 3); - - await visit(hostcatalogsURL); - await click(findAll('.rose-nav-breadcrumbs a')[2]); - assert.equal(currentURL(), hostcatalogsURL); + const project = this.server.create('project'); + const projectURL = `/orgs/1/projects/${project.id}`; + const hostCatalogsURL = `${projectURL}/host-catalogs`; + await visit(hostCatalogsURL); + assert.equal(currentURL(), hostCatalogsURL, 'We begin on th expected page.'); + await click(findAll('.rose-nav-breadcrumbs-link')[1]); + assert.equal(currentURL(), projectURL, 'After navigating via breadcrumbs, we are one level up.'); }); - test('visiting host catalog', async function (assert) { + test('can navigate via breadcrumbs to host catalogs from host catalog', async function (assert) { assert.expect(2); - this.server.createList('project', 1); - this.server.createList('host-catalog', 1); - const hostcatalogURL = `/orgs/1/projects/${this.server.db.projects[0].id}/host-catalogs/${this.server.db.hostCatalogs[0].id}`; - await visit(hostcatalogURL); - assert.equal(findAll('.rose-nav-breadcrumbs a').length, 4); - - await visit(hostcatalogURL); - await click(findAll('.rose-nav-breadcrumbs a')[3]); - assert.equal(currentURL(), hostcatalogURL); + const project = this.server.create('project'); + const hostCatalog = this.server.create('host-catalog'); + const projectURL = `/orgs/1/projects/${project.id}`; + const hostCatalogsURL = `${projectURL}/host-catalogs`; + const hostCatalogURL = `${hostCatalogsURL}/${hostCatalog.id}`; + await visit(hostCatalogURL); + assert.equal(currentURL(), hostCatalogURL, 'We begin on th expected page.'); + await click(findAll('.rose-nav-breadcrumbs-link')[2]); + assert.equal(currentURL(), hostCatalogsURL, 'After navigating via breadcrumbs, we are one level up.'); }); - test('visiting host catalog creation', async function (assert) { + test('can navigate via breadcrumbs to host catalogs from new host catalog', async function (assert) { assert.expect(2); - this.server.createList('project', 1); - this.server.createList('host-catalog', 1); - const hostcatalogURL = `/orgs/1/projects/${this.server.db.projects[0].id}/host-catalogs/new`; - await visit(hostcatalogURL); - assert.equal(findAll('.rose-nav-breadcrumbs a').length, 4); - - await visit(hostcatalogURL); - await click(findAll('.rose-nav-breadcrumbs a')[3]); - assert.equal(currentURL(), hostcatalogURL); + const project = this.server.create('project'); + const projectURL = `/orgs/1/projects/${project.id}`; + const hostCatalogsURL = `${projectURL}/host-catalogs`; + const newHostCatalogURL = `${hostCatalogsURL}/new`; + await visit(newHostCatalogURL); + assert.equal(currentURL(), newHostCatalogURL, 'We begin on th expected page.'); + await click(findAll('.rose-nav-breadcrumbs-link')[2]); + assert.equal(currentURL(), hostCatalogsURL, 'After navigating via breadcrumbs, we are one level up.'); }); + }); From e48af4bc9dd69c70af7d6933e02f262ffe656af1 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Tue, 16 Jun 2020 10:05:16 -0400 Subject: [PATCH 5/6] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20consolidate=20co?= =?UTF-8?q?mmon=20steps=20into=20before=20hook?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/core/tests/acceptance/bread-crumbs-test.js | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/ui/core/tests/acceptance/bread-crumbs-test.js b/ui/core/tests/acceptance/bread-crumbs-test.js index 8515916d0..4cb61733e 100644 --- a/ui/core/tests/acceptance/bread-crumbs-test.js +++ b/ui/core/tests/acceptance/bread-crumbs-test.js @@ -7,10 +7,28 @@ module('Acceptance | breadcrumbs', function (hooks) { setupApplicationTest(hooks); setupMirage(hooks); + let project; + let hostCatalog; + let projectsURL; + let newProjectURL; + let projectURL; + let hostCatalogsURL; + let newHostCatalogURL; + let hostCatalogURL; + + hooks.beforeEach(function () { + project = this.server.create('project'); + hostCatalog = this.server.create('host-catalog'); + projectsURL = `/orgs/1/projects`; + newProjectURL = `${projectsURL}/new`; + projectURL = `${projectsURL}/${project.id}`; + hostCatalogsURL = `${projectURL}/host-catalogs`; + newHostCatalogURL = `${hostCatalogsURL}/new`; + hostCatalogURL = `${hostCatalogsURL}/${hostCatalog.id}`; + }); + test('can navigate via breadcrumbs to projects from project', async function (assert) { assert.expect(2); - const project = this.server.create('project'); - const projectURL = `/orgs/1/projects/${project.id}`; await visit(projectURL); assert.equal(currentURL(), projectURL, 'We begin on th expected page.'); await click(find('.rose-nav-breadcrumbs-link:first-child')); @@ -19,7 +37,6 @@ module('Acceptance | breadcrumbs', function (hooks) { test('can navigate via breadcrumbs to projects from new project', async function (assert) { assert.expect(2); - const newProjectURL = `/orgs/1/projects/new`; await visit(newProjectURL); assert.equal(currentURL(), newProjectURL, 'We begin on th expected page.'); await click(find('.rose-nav-breadcrumbs-link:first-child')); @@ -28,9 +45,6 @@ module('Acceptance | breadcrumbs', function (hooks) { test('can navigate via breadcrumbs to project from host catalogs', async function (assert) { assert.expect(2); - const project = this.server.create('project'); - const projectURL = `/orgs/1/projects/${project.id}`; - const hostCatalogsURL = `${projectURL}/host-catalogs`; await visit(hostCatalogsURL); assert.equal(currentURL(), hostCatalogsURL, 'We begin on th expected page.'); await click(findAll('.rose-nav-breadcrumbs-link')[1]); @@ -39,11 +53,6 @@ module('Acceptance | breadcrumbs', function (hooks) { test('can navigate via breadcrumbs to host catalogs from host catalog', async function (assert) { assert.expect(2); - const project = this.server.create('project'); - const hostCatalog = this.server.create('host-catalog'); - const projectURL = `/orgs/1/projects/${project.id}`; - const hostCatalogsURL = `${projectURL}/host-catalogs`; - const hostCatalogURL = `${hostCatalogsURL}/${hostCatalog.id}`; await visit(hostCatalogURL); assert.equal(currentURL(), hostCatalogURL, 'We begin on th expected page.'); await click(findAll('.rose-nav-breadcrumbs-link')[2]); @@ -52,10 +61,6 @@ module('Acceptance | breadcrumbs', function (hooks) { test('can navigate via breadcrumbs to host catalogs from new host catalog', async function (assert) { assert.expect(2); - const project = this.server.create('project'); - const projectURL = `/orgs/1/projects/${project.id}`; - const hostCatalogsURL = `${projectURL}/host-catalogs`; - const newHostCatalogURL = `${hostCatalogsURL}/new`; await visit(newHostCatalogURL); assert.equal(currentURL(), newHostCatalogURL, 'We begin on th expected page.'); await click(findAll('.rose-nav-breadcrumbs-link')[2]); From 8d66c178eb0eafaef556124240aa611d3e701685 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Tue, 16 Jun 2020 10:18:10 -0400 Subject: [PATCH 6/6] =?UTF-8?q?test:=20=F0=9F=92=8D=20add=20current=20crum?= =?UTF-8?q?b=20path=20checks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/core/tests/acceptance/bread-crumbs-test.js | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/ui/core/tests/acceptance/bread-crumbs-test.js b/ui/core/tests/acceptance/bread-crumbs-test.js index 4cb61733e..acdd9e736 100644 --- a/ui/core/tests/acceptance/bread-crumbs-test.js +++ b/ui/core/tests/acceptance/bread-crumbs-test.js @@ -16,6 +16,8 @@ module('Acceptance | breadcrumbs', function (hooks) { let newHostCatalogURL; let hostCatalogURL; + let crumbPath; + hooks.beforeEach(function () { project = this.server.create('project'); hostCatalog = this.server.create('host-catalog'); @@ -28,41 +30,51 @@ module('Acceptance | breadcrumbs', function (hooks) { }); test('can navigate via breadcrumbs to projects from project', async function (assert) { - assert.expect(2); + assert.expect(3); await visit(projectURL); assert.equal(currentURL(), projectURL, 'We begin on th 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')); assert.equal(currentURL(), '/orgs/1/projects', 'After navigating via breadcrumbs, we are one level up.'); }); test('can navigate via breadcrumbs to projects from new project', async function (assert) { - assert.expect(2); + assert.expect(3); await visit(newProjectURL); assert.equal(currentURL(), newProjectURL, 'We begin on th 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')); assert.equal(currentURL(), '/orgs/1/projects', 'After navigating via breadcrumbs, we are one level up.'); }); test('can navigate via breadcrumbs to project from host catalogs', async function (assert) { - assert.expect(2); + assert.expect(3); await visit(hostCatalogsURL); assert.equal(currentURL(), hostCatalogsURL, 'We begin on th 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]); assert.equal(currentURL(), projectURL, 'After navigating via breadcrumbs, we are one level up.'); }); test('can navigate via breadcrumbs to host catalogs from host catalog', async function (assert) { - assert.expect(2); + assert.expect(3); await visit(hostCatalogURL); assert.equal(currentURL(), hostCatalogURL, 'We begin on th 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]); assert.equal(currentURL(), hostCatalogsURL, 'After navigating via breadcrumbs, we are one level up.'); }); test('can navigate via breadcrumbs to host catalogs from new host catalog', async function (assert) { - assert.expect(2); + assert.expect(3); await visit(newHostCatalogURL); assert.equal(currentURL(), newHostCatalogURL, 'We begin on th 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.'); });