From 92fdacb63505a5b3f161b357956ecd07ece5723d Mon Sep 17 00:00:00 2001 From: Dharini Jeeva Date: Mon, 11 Jul 2022 10:47:26 -0700 Subject: [PATCH] =?UTF-8?q?test:=20=F0=9F=92=8D=20onboarding=20tests=20(#1?= =?UTF-8?q?181)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../acceptance/onboarding/success-test.js | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/ui/admin/tests/acceptance/onboarding/success-test.js b/ui/admin/tests/acceptance/onboarding/success-test.js index 98a45291e..a3ea1c8b5 100644 --- a/ui/admin/tests/acceptance/onboarding/success-test.js +++ b/ui/admin/tests/acceptance/onboarding/success-test.js @@ -1,5 +1,5 @@ import { module, test } from 'qunit'; -import { visit, find } from '@ember/test-helpers'; +import { visit, currentURL, find, click, fillIn } from '@ember/test-helpers'; import { setupApplicationTest } from 'ember-qunit'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { authenticateSession } from 'ember-simple-auth/test-support'; @@ -15,14 +15,40 @@ module( }); const urls = { - createResources: '/onboarding/quick-setup/create-resources/success', - targets: '/scopes/global/targets', + createResources: '/onboarding/quick-setup/create-resources', + successPath: '/onboarding/quick-setup/create-resources/success', + targetsPath: null, }; test('check if the done button is present', async function (assert) { assert.expect(1); - await visit(urls.createResources); + await visit(urls.successPath); assert.ok(find('.onboarding-quick-setup-success-button')); }); + + test('check if the controller url is copyable', async function (assert) { + assert.expect(2); + await visit(urls.successPath); + assert.ok(find('.copyable')); + assert.strictEqual( + find('.copyable-button').textContent.trim(), + 'Copy to Clipboard' + ); + }); + + test('redirect user to targets list when done is clicked', async function (assert) { + assert.expect(1); + await visit(urls.createResources); + await click('[type="checkbox"]'); + await fillIn('[name="hostAddress"]', '0.0.0.0'); + await fillIn('[name="targetPort"]', '22'); + await click('[type="submit"]'); + const projectId = this.server.schema.scopes.where({ type: 'project' }) + .models[0].id; + await visit(urls.successPath); + await click('.onboarding-quick-setup-success-button'); + urls.targetsPath = `/scopes/${projectId}/targets`; + assert.strictEqual(currentURL(), urls.targetsPath); + }); } );