From e48af4bc9dd69c70af7d6933e02f262ffe656af1 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Tue, 16 Jun 2020 10:05:16 -0400 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20consolidate=20common?= =?UTF-8?q?=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]);