From 8aa9a51c881bae3b9ed3fd0442250585c93fa9b6 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Fri, 26 Mar 2021 14:55:19 -0400 Subject: [PATCH] =?UTF-8?q?test:=20=F0=9F=92=8D=20add=20primary=20auth=20m?= =?UTF-8?q?ethod=20acceptance=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/acceptance/auth-methods-test.js | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/ui/admin/tests/acceptance/auth-methods-test.js b/ui/admin/tests/acceptance/auth-methods-test.js index 67e73d624..27bbe2db2 100644 --- a/ui/admin/tests/acceptance/auth-methods-test.js +++ b/ui/admin/tests/acceptance/auth-methods-test.js @@ -270,4 +270,90 @@ module('Acceptance | auth methods', function (hooks) { 'Displays field-level errors.' ); }); + + test('user can make primary an auth method', async function (assert) { + assert.expect(2); + assert.notOk( + instances.scopes.org.primaryAuthMethodId, + 'Primary auth method is not yet set.' + ); + await visit(urls.authMethod); + await click( + '.rose-layout-page-actions .rose-dropdown-content [type="button"]:first-child' + ); + const scope = this.server.schema.scopes.find(instances.scopes.org.id); + assert.equal( + scope.primaryAuthMethodId, + instances.authMethod.id, + 'Primary auth method is set.' + ); + }); + + test('user is notified of error on make primary an auth method', async function (assert) { + assert.expect(2); + this.server.patch('/scopes/:id', () => { + return new Response( + 400, + {}, + { + status: 400, + code: 'fail', + message: 'Sorry!', + } + ); + }); + assert.notOk( + instances.scopes.org.primaryAuthMethodId, + 'Primary auth method is not yet set.' + ); + await visit(urls.authMethod); + await click( + '.rose-layout-page-actions .rose-dropdown-content [type="button"]:first-child' + ); + assert.ok(find('.rose-notification')); + }); + + test('user can remove as primary an auth method', async function (assert) { + assert.expect(2); + instances.scopes.org.update({ + primaryAuthMethodId: instances.authMethod.id, + }); + assert.ok( + instances.scopes.org.primaryAuthMethodId, + 'Primary auth method is set.' + ); + await visit(urls.authMethod); + await click( + '.rose-layout-page-actions .rose-dropdown-content [type="button"]:first-child' + ); + const scope = this.server.schema.scopes.find(instances.scopes.org.id); + assert.notOk(scope.primaryAuthMethodId, 'Primary auth method is unset.'); + }); + + test('user is notified of error on remove as primary an auth method', async function (assert) { + assert.expect(2); + this.server.patch('/scopes/:id', () => { + return new Response( + 400, + {}, + { + status: 400, + code: 'fail', + message: 'Sorry!', + } + ); + }); + instances.scopes.org.update({ + primaryAuthMethodId: instances.authMethod.id, + }); + assert.ok( + instances.scopes.org.primaryAuthMethodId, + 'Primary auth method is set.' + ); + await visit(urls.authMethod); + await click( + '.rose-layout-page-actions .rose-dropdown-content [type="button"]:first-child' + ); + assert.ok(find('.rose-notification')); + }); });