From c2ffe19d442f9c8e9070114ae7a14e30d6b712e0 Mon Sep 17 00:00:00 2001 From: dharini Date: Mon, 16 Aug 2021 17:10:18 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20test=20cases?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/admin/jsconfig.json | 1 + ui/admin/tests/acceptance/users/read-test.js | 1 + .../tests/acceptance/users/update-test.js | 20 +++++++++++++++++-- ui/desktop/jsconfig.json | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 ui/admin/jsconfig.json create mode 100644 ui/desktop/jsconfig.json diff --git a/ui/admin/jsconfig.json b/ui/admin/jsconfig.json new file mode 100644 index 000000000..f408cac8c --- /dev/null +++ b/ui/admin/jsconfig.json @@ -0,0 +1 @@ +{"compilerOptions":{"target":"es6","experimentalDecorators":true},"exclude":["node_modules","bower_components","tmp","vendor",".git","dist"]} \ No newline at end of file diff --git a/ui/admin/tests/acceptance/users/read-test.js b/ui/admin/tests/acceptance/users/read-test.js index 551cf96f6..cd896bdc9 100644 --- a/ui/admin/tests/acceptance/users/read-test.js +++ b/ui/admin/tests/acceptance/users/read-test.js @@ -24,6 +24,7 @@ module('Acceptance | users', function (hooks) { }, user: null, }; + hooks.beforeEach(function () { orgScope = this.server.create( 'scope', diff --git a/ui/admin/tests/acceptance/users/update-test.js b/ui/admin/tests/acceptance/users/update-test.js index eade03c6b..3a5cba152 100644 --- a/ui/admin/tests/acceptance/users/update-test.js +++ b/ui/admin/tests/acceptance/users/update-test.js @@ -18,6 +18,14 @@ module('Acceptance | users', function (hooks) { let usersURL; let userURL; + const instances = { + scopes: { + global: null, + org: null, + }, + user: null, + }; + hooks.beforeEach(function () { orgScope = this.server.create( 'scope', @@ -27,12 +35,12 @@ module('Acceptance | users', function (hooks) { 'withChildren' ); - const user = this.server.create('user', { + instances.user = this.server.create('user', { scope: orgScope, }); usersURL = `/scopes/${orgScope.id}/users`; - userURL = `${usersURL}/${user.id}`; + userURL = `${usersURL}/${instances.user.id}`; authenticateSession({}); }); @@ -55,6 +63,14 @@ module('Acceptance | users', function (hooks) { assert.notEqual(find('[name="name"]').value, 'Unsaved user name'); }); + test('cannot make changes to an existing user without proper authorization', async function (assert) { + assert.expect(1); + instances.user.authorized_actions = + instances.user.authorized_actions.filter((item) => item !== 'update'); + await visit(userURL); + assert.notOk(find('.rose-layout-page-actions .rose-button-secondary')); + }); + test('saving an existing user with invalid fields displays error messages', async function (assert) { assert.expect(2); this.server.patch('/users/:id', () => { diff --git a/ui/desktop/jsconfig.json b/ui/desktop/jsconfig.json new file mode 100644 index 000000000..f408cac8c --- /dev/null +++ b/ui/desktop/jsconfig.json @@ -0,0 +1 @@ +{"compilerOptions":{"target":"es6","experimentalDecorators":true},"exclude":["node_modules","bower_components","tmp","vendor",".git","dist"]} \ No newline at end of file