feat: 🎸 add ldap type to dropdown in list view (#1763)

* feat: 🎸 add ldap type to dropdown in list view

✅ Closes: ICU-10071

* test: 💍 fix broken tests & add new test
This commit is contained in:
Lisbet Alvarez authored and GitHub committed 2023-07-12 10:29:20 -07:00
1 parent ef8eb0e407
commit ba0edd603d
2 files changed
+83 -21

No files matched your search

@@ -18,24 +18,26 @@
<page.actions>
{{#if (can 'create model' this.scopeModel collection='auth-methods')}}
<Rose::Dropdown
@text={{t 'titles.new'}}
@dropdownRight={{true}}
as |dropdown|
>
<dropdown.link
<Hds::Dropdown as |dd|>
<dd.ToggleButton @text={{t 'titles.new'}} @color='secondary' />
<dd.Interactive
@text={{t 'resources.auth-method.types.password'}}
@route='scopes.scope.auth-methods.new'
@query={{hash type='password'}}
>
{{t 'resources.auth-method.types.password'}}
</dropdown.link>
<dropdown.link
/>
<dd.Interactive
@text={{t 'resources.auth-method.types.oidc'}}
@route='scopes.scope.auth-methods.new'
@query={{hash type='oidc'}}
>
{{t 'resources.auth-method.types.oidc'}}
</dropdown.link>
</Rose::Dropdown>
/>
{{#if (feature-flag 'ldap-auth-methods')}}
<dd.Interactive
@text={{t 'resources.auth-method.types.ldap'}}
@route='scopes.scope.auth-methods.new'
@query={{hash type='ldap'}}
/>
{{/if}}
</Hds::Dropdown>
{{/if}}
</page.actions>
@@ -29,7 +29,11 @@ module('Acceptance | auth-methods | create', function (hooks) {
'tbody .hds-table__tr:nth-child(1) .hds-table__td:last-child .hds-dropdown-toggle-icon';
const DROPDOWN_SELECTOR_OPTION =
'.hds-dropdown__content .hds-dropdown-list-item [type=button]';
const NEW_DROPDOWN_SELECTOR = '.hds-dropdown-toggle-button';
let getAuthMethodsCount;
let featuresService;
const instances = {
scopes: {
global: null,
@@ -44,6 +48,7 @@ module('Acceptance | auth-methods | create', function (hooks) {
orgScope: null,
authMethods: null,
newAuthMethod: null,
newLdapAuthMethod: null,
authMethod: null,
};
@@ -71,9 +76,12 @@ module('Acceptance | auth-methods | create', function (hooks) {
urls.orgScope = `/scopes/${instances.orgScope.id}`;
urls.authMethods = `${urls.orgScope}/auth-methods`;
urls.newAuthMethod = `${urls.authMethods}/new?type=password`;
urls.newLdapAuthMethod = `${urls.authMethods}/new?type=ldap`;
urls.authMethod = `${urls.authMethods}/${instances.authMethod.id}`;
getAuthMethodsCount = () =>
this.server.schema.authMethods.all().models.length;
featuresService = this.owner.lookup('service:features');
});
test('Users can create new auth method', async function (assert) {
@@ -139,25 +147,77 @@ module('Acceptance | auth-methods | create', function (hooks) {
'create',
'list',
];
await visit(urls.authMethods);
assert.ok(
await visit(urls.orgScope);
await click(`[href="${urls.authMethods}"]`);
assert.true(
instances.orgScope.authorized_collection_actions['auth-methods'].includes(
'create'
)
);
assert.ok(find(`[href="${urls.newAuthMethod}"]`));
await click(NEW_DROPDOWN_SELECTOR);
assert.dom(`[href="${urls.newAuthMethod}"]`).exists();
});
test('Users cannot navigate to new auth-methods route without proper authorization', async function (assert) {
assert.expect(2);
instances.orgScope.authorized_collection_actions['auth-methods'] = [];
await visit(urls.authMethods);
assert.notOk(
instances.orgScope.authorized_collection_actions['auth-methods'] = ['list'];
await visit(urls.orgScope);
await click(`[href="${urls.authMethods}"]`);
assert.false(
instances.orgScope.authorized_collection_actions['auth-methods'].includes(
'create'
)
);
assert.notOk(find(`[href="${urls.newAuthMethod}"]`));
assert.dom(NEW_DROPDOWN_SELECTOR).doesNotExist();
});
test('Users can navigate to new ldap auth-method route with proper authorization and feature flag enabled', async function (assert) {
assert.expect(2);
instances.orgScope.authorized_collection_actions['auth-methods'] = [
'create',
'list',
];
featuresService.enable('ldap-auth-methods');
await visit(urls.orgScope);
await click(`[href="${urls.authMethods}"]`);
assert.true(
instances.orgScope.authorized_collection_actions['auth-methods'].includes(
'create'
)
);
await click(NEW_DROPDOWN_SELECTOR);
assert.dom(`[href="${urls.newLdapAuthMethod}"]`).exists();
});
test('Users cannot navigate to new ldap auth-method route when feature flag disabled', async function (assert) {
assert.expect(2);
instances.orgScope.authorized_collection_actions['auth-methods'] = [
'create',
'list',
];
await visit(urls.orgScope);
await click(`[href="${urls.authMethods}"]`);
assert.true(
instances.orgScope.authorized_collection_actions['auth-methods'].includes(
'create'
)
);
await click(NEW_DROPDOWN_SELECTOR);
assert.dom(`[href="${urls.newLdapAuthMethod}"]`).doesNotExist();
});
test('can cancel new auth method creation', async function (assert) {