76 lines
2.3 KiB
JavaScript
76 lines
2.3 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { visit, currentURL, findAll } from '@ember/test-helpers';
|
|
import { setupApplicationTest } from 'ember-qunit';
|
|
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
|
import a11yAudit from 'ember-a11y-testing/test-support/audit';
|
|
import {
|
|
authenticateSession,
|
|
// These are left here intentionally for future reference.
|
|
//currentSession,
|
|
//invalidateSession,
|
|
} from 'ember-simple-auth/test-support';
|
|
import { TYPE_AUTH_METHOD_OIDC } from 'api/models/auth-method';
|
|
|
|
module('Acceptance | managed-groups | members', function (hooks) {
|
|
setupApplicationTest(hooks);
|
|
setupMirage(hooks);
|
|
|
|
const instances = {
|
|
scopes: {
|
|
global: null,
|
|
org: null,
|
|
},
|
|
authMethod: null,
|
|
managedGroup: null,
|
|
accounts: null,
|
|
};
|
|
const urls = {
|
|
orgScope: null,
|
|
authMethods: null,
|
|
managedGroups: null,
|
|
managedGroup: null,
|
|
managedGroupMembers: null,
|
|
};
|
|
|
|
hooks.beforeEach(function () {
|
|
authenticateSession({});
|
|
instances.scopes.global = this.server.create('scope', { id: 'global' });
|
|
instances.scopes.org = this.server.create('scope', {
|
|
type: 'org',
|
|
scope: { id: 'global', type: 'global' },
|
|
});
|
|
instances.authMethod = this.server.create(
|
|
'auth-method',
|
|
{
|
|
scope: instances.scopes.org,
|
|
type: TYPE_AUTH_METHOD_OIDC,
|
|
},
|
|
'withAccountsAndUsersAndManagedGroups'
|
|
);
|
|
|
|
instances.managedGroup = this.server.db.managedGroups[0];
|
|
// Generate route URLs for resources
|
|
urls.orgScope = `/scopes/${instances.scopes.org.id}`;
|
|
urls.authMethods = `${urls.orgScope}/auth-methods`;
|
|
urls.authMethod = `${urls.authMethods}/${instances.authMethod.id}`;
|
|
urls.managedGroups = `${urls.authMethod}/managed-groups`;
|
|
urls.managedGroup = `${urls.managedGroups}/${instances.managedGroup.id}`;
|
|
urls.managedGroupMembers = `${urls.managedGroup}/members`;
|
|
});
|
|
|
|
test('User can navigate to index', async function (assert) {
|
|
assert.expect(3);
|
|
const membersCount = instances.managedGroup.memberIds.length;
|
|
await visit(urls.managedGroupMembers);
|
|
await a11yAudit();
|
|
assert.strictEqual(currentURL(), urls.managedGroupMembers);
|
|
assert.ok(membersCount);
|
|
assert.strictEqual(findAll('tbody tr').length, membersCount);
|
|
});
|
|
});
|