vault/ui/tests/helpers/ldap/ldap-helpers.js
claire bontempo 30d4e21e88
UI: LDAP Hierarchical roles (#28824)
* remove named path adapter extension, add subdirectory query logic to adapter

* add subdirectory route and logic to page::roles component

* fix overview page search select

* breadcrumbs

* update tests and mirage

* revert ss changes

* oops

* cleanup adapter, add _ for private methods

* add acceptance test

* remove type

* add changelog

* add ldap breadcrumb test

* VAULT-31905 link jira

* update breadcrumbs in Edit route

* rename type interfaces
2024-11-06 00:52:29 +00:00

45 lines
1.3 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { visit, currentURL } from '@ember/test-helpers';
export const createSecretsEngine = (store) => {
store.pushPayload('secret-engine', {
modelName: 'secret-engine',
data: {
accessor: 'ldap_7e838627',
path: 'ldap-test/',
type: 'ldap',
},
});
return store.peekRecord('secret-engine', 'ldap-test');
};
export const generateBreadcrumbs = (backend, childRoute) => {
const breadcrumbs = [{ label: 'Secrets', route: 'secrets', linkExternal: true }];
const root = { label: backend };
if (childRoute) {
root.route = 'overview';
breadcrumbs.push({ label: childRoute });
}
breadcrumbs.splice(1, 0, root);
return breadcrumbs;
};
const baseURL = (backend) => `/vault/secrets/${backend}/ldap/`;
const stripLeadingSlash = (uri) => (uri.charAt(0) === '/' ? uri.slice(1) : uri);
export const isURL = (uri, backend = 'ldap-test') => {
return currentURL() === `${baseURL(backend)}${stripLeadingSlash(uri)}`;
};
export const assertURL = (assert, backend, path) => {
assert.strictEqual(currentURL(), baseURL(backend) + path, `url is ${path}`);
};
export const visitURL = (uri, backend = 'ldap-test') => {
return visit(`${baseURL(backend)}${stripLeadingSlash(uri)}`);
};