Flaky test and info-table-row test selectors (#30525)

* selector things and addressing flakiness in secret-test

* replace and update the data test selectors for info-table-row

* fix a selector

* skip the replication test that borks it all, I have a follow up ticket and replication works still.

* remove the uneeded data-test-div thing

* missed one

* fix replication selector

* fix ci test failures

* pull in clicktrigger

* update transit test
This commit is contained in:
Angel Garbarino 2025-05-08 11:54:32 -06:00 committed by GitHub
parent 9832c90037
commit 27cbe2f168
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
52 changed files with 414 additions and 416 deletions

View File

@ -11,7 +11,7 @@
<p class="is-size-8 has-top-margin-xxs has-bottom-margin-s has-text-grey">Supported engines include databases, KV
version 2, and PKI.</p>
<SearchSelect
@id="secrets-engines-select"
@id="type-to-select-a-mount"
@options={{this.mountOptions}}
@selectLimit="1"
@disallowNewItems={{true}}

View File

@ -162,7 +162,7 @@
@icon={{if this.handleCreateEditRole.isRunning "loading"}}
type="submit"
disabled={{this.handleCreateEditRole.isRunning}}
data-test-secret-save
data-test-save
/>
<Hds::Button
@text="Cancel"

View File

@ -181,7 +181,7 @@
@icon={{if this.handleCreateConnection.isRunning "loading"}}
@text="Create database"
type="submit"
data-test-secret-save
data-test-save
/>
<Hds::Button
@text="Cancel"
@ -301,7 +301,7 @@
<div class="field is-grouped is-grouped-split is-fullwidth box is-bottomless">
<div class="field is-grouped">
<Hds::ButtonSet>
<Hds::Button @text="Save" type="submit" data-test-secret-save />
<Hds::Button @text="Save" type="submit" data-test-save />
<Hds::Button
@text="Cancel"
@color="secondary"

View File

@ -67,7 +67,7 @@
<div class="info-table-row">
<div class="column is-one-quarter info-table-row-edit">
<Input
data-test-secret-key={{true}}
data-test-secret-key="create"
@value={{secret.name}}
placeholder="key"
{{on "change" this.handleChange}}
@ -107,7 +107,7 @@
<div class="field is-grouped box is-fullwidth is-bottomless">
<Hds::ButtonSet>
<Hds::Button @text="Save" type="submit" disabled={{@buttonDisabled}} data-test-secret-save={{true}} />
<Hds::Button @text="Save" type="submit" disabled={{@buttonDisabled}} data-test-save />
{{#if @model.path}}
<Hds::Button
@text="Cancel"
@ -164,7 +164,7 @@
<div class="columns is-variable has-no-shadow">
<div class="column is-one-quarter">
<Input
data-test-secret-key={{true}}
data-test-secret-key="edit"
@value={{secret.name}}
placeholder="key"
{{on "change" this.handleChange}}
@ -202,12 +202,7 @@
<div class="field is-grouped is-grouped-split is-fullwidth box is-bottomless">
<div class="field is-grouped">
<Hds::ButtonSet>
<Hds::Button
@text="Save"
data-test-secret-save
type="submit"
disabled={{or @buttonDisabled this.validationErrorCount}}
/>
<Hds::Button @text="Save" data-test-save type="submit" disabled={{or @buttonDisabled this.validationErrorCount}} />
<Hds::Button
@text="Cancel"
@color="secondary"

View File

@ -94,7 +94,11 @@
@hasChevron={{false}}
data-test-popup-menu-trigger
/>
<dd.Interactive @route={{backend.backendConfigurationLink}} @model={{backend.id}} data-test-engine-config>
<dd.Interactive
@route={{backend.backendConfigurationLink}}
@model={{backend.id}}
data-test-popup-menu="view-configuration"
>
View configuration
</dd.Interactive>
{{#if (not-eq backend.type "cubbyhole")}}

View File

@ -5,9 +5,9 @@
{{#if (or (has-block) this.isVisible)}}
<div class="info-table-row" data-test-component="info-table-row" ...attributes>
{{! label section of the row }}
<div
class="column {{or @labelWidth 'is-one-quarter'}} {{if this.hasLabelOverflow 'label-overflow'}}"
data-test-label-div
{{did-insert this.calculateLabelOverflow}}
>
{{#if @label}}
@ -34,7 +34,8 @@
<Icon @name="minus" />
{{/if}}
</div>
<div class="column is-flex-center {{if @truncateValue 'is-two-thirds'}}" data-test-value-div={{@label}}>
{{! value section of the row }}
<div class="column is-flex-center {{if @truncateValue 'is-two-thirds'}}" data-test-row-value={{@label}}>
{{#if @addCopyButton}}
<Hds::Copy::Button
@text="Copy"

View File

@ -17,6 +17,7 @@ import {
import { setupApplicationTest } from 'vault/tests/helpers';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { selectChoose } from 'ember-power-select/test-support';
import { clickTrigger } from 'ember-power-select/test-support/helpers';
import { login } from 'vault/tests/helpers/auth/auth-helpers';
import mountSecrets from 'vault/tests/pages/settings/mount-secret-backend';
import clientsHandlers from 'vault/mirage/handlers/clients';
@ -344,7 +345,7 @@ module('Acceptance | landing page dashboard', function (hooks) {
await connectionPage.name(name);
await connectionPage.connectionUrl(`mongodb://127.0.0.1:4321/${name}`);
await connectionPage.toggleVerify();
await connectionPage.save();
await click(GENERAL.saveButton);
await connectionPage.enable();
return name;
};
@ -381,7 +382,7 @@ module('Acceptance | landing page dashboard', function (hooks) {
await runCmd([`write sys/mounts/kv1 type=kv`]);
await settled();
await visit('/vault/dashboard');
await click('[data-test-component="search-select"] .ember-basic-dropdown-trigger');
await clickTrigger('#type-to-select-a-mount');
assert
.dom('.ember-power-select-option')
.doesNotHaveTextContaining('kv1', 'dropdown does not show kv1 mount');

View File

@ -138,7 +138,7 @@ module('Acceptance | Enterprise | KMIP secrets', function (hooks) {
'redirects to configuration page after saving config'
);
assert.notOk(scopesPage.isEmpty, 'configuration page no longer renders empty state');
assert.dom('[data-test-value-div="Listen addrs"]').hasText(addr, 'renders the correct listen address');
assert.dom(GENERAL.infoRowValue('Listen addrs')).hasText(addr, 'renders the correct listen address');
});
test('it can revoke from the credentials show page', async function (assert) {

View File

@ -145,7 +145,7 @@ module('Acceptance | mfa-method', function (hooks) {
'Organization name': 'org_name',
}[label] || underscore(label);
const value = typeof model[key] === 'boolean' ? (model[key] ? 'Yes' : 'No') : model[key].toString();
assert.dom(`[data-test-value-div="${label}"]`).hasText(value, `${label} value renders`);
assert.dom(GENERAL.infoRowValue(label)).hasText(value, `${label} value renders`);
});
await click('.hds-breadcrumb a');
}

View File

@ -24,6 +24,7 @@ import {
ASSIGNMENT_DATA_RESPONSE,
} from 'vault/tests/helpers/oidc-config';
import { capabilitiesStub, overrideResponse } from 'vault/tests/helpers/stubs';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
const searchSelect = create(ss);
const flashMessage = create(fm);
@ -220,12 +221,12 @@ module('Acceptance | oidc-config clients', function (hooks) {
);
// assert default values in details view are correct
assert.dom('[data-test-value-div="Algorithm"]').hasText('RS256', 'defaults to RS526 algorithm');
assert.dom(GENERAL.infoRowValue('Algorithm')).hasText('RS256', 'defaults to RS526 algorithm');
assert
.dom('[data-test-value-div="Rotation period"]')
.dom(GENERAL.infoRowValue('Rotation period'))
.hasText('1 day', 'when toggled off rotation period defaults to 1 day');
assert
.dom('[data-test-value-div="Verification TTL"]')
.dom(GENERAL.infoRowValue('Verification TTL'))
.hasText('1 day', 'when toggled off verification ttl defaults to 1 day');
// rotate key
@ -398,22 +399,22 @@ module('Acceptance | oidc-config clients', function (hooks) {
'navigates to client details view after save'
);
// assert default values in details view are correct
assert.dom('[data-test-value-div="Assignment"]').hasText('allow_all', 'client allows all assignments');
assert.dom('[data-test-value-div="Type"]').hasText('confidential', 'type defaults to confidential');
assert.dom(GENERAL.infoRowValue('Assignment')).hasText('allow_all', 'client allows all assignments');
assert.dom(GENERAL.infoRowValue('Type')).hasText('confidential', 'type defaults to confidential');
assert
.dom('[data-test-value-div="Key"] a')
.dom(`${GENERAL.infoRowValue('Key')} a`)
.hasText('default', 'client uses default key and renders a link');
assert
.dom('[data-test-value-div="Client ID"] [data-test-copy-button]')
.dom(`${GENERAL.infoRowValue('Client ID')} [data-test-copy-button]`)
.exists('client ID exists and has copy button');
assert
.dom('[data-test-value-div="Client Secret"] [data-test-copy-button]')
.dom(`${GENERAL.infoRowValue('Client Secret')} [data-test-copy-button]`)
.exists('client secret exists and has copy button');
assert
.dom('[data-test-value-div="ID Token TTL"]')
.dom(GENERAL.infoRowValue('ID Token TTL'))
.hasText('1 day', 'ID token ttl toggled off sets default of 24h');
assert
.dom('[data-test-value-div="Access Token TTL"]')
.dom(GENERAL.infoRowValue('Access Token TTL'))
.hasText('1 day', 'access token ttl toggled off sets default of 24h');
// edit client
@ -452,9 +453,9 @@ module('Acceptance | oidc-config clients', function (hooks) {
'vault.cluster.access.oidc.clients.client.details',
'navigates back to details on update'
);
assert.dom('[data-test-value-div="Redirect URI"]').hasText('some-url.com', 'shows updated attribute');
assert.dom(GENERAL.infoRowValue('Redirect URI')).hasText('some-url.com', 'shows updated attribute');
assert
.dom('[data-test-value-div="Assignment"]')
.dom(GENERAL.infoRowValue('Assignment'))
.hasText('assignment-inline', 'updated to limited assignment');
// edit back to allow_all
@ -463,7 +464,7 @@ module('Acceptance | oidc-config clients', function (hooks) {
await click('[data-test-oidc-radio="allow-all"]');
await click(SELECTORS.clientSaveButton);
assert
.dom('[data-test-value-div="Assignment"]')
.dom(GENERAL.infoRowValue('Assignment'))
.hasText('allow_all', 'client updated to allow all assignments');
// create another client
@ -534,8 +535,8 @@ module('Acceptance | oidc-config clients', function (hooks) {
);
// assert default values in assignment details view are correct
assert.dom('[data-test-value-div="Name"]').hasText('test-assignment');
assert.dom('[data-test-value-div="Entities"]').hasText('test-entity', 'shows the entity name.');
assert.dom(GENERAL.infoRowValue('Name')).hasText('test-assignment');
assert.dom(GENERAL.infoRowValue('Entities')).hasText('test-entity', 'shows the entity name.');
// edit assignment
await click(SELECTORS.assignmentEditButton);
@ -555,10 +556,8 @@ module('Acceptance | oidc-config clients', function (hooks) {
'renders success flash upon updating the assignment'
);
assert
.dom('[data-test-value-div="Entities"]')
.hasText('test-entity', 'it still shows the entity name.');
assert.dom('[data-test-value-div="Groups"]').hasText('test-group', 'shows updated group name id.');
assert.dom(GENERAL.infoRowValue('Entities')).hasText('test-entity', 'it still shows the entity name.');
assert.dom(GENERAL.infoRowValue('Groups')).hasText('test-group', 'shows updated group name id.');
// delete the assignment
await click(SELECTORS.assignmentDeleteButton);

View File

@ -12,6 +12,7 @@ import { login } from 'vault/tests/helpers/auth/auth-helpers';
import { create } from 'ember-cli-page-object';
import { selectChoose } from 'ember-power-select/test-support';
import { clickTrigger } from 'ember-power-select/test-support/helpers';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
import ss from 'vault/tests/pages/components/search-select';
import fm from 'vault/tests/pages/components/flash-message';
import {
@ -190,9 +191,9 @@ module('Acceptance | oidc-config providers and scopes', function (hooks) {
'navigates to scope detail view after save'
);
assert.dom(SELECTORS.scopeDetailsTab).hasClass('active', 'scope details tab is active');
assert.dom('[data-test-value-div="Name"]').hasText('test-scope', 'has correct created name');
assert.dom(GENERAL.infoRowValue('Name')).hasText('test-scope', 'has correct created name');
assert
.dom('[data-test-value-div="Description"]')
.dom(GENERAL.infoRowValue('Description'))
.hasText('this is a test', 'has correct created description');
// edit scope
@ -215,7 +216,7 @@ module('Acceptance | oidc-config providers and scopes', function (hooks) {
'navigates back to scope details on update'
);
assert
.dom('[data-test-value-div="Description"]')
.dom(GENERAL.infoRowValue('Description'))
.hasText('this is an edit test', 'has correct edited description');
// create a provider using test-scope
@ -244,12 +245,12 @@ module('Acceptance | oidc-config providers and scopes', function (hooks) {
);
// assert default values in details view are correct
assert.dom('[data-test-value-div="Issuer URL"]').hasTextContaining('http://', 'issuer includes scheme');
assert.dom(GENERAL.infoRowValue('Issuer URL')).hasTextContaining('http://', 'issuer includes scheme');
assert
.dom('[data-test-value-div="Issuer URL"]')
.dom(GENERAL.infoRowValue('Issuer URL'))
.hasTextContaining('identity/oidc/provider/test', 'issuer path populates correctly');
assert
.dom('[data-test-value-div="Scopes"] a')
.dom(`${GENERAL.infoRowValue('Scopes')} a`)
.hasAttribute('href', '/ui/vault/access/oidc/scopes/test-scope/details', 'lists scopes as links');
// check provider's application list view

View File

@ -395,7 +395,7 @@ module('Acceptance | pki workflow', function (hooks) {
await click(GENERAL.secretTab('Issuers'));
await click(GENERAL.menuTrigger);
await click(PKI_ISSUER_LIST.issuerPopupDetails);
const issuerId = find(PKI_ISSUER_DETAILS.valueByName('Issuer ID')).innerText;
const issuerId = find(GENERAL.infoRowValue('Issuer ID')).innerText;
const pki_issuer_denied_policy = `
path "${this.mountPath}/*" {
capabilities = ["create", "read", "update", "delete", "list"]
@ -428,11 +428,12 @@ module('Acceptance | pki workflow', function (hooks) {
`/vault/secrets/${this.mountPath}/pki/issuers/my-issuer/details`
);
assert.dom(GENERAL.title).hasText('View Issuer Certificate');
['Certificate', 'CA Chain', 'Common name', 'Issuer name', 'Issuer ID', 'Default key ID'].forEach(
(label) => {
assert
.dom(`${PKI_ISSUER_DETAILS.defaultGroup} ${PKI_ISSUER_DETAILS.valueByName(label)}`)
.exists({ count: 1 }, `${label} value rendered`);
.dom(`${PKI_ISSUER_DETAILS.defaultGroup} ${GENERAL.infoRowValue(label)}`)
.exists(`${label} value rendered`);
}
);
assert
@ -448,7 +449,7 @@ module('Acceptance | pki workflow', function (hooks) {
await click(GENERAL.menuTrigger);
await click(PKI_ISSUER_LIST.issuerPopupDetails);
const issuerId = find(PKI_ISSUER_DETAILS.valueByName('Issuer ID')).innerText;
const issuerId = find(GENERAL.infoRowValue('Issuer ID')).innerText;
assert.strictEqual(
currentURL(),
`/vault/secrets/${this.mountPath}/pki/issuers/${issuerId}/details`,
@ -542,7 +543,7 @@ module('Acceptance | pki workflow', function (hooks) {
await click(PKI_CONFIG_EDIT.saveButton);
assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration`);
assert
.dom('[data-test-value-div="CRL building"]')
.dom(GENERAL.infoRowValue('CRL building'))
.hasText('Disabled', 'Successfully saves config with partial permission');
});
});

View File

@ -9,14 +9,15 @@ import { setupMirage } from 'ember-cli-mirage/test-support';
import { login } from 'vault/tests/helpers/auth/auth-helpers';
import replicationHandlers from 'vault/mirage/handlers/replication';
import { click } from '@ember/test-helpers';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
const SELECTORS = {
navReplication: '[data-test-sidebar-nav-link="Replication"]',
navPerformance: '[data-test-sidebar-nav-link="Performance"]',
navDR: '[data-test-sidebar-nav-link="Disaster Recovery"]',
title: '[data-test-replication-title]',
primaryCluster: '[data-test-value-div="primary_cluster_addr"]',
replicationSet: '[data-test-row-value="Replication set"]',
primaryCluster: `${GENERAL.infoRowValue('primary_cluster_addr')}`,
replicationSet: `${GENERAL.infoRowValue('Replication set')}`,
knownSecondariesTitle: '.known-secondaries-card h3',
};
module('Acceptance | Enterprise | replication navigation', function (hooks) {

View File

@ -34,7 +34,7 @@ const newConnection = async (
await connectionPage.name(name);
await connectionPage.connectionUrl(connectionUrl);
await connectionPage.toggleVerify();
await connectionPage.save();
await click(GENERAL.saveButton);
await connectionPage.enable();
return name;
};
@ -42,8 +42,8 @@ const newConnection = async (
const navToConnection = async (backend, connection) => {
await visit('/vault/secrets');
await click(SES.secretsBackendLink(backend));
await click('[data-test-secret-list-tab="Connections"]');
await click(`[data-test-secret-link="${connection}"]`);
await click(GENERAL.secretTab('Connections'));
await click(SES.secretLink(connection));
return;
};
@ -56,14 +56,14 @@ const connectionTests = [
url: 'http://127.0.0.1:9200',
assertCount: 9,
requiredFields: async (assert, name) => {
assert.dom('[data-test-input="username"]').exists(`Username field exists for ${name}`);
assert.dom('[data-test-input="password"]').exists(`Password field exists for ${name}`);
assert.dom('[data-test-input="ca_cert"]').exists(`CA certificate field exists for ${name}`);
assert.dom('[data-test-input="ca_path"]').exists(`CA path field exists for ${name}`);
assert.dom('[data-test-input="client_cert"]').exists(`Client certificate field exists for ${name}`);
assert.dom('[data-test-input="client_key"]').exists(`Client key field exists for ${name}`);
assert.dom('[data-test-input="tls_server_name"]').exists(`TLS server name field exists for ${name}`);
assert.dom('[data-test-input="insecure"]').exists(`Insecure checkbox exists for ${name}`);
assert.dom(GENERAL.inputByAttr('username')).exists(`Username field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('password')).exists(`Password field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('ca_cert')).exists(`CA certificate field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('ca_path')).exists(`CA path field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('client_cert')).exists(`Client certificate field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('client_key')).exists(`Client key field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('tls_server_name')).exists(`TLS server name field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('insecure')).exists(`Insecure checkbox exists for ${name}`);
assert
.dom('[data-test-toggle-input="show-username_template"]')
.exists(`Username template toggle exists for ${name}`);
@ -75,12 +75,12 @@ const connectionTests = [
url: `mongodb://127.0.0.1:4321/test`,
assertCount: 5,
requiredFields: async (assert, name) => {
assert.dom('[data-test-input="username"]').exists(`Username field exists for ${name}`);
assert.dom('[data-test-input="password"]').exists(`Password field exists for ${name}`);
assert.dom('[data-test-input="write_concern"]').exists(`Write concern field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('username')).exists(`Username field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('password')).exists(`Password field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('write_concern')).exists(`Write concern field exists for ${name}`);
assert.dom('[data-test-toggle-group="TLS options"]').exists('TLS options toggle exists');
assert
.dom('[data-test-input="root_rotation_statements"]')
.dom(GENERAL.inputByAttr('root_rotation_statements'))
.exists(`Root rotation statements exists for ${name}`);
},
},
@ -90,19 +90,19 @@ const connectionTests = [
url: `mssql://127.0.0.1:4321/test`,
assertCount: 6,
requiredFields: async (assert, name) => {
assert.dom('[data-test-input="username"]').exists(`Username field exists for ${name}`);
assert.dom('[data-test-input="password"]').exists(`Password field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('username')).exists(`Username field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('password')).exists(`Password field exists for ${name}`);
assert
.dom('[data-test-input="max_open_connections"]')
.dom(GENERAL.inputByAttr('max_open_connections'))
.exists(`Max open connections exists for ${name}`);
assert
.dom('[data-test-input="max_idle_connections"]')
.dom(GENERAL.inputByAttr('max_idle_connections'))
.exists(`Max idle connections exists for ${name}`);
assert
.dom('[data-test-input="max_connection_lifetime"]')
.dom(GENERAL.inputByAttr('max_connection_lifetime'))
.exists(`Max connection lifetime exists for ${name}`);
assert
.dom('[data-test-input="root_rotation_statements"]')
.dom(GENERAL.inputByAttr('root_rotation_statements'))
.exists(`Root rotation statements exists for ${name}`);
},
},
@ -112,20 +112,20 @@ const connectionTests = [
url: `{{username}}:{{password}}@tcp(127.0.0.1:3306)/test`,
assertCount: 7,
requiredFields: async (assert, name) => {
assert.dom('[data-test-input="username"]').exists(`Username field exists for ${name}`);
assert.dom('[data-test-input="password"]').exists(`Password field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('username')).exists(`Username field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('password')).exists(`Password field exists for ${name}`);
assert
.dom('[data-test-input="max_open_connections"]')
.dom(GENERAL.inputByAttr('max_open_connections'))
.exists(`Max open connections exists for ${name}`);
assert
.dom('[data-test-input="max_idle_connections"]')
.dom(GENERAL.inputByAttr('max_idle_connections'))
.exists(`Max idle connections exists for ${name}`);
assert
.dom('[data-test-input="max_connection_lifetime"]')
.dom(GENERAL.inputByAttr('max_connection_lifetime'))
.exists(`Max connection lifetime exists for ${name}`);
assert.dom('[data-test-toggle-group="TLS options"]').exists('TLS options toggle exists');
assert
.dom('[data-test-input="root_rotation_statements"]')
.dom(GENERAL.inputByAttr('root_rotation_statements'))
.exists(`Root rotation statements exists for ${name}`);
},
},
@ -135,20 +135,20 @@ const connectionTests = [
url: `{{username}}:{{password}}@tcp(127.0.0.1:3306)/test`,
assertCount: 7,
requiredFields: async (assert, name) => {
assert.dom('[data-test-input="username"]').exists(`Username field exists for ${name}`);
assert.dom('[data-test-input="password"]').exists(`Password field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('username')).exists(`Username field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('password')).exists(`Password field exists for ${name}`);
assert
.dom('[data-test-input="max_open_connections"]')
.dom(GENERAL.inputByAttr('max_open_connections'))
.exists(`Max open connections exists for ${name}`);
assert
.dom('[data-test-input="max_idle_connections"]')
.dom(GENERAL.inputByAttr('max_idle_connections'))
.exists(`Max idle connections exists for ${name}`);
assert
.dom('[data-test-input="max_connection_lifetime"]')
.dom(GENERAL.inputByAttr('max_connection_lifetime'))
.exists(`Max connection lifetime exists for ${name}`);
assert.dom('[data-test-toggle-group="TLS options"]').exists('TLS options toggle exists');
assert
.dom('[data-test-input="root_rotation_statements"]')
.dom(GENERAL.inputByAttr('root_rotation_statements'))
.exists(`Root rotation statements exists for ${name}`);
},
},
@ -158,20 +158,20 @@ const connectionTests = [
url: `{{username}}:{{password}}@tcp(127.0.0.1:3306)/test`,
assertCount: 7,
requiredFields: async (assert, name) => {
assert.dom('[data-test-input="username"]').exists(`Username field exists for ${name}`);
assert.dom('[data-test-input="password"]').exists(`Password field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('username')).exists(`Username field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('password')).exists(`Password field exists for ${name}`);
assert
.dom('[data-test-input="max_open_connections"]')
.dom(GENERAL.inputByAttr('max_open_connections'))
.exists(`Max open connections exists for ${name}`);
assert
.dom('[data-test-input="max_idle_connections"]')
.dom(GENERAL.inputByAttr('max_idle_connections'))
.exists(`Max idle connections exists for ${name}`);
assert
.dom('[data-test-input="max_connection_lifetime"]')
.dom(GENERAL.inputByAttr('max_connection_lifetime'))
.exists(`Max connection lifetime exists for ${name}`);
assert.dom('[data-test-toggle-group="TLS options"]').exists('TLS options toggle exists');
assert
.dom('[data-test-input="root_rotation_statements"]')
.dom(GENERAL.inputByAttr('root_rotation_statements'))
.exists(`Root rotation statements exists for ${name}`);
},
},
@ -181,20 +181,20 @@ const connectionTests = [
url: `{{username}}:{{password}}@tcp(127.0.0.1:3306)/test`,
assertCount: 7,
requiredFields: async (assert, name) => {
assert.dom('[data-test-input="username"]').exists(`Username field exists for ${name}`);
assert.dom('[data-test-input="password"]').exists(`Password field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('username')).exists(`Username field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('password')).exists(`Password field exists for ${name}`);
assert
.dom('[data-test-input="max_open_connections"]')
.dom(GENERAL.inputByAttr('max_open_connections'))
.exists(`Max open connections exists for ${name}`);
assert
.dom('[data-test-input="max_idle_connections"]')
.dom(GENERAL.inputByAttr('max_idle_connections'))
.exists(`Max idle connections exists for ${name}`);
assert
.dom('[data-test-input="max_connection_lifetime"]')
.dom(GENERAL.inputByAttr('max_connection_lifetime'))
.exists(`Max connection lifetime exists for ${name}`);
assert.dom('[data-test-toggle-group="TLS options"]').exists('TLS options toggle exists');
assert
.dom('[data-test-input="root_rotation_statements"]')
.dom(GENERAL.inputByAttr('root_rotation_statements'))
.exists(`Root rotation statements exists for ${name}`);
},
},
@ -206,19 +206,19 @@ const connectionTests = [
password: 'password',
assertCount: 7,
requiredFields: async (assert, name) => {
assert.dom('[data-test-input="username"]').exists(`Username field exists for ${name}`);
assert.dom('[data-test-input="password"]').exists(`Password field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('username')).exists(`Username field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('password')).exists(`Password field exists for ${name}`);
assert
.dom('[data-test-input="max_open_connections"]')
.dom(GENERAL.inputByAttr('max_open_connections'))
.exists(`Max open connections exists for ${name}`);
assert
.dom('[data-test-input="max_idle_connections"]')
.dom(GENERAL.inputByAttr('max_idle_connections'))
.exists(`Max idle connections exists for ${name}`);
assert
.dom('[data-test-input="max_connection_lifetime"]')
.dom(GENERAL.inputByAttr('max_connection_lifetime'))
.exists(`Max connection lifetime exists for ${name}`);
assert
.dom('[data-test-input="root_rotation_statements"]')
.dom(GENERAL.inputByAttr('root_rotation_statements'))
.exists(`Root rotation statements exists for ${name}`);
assert
.dom('[data-test-toggle-input="show-username_template"]')
@ -289,14 +289,13 @@ module('Acceptance | secrets/database/*', function (hooks) {
await connectionPage.password(testCase.password);
}
testCase.requiredFields(assert, testCase.plugin);
assert.dom('[data-test-input="verify_connection"]').isChecked('verify is checked');
assert.dom(GENERAL.inputByAttr('verify_connection')).isChecked('verify is checked');
await connectionPage.toggleVerify();
assert.dom('[data-test-input="verify_connection"]').isNotChecked('verify is unchecked');
assert.dom(GENERAL.inputByAttr('verify_connection')).isNotChecked('verify is unchecked');
assert
.dom('[data-test-database-oracle-alert]')
.doesNotExist('does not show oracle alert for non-oracle plugins');
await connectionPage.save();
await settled();
await click(GENERAL.saveButton);
assert
.dom('[data-test-db-connection-modal-title]')
.hasText('Rotate your root credentials?', 'Modal appears asking to rotate root credentials');
@ -317,11 +316,11 @@ module('Acceptance | secrets/database/*', function (hooks) {
);
assert.dom(`[data-test-input="name"]`).hasAttribute('readonly');
assert.dom(`[data-test-input="plugin_name"]`).hasAttribute('readonly');
assert.dom('[data-test-input="password"]').doesNotExist('Password is not displayed on edit form');
assert.dom(GENERAL.inputByAttr('password')).doesNotExist('Password is not displayed on edit form');
assert.dom('[data-test-toggle-input="show-password"]').exists('Update password toggle exists');
assert.dom('[data-test-input="verify_connection"]').isNotChecked('verify is still unchecked');
await connectionPage.save();
assert.dom(GENERAL.inputByAttr('verify_connection')).isNotChecked('verify is still unchecked');
await click(GENERAL.saveButton);
assert.strictEqual(currentURL(), `/vault/secrets/${backend}/show/${testCase.name}`);
// click "Add Role"
await connectionPage.addRole();
@ -351,19 +350,19 @@ module('Acceptance | secrets/database/*', function (hooks) {
plugin: 'vault-plugin-database-oracle',
url: `{{username}}/{{password}}@localhost:1521/OraDoc.localhost`,
requiredFields: async (assert, name) => {
assert.dom('[data-test-input="username"]').exists(`Username field exists for ${name}`);
assert.dom('[data-test-input="password"]').exists(`Password field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('username')).exists(`Username field exists for ${name}`);
assert.dom(GENERAL.inputByAttr('password')).exists(`Password field exists for ${name}`);
assert
.dom('[data-test-input="max_open_connections"]')
.dom(GENERAL.inputByAttr('max_open_connections'))
.exists(`Max open connections exists for ${name}`);
assert
.dom('[data-test-input="max_idle_connections"]')
.dom(GENERAL.inputByAttr('max_idle_connections'))
.exists(`Max idle connections exists for ${name}`);
assert
.dom('[data-test-input="max_connection_lifetime"]')
.dom(GENERAL.inputByAttr('max_connection_lifetime'))
.exists(`Max connection lifetime exists for ${name}`);
assert
.dom('[data-test-input="root_rotation_statements"]')
.dom(GENERAL.inputByAttr('root_rotation_statements'))
.exists(`Root rotation statements exists for ${name}`);
assert
.dom('[data-test-database-oracle-alert]')
@ -430,7 +429,7 @@ module('Acceptance | secrets/database/*', function (hooks) {
await connectionPage.edit();
assert
.dom('[data-test-input="connection_url"]')
.dom(GENERAL.inputByAttr('connection_url'))
.hasValue(decoded, 'connection_url is decoded when editing');
});
@ -465,8 +464,7 @@ module('Acceptance | secrets/database/*', function (hooks) {
});
// uncheck verify for the save step to work
await connectionPage.toggleVerify();
await connectionPage.save();
await settled();
await click(GENERAL.saveButton);
assert
.dom('[data-test-db-connection-modal-title]')
.hasText('Rotate your root credentials?', 'Modal appears asking to ');
@ -584,7 +582,7 @@ module('Acceptance | secrets/database/*', function (hooks) {
.exists({ count: 2 }, 'Two empty states exist after a database is selected');
await rolePage.roleType('static');
assert.dom('[data-test-component="empty-state"]').doesNotExist('Empty states go away');
assert.dom('[data-test-input="username"]').exists('Username field appears for static role');
assert.dom(GENERAL.inputByAttr('username')).exists('Username field appears for static role');
assert
.dom('[data-test-toggle-input="Rotation period"]')
.exists('Rotation period field appears for static role');

View File

@ -15,6 +15,7 @@ import { setupApplicationTest } from 'vault/tests/helpers';
import { login } from 'vault/tests/helpers/auth/auth-helpers';
import flashMessage from 'vault/tests/pages/components/flash-message';
import { deleteEngineCmd, mountEngineCmd, runCmd } from 'vault/tests/helpers/commands';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
import { SECRET_ENGINE_SELECTORS as SES } from 'vault/tests/helpers/secret-engine/secret-engine-selectors';
const flash = create(flashMessage);
@ -23,9 +24,6 @@ const PAGE = {
// GENERIC
emptyStateTitle: '[data-test-empty-state-title]',
infoRow: '[data-test-component="info-table-row"]',
infoRowLabel: (label) => `[data-test-row-label="${label}"]`,
infoRowValue: (label) => `[data-test-row-value="${label}"]`,
infoRowValueDiv: (label) => `[data-test-value-div="${label}"]`,
// CONNECTIONS
rotateModal: '[data-test-db-connection-modal-title]',
confirmRotate: '[data-test-enable-rotate-connection]',
@ -39,18 +37,16 @@ const PAGE = {
};
const FORM = {
inputByAttr: (attr) => `[data-test-input="${attr}"]`,
creationStatement: (idx = 0) =>
`[data-test-input="creation_statements"] [data-test-string-list-input="${idx}"]`,
saveBtn: '[data-test-secret-save]',
};
async function fillOutConnection(name) {
await fillIn(FORM.inputByAttr('name'), name);
await fillIn(FORM.inputByAttr('plugin_name'), 'mysql-database-plugin');
await fillIn(FORM.inputByAttr('connection_url'), '{{username}}:{{password}}@tcp(127.0.0.1:33060)/');
await fillIn(FORM.inputByAttr('username'), 'admin');
await fillIn(FORM.inputByAttr('password'), 'very-secure');
await fillIn(GENERAL.inputByAttr('name'), name);
await fillIn(GENERAL.inputByAttr('plugin_name'), 'mysql-database-plugin');
await fillIn(GENERAL.inputByAttr('connection_url'), '{{username}}:{{password}}@tcp(127.0.0.1:33060)/');
await fillIn(GENERAL.inputByAttr('username'), 'admin');
await fillIn(GENERAL.inputByAttr('password'), 'very-secure');
}
/**
@ -108,7 +104,7 @@ module('Acceptance | database workflow', function (hooks) {
// fill in connection details
await fillOutConnection(`connect-${this.backend}`);
await click(FORM.saveBtn);
await click(GENERAL.saveButton);
assert.dom(PAGE.rotateModal).hasText('Rotate your root credentials?', 'rotate modal is shown');
await click(PAGE.confirmRotate);
@ -120,12 +116,8 @@ module('Acceptance | database workflow', function (hooks) {
);
assert.dom(PAGE.infoRow).exists({ count: this.expectedRows.length }, 'correct number of rows');
this.expectedRows.forEach(({ label, value }) => {
const valueSelector =
label === 'Rotate static roles immediately'
? PAGE.infoRowValueDiv(label)
: PAGE.infoRowValue(label);
assert.dom(PAGE.infoRowLabel(label)).hasText(label, `Label for ${label} is correct`);
assert.dom(valueSelector).hasText(value, `Value for ${label} is correct`);
assert.dom(GENERAL.infoRowLabel(label)).hasText(label, `Label for ${label} is correct`);
assert.dom(GENERAL.infoRowValue(label)).hasText(value, `Value for ${label} is correct`);
});
});
test('create without rotate', async function (assert) {
@ -145,7 +137,7 @@ module('Acceptance | database workflow', function (hooks) {
// fill in connection details
await fillOutConnection(`connect-${this.backend}`);
await click(FORM.saveBtn);
await click(GENERAL.saveButton);
assert.dom(PAGE.rotateModal).hasText('Rotate your root credentials?', 'rotate modal is shown');
await click(PAGE.skipRotate);
@ -157,12 +149,8 @@ module('Acceptance | database workflow', function (hooks) {
);
assert.dom(PAGE.infoRow).exists({ count: this.expectedRows.length }, 'correct number of rows');
this.expectedRows.forEach(({ label, value }) => {
const valueSelector =
label === 'Rotate static roles immediately'
? PAGE.infoRowValueDiv(label)
: PAGE.infoRowValue(label);
assert.dom(PAGE.infoRowLabel(label)).hasText(label, `Label for ${label} is correct`);
assert.dom(valueSelector).hasText(value, `Value for ${label} is correct`);
assert.dom(GENERAL.infoRowLabel(label)).hasText(label, `Label for ${label} is correct`);
assert.dom(GENERAL.infoRowValue(label)).hasText(value, `Value for ${label} is correct`);
});
});
test('create failure', async function (assert) {
@ -183,14 +171,14 @@ module('Acceptance | database workflow', function (hooks) {
// fill in connection details
await fillOutConnection(`bad-connection`);
await click(FORM.saveBtn);
await click(GENERAL.saveButton);
assert.strictEqual(
flash.latestMessage,
`error creating database object: error verifying - ping: Error 1045 (28000): Access denied for user 'admin'@'192.168.65.1' (using password: YES)`,
'shows the error message from API'
);
await fillIn(FORM.inputByAttr('name'), `connect-${this.backend}`);
await click(FORM.saveBtn);
await fillIn(GENERAL.inputByAttr('name'), `connect-${this.backend}`);
await click(GENERAL.saveButton);
assert.dom(PAGE.rotateModal).hasText('Rotate your root credentials?', 'rotate modal is shown');
await click(PAGE.confirmRotate);
@ -201,12 +189,8 @@ module('Acceptance | database workflow', function (hooks) {
);
assert.dom(PAGE.infoRow).exists({ count: this.expectedRows.length }, 'correct number of rows');
this.expectedRows.forEach(({ label, value }) => {
const valueSelector =
label === 'Rotate static roles immediately'
? PAGE.infoRowValueDiv(label)
: PAGE.infoRowValue(label);
assert.dom(PAGE.infoRowLabel(label)).hasText(label, `Label for ${label} is correct`);
assert.dom(valueSelector).hasText(value, `Value for ${label} is correct`);
assert.dom(GENERAL.infoRowLabel(label)).hasText(label, `Label for ${label} is correct`);
assert.dom(GENERAL.infoRowValue(label)).hasText(value, `Value for ${label} is correct`);
});
});
@ -222,7 +206,7 @@ module('Acceptance | database workflow', function (hooks) {
// fill in connection details
await fillOutConnection(`fail-rotate`);
await click(FORM.saveBtn);
await click(GENERAL.saveButton);
assert.dom(PAGE.rotateModal).hasText('Rotate your root credentials?', 'rotate modal is shown');
await click(PAGE.confirmRotate);
@ -243,7 +227,7 @@ module('Acceptance | database workflow', function (hooks) {
this.connection = `connect-${this.backend}`;
await visit(`/vault/secrets/${this.backend}/create`);
await fillOutConnection(this.connection);
await click(FORM.saveBtn);
await click(GENERAL.saveButton);
await visit(`/vault/secrets/${this.backend}/show/${this.connection}`);
});
@ -263,10 +247,10 @@ module('Acceptance | database workflow', function (hooks) {
.dom(`${PAGE.statementsSection} ${PAGE.emptyStateTitle}`)
.hasText('No role type selected', 'statements section shows empty state before selecting role type');
await fillIn(FORM.inputByAttr('name'), roleName);
await fillIn(GENERAL.inputByAttr('name'), roleName);
assert.dom('[data-test-selected-option]').hasText(this.connection, 'Connection is selected by default');
await fillIn(FORM.inputByAttr('type'), 'dynamic');
await fillIn(GENERAL.inputByAttr('type'), 'dynamic');
assert
.dom(`${PAGE.roleSettingsSection} ${PAGE.emptyStateTitle}`)
.doesNotExist('roles section no longer has empty state');
@ -278,7 +262,7 @@ module('Acceptance | database workflow', function (hooks) {
await fillIn(FORM.creationStatement(), `GRANT SELECT ON *.* TO '{{name}}'@'%'`);
await click(`[data-test-string-list-row="0"] [data-test-string-list-button="add"]`);
await fillIn(FORM.creationStatement(1), `GRANT CREATE ON *.* TO '{{name}}'@'%'`);
await click(FORM.saveBtn);
await click(GENERAL.saveButton);
// DETAILS
assert.strictEqual(
currentURL(),
@ -298,10 +282,8 @@ module('Acceptance | database workflow', function (hooks) {
},
{ label: 'Revocation statements', value: 'Default' },
].forEach(({ label, value }) => {
const valueSelector =
label === 'Creation statements' ? PAGE.infoRowValueDiv(label) : PAGE.infoRowValue(label);
assert.dom(PAGE.infoRowLabel(label)).hasText(label, `Label for ${label} is correct`);
assert.dom(valueSelector).hasText(value, `Value for ${label} is correct`);
assert.dom(GENERAL.infoRowLabel(label)).hasText(label, `Label for ${label} is correct`);
assert.dom(GENERAL.infoRowValue(label)).hasText(value, `Value for ${label} is correct`);
});
// EDIT
await click(PAGE.editRole);
@ -311,18 +293,18 @@ module('Acceptance | database workflow', function (hooks) {
'Takes you to edit page for role'
);
// TODO: these should be readonly not disabled
assert.dom(FORM.inputByAttr('name')).isDisabled('Name is read-only');
assert.dom(FORM.inputByAttr('database')).isDisabled('Database is read-only');
assert.dom(FORM.inputByAttr('type')).isDisabled('Type is read-only');
assert.dom(GENERAL.inputByAttr('name')).isDisabled('Name is read-only');
assert.dom(GENERAL.inputByAttr('database')).isDisabled('Database is read-only');
assert.dom(GENERAL.inputByAttr('type')).isDisabled('Type is read-only');
await fillIn('[data-test-ttl-value="Generated credentialss Time-to-Live (TTL)"]', '2');
await click(FORM.saveBtn);
await click(GENERAL.saveButton);
assert.strictEqual(
currentURL(),
`/vault/secrets/${this.backend}/show/role/${roleName}`,
'Takes you to details page for role after save'
);
assert
.dom(PAGE.infoRowValue('Generated credentialss Time-to-Live (TTL)'))
.dom(GENERAL.infoRowValue('Generated credentialss Time-to-Live (TTL)'))
.hasText('2 hours', 'Shows updated TTL');
// CREDENTIALS
@ -336,23 +318,27 @@ module('Acceptance | database workflow', function (hooks) {
.dom('[data-test-credentials-warning]')
.exists('shows warning about credentials only being available once');
assert
.dom(`[data-test-value-div="Username"] [data-test-masked-input]`)
.dom(`${GENERAL.infoRowValue('Username')} [data-test-masked-input]`)
.hasText('***********', 'Username is masked');
await click(`[data-test-value-div="Username"] [data-test-button="toggle-masked"]`);
await click(`${GENERAL.infoRowValue('Username')} ${GENERAL.testButton('toggle-masked')}`);
assert
.dom(`[data-test-value-div="Username"] [data-test-masked-input]`)
.dom(`${GENERAL.infoRowValue('Username')} [data-test-masked-input]`)
.hasText('generated-username', 'Username is generated');
assert
.dom(`[data-test-value-div="Password"] [data-test-masked-input]`)
.dom(`${GENERAL.infoRowValue('Password')} [data-test-masked-input]`)
.hasText('***********', 'Password is masked');
await click(`[data-test-value-div="Password"] [data-test-button="toggle-masked"]`);
await click(`${GENERAL.infoRowValue('Password')} ${GENERAL.testButton('toggle-masked')}`);
assert
.dom(`[data-test-value-div="Password"] [data-test-masked-input]`)
.dom(`${GENERAL.infoRowValue('Password')} [data-test-masked-input]`)
.hasText('generated-password', 'Password is generated');
assert.dom(PAGE.infoRowValue('Lease Duration')).hasText('3600', 'shows lease duration from response');
assert
.dom(PAGE.infoRowValue('Lease ID'))
.dom(GENERAL.infoRowValue('Lease Duration'))
.hasText('3600', 'shows lease duration from response');
assert
.dom(GENERAL.infoRowValue('Lease ID'))
.hasText(`database/creds/${roleName}/abcd`, 'shows lease ID from response');
});
});
@ -366,7 +352,7 @@ module('Acceptance | database workflow', function (hooks) {
if (toggleRotateOff) {
await click('[data-test-toggle-input="toggle-skip_static_role_rotation_import"]');
}
await click(FORM.saveBtn);
await click(GENERAL.saveButton);
await visit(`/vault/secrets/${this.backend}/show/${this.connection}`);
};
});
@ -382,9 +368,9 @@ module('Acceptance | database workflow', function (hooks) {
'Takes you to create role page'
);
await fillIn(FORM.inputByAttr('name'), roleName);
await fillIn(GENERAL.inputByAttr('name'), roleName);
await fillIn(FORM.inputByAttr('type'), 'static');
await fillIn(GENERAL.inputByAttr('type'), 'static');
assert
.dom('[data-test-toggle-subtext]')
@ -402,9 +388,9 @@ module('Acceptance | database workflow', function (hooks) {
'Takes you to create role page'
);
await fillIn(FORM.inputByAttr('name'), roleName);
await fillIn(GENERAL.inputByAttr('name'), roleName);
await fillIn(FORM.inputByAttr('type'), 'static');
await fillIn(GENERAL.inputByAttr('type'), 'static');
assert
.dom('[data-test-toggle-subtext]')

View File

@ -21,11 +21,11 @@ module('Acceptance | secret-engine list view', function (hooks) {
const createSecret = async (path, key, value, enginePath) => {
await click(SES.createSecretLink);
await fillIn('[data-test-secret-path]', path);
await fillIn(SES.secretPath('create'), path);
await fillIn('[data-test-secret-key]', key);
await fillIn(SES.secretKey('create'), key);
await fillIn(GENERAL.inputByAttr(key), value);
await click('[data-test-secret-save]');
await click(GENERAL.saveButton);
await click(SES.crumb(enginePath));
};
@ -52,6 +52,8 @@ module('Acceptance | secret-engine list view', function (hooks) {
'redirects to the backends list page'
);
assert.dom(SES.secretsBackendLink(enginePath)).doesNotExist('does not show the disabled engine');
// remove the filter as it may cause issues in the next tests
await click(GENERAL.searchSelect.removeSelected);
});
test('it adds disabled css styling to unsupported secret engines', async function (assert) {

View File

@ -8,7 +8,6 @@ import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { v4 as uuidv4 } from 'uuid';
import editPage from 'vault/tests/pages/secrets/backend/kv/edit-secret';
import showPage from 'vault/tests/pages/secrets/backend/kv/show';
import listPage from 'vault/tests/pages/secrets/backend/list';
@ -341,7 +340,7 @@ module('Acceptance | secrets/secret/create, read, delete', function (hooks) {
await fillIn(SS.secretPath('create'), secretPath);
await click(GENERAL.toggleInput('json'));
codemirror().setValue(content);
await editPage.save();
await click(GENERAL.saveButton);
assert.strictEqual(
currentRouteName(),

View File

@ -72,12 +72,10 @@ module('Acceptance | ssh | roles', function (hooks) {
`/vault/secrets/${sshPath}/sign/${this.name}`,
'ca sign url is correct'
);
assert.dom('[data-test-row-label="Signed key"]').exists({ count: 1 }, 'renders the signed key');
assert
.dom('[data-test-row-value="Signed key"]')
.exists({ count: 1 }, "renders the signed key's value");
assert.dom('[data-test-row-label="Serial number"]').exists({ count: 1 }, 'renders the serial');
assert.dom('[data-test-row-value="Serial number"]').exists({ count: 1 }, 'renders the serial value');
assert.dom(GENERAL.infoRowLabel('Signed key')).exists({ count: 1 }, 'renders the signed key');
assert.dom(GENERAL.infoRowValue('Signed key')).exists("renders the signed key's value");
assert.dom(GENERAL.infoRowLabel('Serial number')).exists({ count: 1 }, 'renders the serial');
assert.dom(GENERAL.infoRowValue('Serial number')).exists('renders the serial value');
},
},
{
@ -102,7 +100,7 @@ module('Acceptance | ssh | roles', function (hooks) {
assert.dom(GENERAL.infoRowLabel('Key')).exists({ count: 1 }, 'renders the key');
assert.dom('[data-test-masked-input]').exists({ count: 1 }, 'renders mask for key value');
assert.dom(GENERAL.infoRowLabel('Port')).exists({ count: 1 }, 'renders the port');
assert.dom('[data-test-row-value="Port"]').exists({ count: 1 }, "renders the port's value");
assert.dom(GENERAL.infoRowValue('Port')).exists("renders the port's value");
},
},
];

View File

@ -4,19 +4,17 @@
*/
import { currentURL, visit, click, fillIn } from '@ember/test-helpers';
import { selectChoose } from 'ember-power-select/test-support';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { v4 as uuidv4 } from 'uuid';
import backendListPage from 'vault/tests/pages/secrets/backends';
import mountSecrets from 'vault/tests/pages/settings/mount-secret-backend';
import { login } from 'vault/tests/helpers/auth/auth-helpers';
import { deleteEngineCmd, mountEngineCmd, runCmd } from 'vault/tests/helpers/commands';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
import { MOUNT_BACKEND_FORM } from 'vault/tests/helpers/components/mount-backend-form-selectors';
const { searchSelect } = GENERAL;
module('Acceptance | secret engine mount settings', function (hooks) {
setupApplicationTest(hooks);
@ -62,10 +60,9 @@ module('Acceptance | secret engine mount settings', function (hooks) {
await visit('/vault/settings/mount-secret-backend');
await runCmd(mountEngineCmd(type, path), false);
await visit('/vault/secrets');
await click(searchSelect.trigger('filter-by-engine-name'));
await click(searchSelect.option(searchSelect.optionIndex(path)));
await selectChoose(GENERAL.searchSelect.trigger('filter-by-engine-name'), path);
await click(GENERAL.menuTrigger);
await backendListPage.configLink();
await click(GENERAL.menuItem('view-configuration'));
assert.strictEqual(
currentURL(),
`/vault/secrets/${path}/${type}/configuration`,
@ -82,10 +79,9 @@ module('Acceptance | secret engine mount settings', function (hooks) {
await visit('/vault/settings/mount-secret-backend');
await runCmd(mountEngineCmd(type, path), false);
await visit('/vault/secrets');
await click(searchSelect.trigger('filter-by-engine-name'));
await click(searchSelect.option(searchSelect.optionIndex(path)));
await selectChoose(GENERAL.searchSelect.trigger('filter-by-engine-name'), path);
await click(GENERAL.menuTrigger);
await backendListPage.configLink();
await click(GENERAL.menuItem('view-configuration'));
assert.strictEqual(
currentURL(),
`/vault/secrets/${path}/configuration`,

View File

@ -21,7 +21,6 @@ const SELECTORS = {
versionsTab: '[data-test-transit-link="versions"]',
actionsTab: '[data-test-transit-key-actions-link]',
card: (action) => `[data-test-transit-card="${action}"]`,
infoRow: (label) => `[data-test-value-div="${label}"]`,
form: (item) => `[data-test-transit-key="${item}"]`,
versionRow: (version) => `[data-test-transit-version="${version}"]`,
rotate: {
@ -245,10 +244,10 @@ module('Acceptance | transit', function (hooks) {
`/vault/secrets/${this.path}/show/${name}?tab=details`,
'it navigates to show page'
);
assert.dom(SELECTORS.infoRow('Auto-rotation period')).hasText('30 days');
assert.dom(SELECTORS.infoRow('Deletion allowed')).hasText('false');
assert.dom(SELECTORS.infoRow('Derived')).hasText('Yes');
assert.dom(SELECTORS.infoRow('Convergent encryption')).hasText('Yes');
assert.dom(GENERAL.infoRowValue('Auto-rotation period')).hasText('30 days');
assert.dom(GENERAL.infoRowValue('Deletion allowed')).hasText('false');
assert.dom(GENERAL.infoRowValue('Derived')).hasText('Yes');
assert.dom(GENERAL.infoRowValue('Convergent encryption')).hasText('Yes');
await click(GENERAL.breadcrumbLink(this.path));
await click(SELECTORS.popupMenu);
const actions = findAll('.hds-dropdown__list li');
@ -346,7 +345,7 @@ module('Acceptance | transit', function (hooks) {
const name = await this.generateTransitKey(keyData);
await visit(`vault/secrets/${this.path}/show/${name}`);
assert
.dom(SELECTORS.infoRow('Auto-rotation period'))
.dom(GENERAL.infoRowValue('Auto-rotation period'))
.hasText('30 days', 'Has expected auto rotate value');
await click(SELECTORS.versionsTab);

View File

@ -40,8 +40,6 @@ export const GENERAL = {
checkboxByAttr: (attr: string) => `[data-test-checkbox="${attr}"]`,
enableField: (attr: string) => `[data-test-enable-field="${attr}"] button`,
fieldByAttr: (attr: string) => `[data-test-field="${attr}"]`,
infoRowLabel: (label: string) => `[data-test-row-label="${label}"]`,
infoRowValue: (label: string) => `[data-test-value-div="${label}"]`,
inputByAttr: (attr: string) => `[data-test-input="${attr}"]`,
selectByAttr: (attr: string) => `[data-test-select="${attr}"]`,
textToggle: '[data-test-text-toggle]',
@ -52,7 +50,10 @@ export const GENERAL = {
toggle: (attr: string) => `[data-test-toggle-label="${attr}"]`,
input: (attr: string) => `[data-test-ttl-value="${attr}"]`,
},
// Info Table Row
infoRowLabel: (label: string) => `[data-test-row-label="${label}"]`,
infoRowValue: (label: string) => `[data-test-row-value="${label}"]`,
// Validation
validation: (attr: string) => `[data-test-field-validation=${attr}]`,
validationWarning: (attr: string) => `[data-test-validation-warning=${attr}]`,
messageError: '[data-test-message-error]',
@ -95,11 +96,14 @@ export const GENERAL = {
input: '[data-test-kv-suggestion-input]',
select: '[data-test-kv-suggestion-select]',
},
// Links and buttons
navLink: (label: string) => `[data-test-sidebar-nav-link="${label}"]`,
backButton: '[data-test-back-button]',
cancelButton: '[data-test-cancel]',
saveButton: '[data-test-save]',
backButton: '[data-test-back-button]',
testButton: (label: string) => `[data-test-button="${label}"]`,
codeBlock: (label: string) => `[data-test-code-block="${label}"]`,
// TODO replace data-test-component="value" as a higher level selector
codemirror: `[data-test-component="code-mirror-modifier"]`,
codemirrorTextarea: `[data-test-component="code-mirror-modifier"] textarea`,
};

View File

@ -12,8 +12,8 @@ export const PAGE = {
breadcrumbCurrentAtIdx: (idx) =>
`[data-test-breadcrumbs] li:nth-child(${idx + 1}) .hds-breadcrumb__current`,
infoRow: '[data-test-component="info-table-row"]',
infoRowValue: (label) => `[data-test-value-div="${label}"]`,
infoRowToggleMasked: (label) => `[data-test-value-div="${label}"] [data-test-button="toggle-masked"]`,
infoRowValue: (label) => `[data-test-row-value="${label}"]`, // TODO replace with GENERAL.infoRowValue
infoRowToggleMasked: (label) => `[data-test-row-value="${label}"] [data-test-button="toggle-masked"]`,
secretTab: (tab) => (tab ? `[data-test-secrets-tab="${tab}"]` : '[data-test-secrets-tab]'),
emptyStateTitle: '[data-test-empty-state-title]',
emptyStateMessage: '[data-test-empty-state-message]',

View File

@ -3,6 +3,8 @@
* SPDX-License-Identifier: BUSL-1.1
*/
import { GENERAL } from '../general-selectors';
export const PKI_OVERVIEW = {
issueCertificateInput: '[data-test-issue-certificate-input]',
issueCertificatePowerSearch: '[data-test-issue-certificate-input] span',
@ -56,14 +58,14 @@ export const PKI_GENERATE_ROOT = {
urlField: '[data-test-urls-section] [data-test-input]',
// Shown values after save
saved: {
certificate: '[data-test-value-div="Certificate"] [data-test-certificate-card]',
commonName: '[data-test-row-value="Common name"]',
issuerName: '[data-test-row-value="Issuer name"]',
issuerLink: '[data-test-value-div="Issuer ID"] a',
keyName: '[data-test-row-value="Key name"]',
keyLink: '[data-test-value-div="Key ID"] a',
privateKey: '[data-test-value-div="Private key"] [data-test-certificate-card]',
serialNumber: '[data-test-row-value="Serial number"]',
certificate: `${GENERAL.infoRowValue('Certificate')} [data-test-certificate-card]`,
commonName: GENERAL.infoRowValue('Common name'),
issuerName: GENERAL.infoRowValue('Issuer name'),
issuerLink: `${GENERAL.infoRowValue('Issuer ID')} a`,
keyName: GENERAL.infoRowValue('Key name'),
keyLink: `${GENERAL.infoRowValue('Key ID')} a`,
privateKey: `${GENERAL.infoRowValue('Private key')} [data-test-certificate-card]`,
serialNumber: GENERAL.infoRowValue('Serial number'),
},
};
@ -73,13 +75,13 @@ export const PKI_CROSS_SIGN = {
statusCount: '[data-test-cross-sign-status-count]',
signedIssuerRow: (row = 0) => `[data-test-info-table-row="${row}"]`,
signedIssuerCol: (attr: string) => `[data-test-info-table-column="${attr}"]`,
rowValue: (attr: string) => `[data-test-row-value="${attr}"]`,
copyButton: (attr: string) => `[data-test-value-div="${attr}"] [data-test-copy-button]`,
rowValue: (attr: string) => `[data-test-row-value="${attr}"]`, // TODO replace with the GENERAL.infoRowValue
copyButton: (attr: string) => `[data-test-row-value="${attr}"] [data-test-copy-button]`,
};
export const PKI_ISSUER_DETAILS = {
configure: '[data-test-pki-issuer-configure]',
copyButtonByName: (name: string) => `[data-test-value-div="${name}"] [data-test-copy-button]`,
copyButtonByName: (name: string) => `[data-test-row-value="${name}"] [data-test-copy-button]`,
crossSign: '[data-test-pki-issuer-cross-sign]',
defaultGroup: '[data-test-details-group="default"]',
download: '[data-test-issuer-download]',
@ -91,7 +93,6 @@ export const PKI_ISSUER_DETAILS = {
row: '[data-test-component="info-table-row"]',
signIntermediate: '[data-test-pki-issuer-sign-int]',
urlsGroup: '[data-test-details-group="Issuer URLs"]',
valueByName: (name: string) => `[data-test-value-div="${name}"]`,
};
export const PKI_KEY_FORM = {
@ -179,11 +180,11 @@ export const PKI_KEYS = {
export const PKI_ROLE_DETAILS = {
issuerLabel: '[data-test-row-label="Issuer"]',
noStoreValue: '[data-test-value-div="Store in storage backend"]',
noStoreMetadataValue: '[data-test-value-div="Store metadata in storage backend"]',
keyUsageValue: '[data-test-value-div="Key usage"]',
extKeyUsageValue: '[data-test-value-div="Ext key usage"]',
customTtlValue: '[data-test-value-div="Issued certificates expire after"]',
noStoreValue: GENERAL.infoRowValue('Store in storage backend'),
noStoreMetadataValue: GENERAL.infoRowValue('Store metadata in storage backend'),
keyUsageValue: GENERAL.infoRowValue('Key usage'),
extKeyUsageValue: GENERAL.infoRowValue('Ext key usage'),
customTtlValue: GENERAL.infoRowValue('Issued certificates expire after'),
deleteRoleButton: '[data-test-pki-role-delete]',
generateCertLink: '[data-test-pki-role-generate-cert]',
signCertLink: '[data-test-pki-role-sign-cert]',
@ -210,8 +211,8 @@ export const PKI_TIDY = {
alertUpdatedAt: '[data-test-tidy-status-alert-updated-at]',
cancelTidyAction: '[data-test-cancel-tidy-action]',
hdsAlertButtonText: '[data-test-cancel-tidy-action] .hds-button__text',
timeStartedRow: '[data-test-value-div="Time started"]',
timeFinishedRow: '[data-test-value-div="Time finished"]',
timeStartedRow: GENERAL.infoRowValue('Time started'),
timeFinishedRow: GENERAL.infoRowValue('Time finished'),
cancelTidyModalBackground: '#pki-cancel-tidy-modal',
tidyEmptyStateConfigure: '[data-test-tidy-empty-state-configure]',
manualTidyToolbar: '[data-test-pki-manual-tidy-config]',

View File

@ -15,7 +15,7 @@ export async function createSecret(path, key, value) {
await fillIn(SES.secretPath('create'), path);
await fillIn('[data-test-secret-key]', key);
await fillIn('[data-test-secret-value] textarea', value);
await click('[data-test-secret-save]');
await click(GENERAL.saveButton);
return;
}

View File

@ -19,6 +19,7 @@ export const SECRET_ENGINE_SELECTORS = {
path ? `[data-test-secrets-backend-link="${path}"]` : '[data-test-secrets-backend-link]',
createSecretLink: '[data-test-create-secret-link]',
secretPath: (name: string) => `[data-test-secret-path="${name}"]`,
secretKey: (name: string) => `[data-test-secret-key="${name}"]`,
secretHeader: '[data-test-secret-header]',
secretLink: (name: string) => (name ? `[data-test-secret-link="${name}"]` : '[data-test-secret-link]'),
secretLinkMenu: (name: string) => `[data-test-secret-link="${name}"] [data-test-popup-menu-trigger]`,

View File

@ -10,6 +10,7 @@ import { setupEngine } from 'ember-engines/test-support';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { dateFormat } from 'core/helpers/date-format';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
const allFields = [
{ label: 'Active', key: 'active' },
@ -62,26 +63,23 @@ module('Integration | Component | messages/page/details', function (hooks) {
.exists({ count: allFields.length }, 'Correct number of filtered fields render');
allFields.forEach((field) => {
assert
.dom(`[data-test-row-label="${field.label}"]`)
.hasText(field.label, `${field.label} label renders`);
assert.dom(GENERAL.infoRowLabel(field.label)).hasText(field.label, `${field.label} label renders`);
if (field.key === 'startTime' || field.key === 'endTime') {
const formattedDate = dateFormat([this.message[field.key], 'MMM d, yyyy hh:mm aaa'], {
withTimeZone: true,
});
assert
.dom(`[data-test-row-value="${field.label}"]`)
.dom(GENERAL.infoRowValue(field.label))
.hasText(formattedDate || 'Never', `${field.label} value renders`);
} else if (field.key === 'authenticated' || field.key === 'active') {
assert
.dom(`[data-test-value-div="${field.label}"]`)
.dom(GENERAL.infoRowValue(field.label))
.hasText(this.message[field.key] ? 'Yes' : 'No', `${field.label} value renders`);
} else if (field.key === 'link') {
assert.dom('[data-test-value-div="Link"]').exists();
assert.dom('[data-test-value-div="Link"] [data-test-link="message link"]').hasText('here');
assert.dom(GENERAL.infoRowValue('Link')).hasText('here');
} else {
assert
.dom(`[data-test-row-value="${field.label}"]`)
.dom(GENERAL.infoRowValue(field.label))
.hasText(this.message[field.key], `${field.label} value renders`);
}
});

View File

@ -5,7 +5,8 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'vault/tests/helpers';
import { render, findAll, click } from '@ember/test-helpers';
import { render, findAll } from '@ember/test-helpers';
import { clickTrigger } from 'ember-power-select/test-support/helpers';
import { hbs } from 'ember-cli-htmlbars';
import { fillIn } from '@ember/test-helpers';
import { selectChoose } from 'ember-power-select/test-support';
@ -134,7 +135,7 @@ module('Integration | Component | dashboard/quick-actions-card', function (hooks
});
test('it should show correct actions for kv', async function (assert) {
await this.renderComponent();
await click('[data-test-component="search-select"]#secrets-engines-select .ember-basic-dropdown-trigger');
await clickTrigger('#type-to-select-a-mount');
assert.strictEqual(
findAll('li.ember-power-select-option').length,
5,

View File

@ -53,7 +53,7 @@ module('Integration | Component | database-role-edit', function (hooks) {
this.server.post('/sys/capabilities-self', capabilitiesStub('database/static-creds/my-role', ['create']));
await render(hbs`<DatabaseRoleEdit @model={{this.modelEmpty}} @mode="create"/>`);
await click('[data-test-secret-save]');
await click(GENERAL.saveButton);
assert.dom('[data-test-inline-error-message]').exists('Inline form errors exist');
});
@ -75,7 +75,7 @@ module('Integration | Component | database-role-edit', function (hooks) {
await render(hbs`<DatabaseRoleEdit @model={{this.modelStatic}} @mode="edit"/>`);
await fillIn('[data-test-ttl-value="Rotation period"]', '20');
await click('[data-test-secret-save]');
await click(GENERAL.saveButton);
});
test('enterprise: it should successfully create user that does not rotate immediately', async function (assert) {
@ -101,7 +101,7 @@ module('Integration | Component | database-role-edit', function (hooks) {
await click(GENERAL.toggleInput('toggle-skip_import_rotation'));
await fillIn(GENERAL.inputByAttr('password'), 'testPassword'); // fill in password field
await click('[data-test-secret-save]');
await click(GENERAL.saveButton);
await render(hbs`<DatabaseRoleEdit @model={{this.modelStatic}} @mode="show"/>`);
assert.dom(GENERAL.infoRowValue('Rotate immediately')).containsText('No');
@ -130,7 +130,7 @@ module('Integration | Component | database-role-edit', function (hooks) {
this.server.post('/sys/capabilities-self', capabilitiesStub('database/static-creds/my-role', ['create']));
await render(hbs`<DatabaseRoleEdit @model={{this.modelStatic}} @mode="create"/>`);
await click('[data-test-secret-save]');
await click(GENERAL.saveButton);
assert.dom('[data-test-issuer-warning]').exists(); // check if warning modal shows after clicking save
await click('[data-test-issuer-save]'); // click continue button on modal

View File

@ -9,6 +9,7 @@ import Service from '@ember/service';
import { setupRenderingTest } from 'ember-qunit';
import { render, triggerEvent } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
const VALUE = 'test value';
const LABEL = 'test label';
@ -52,11 +53,19 @@ module('Integration | Component | InfoTableRow', function (hooks) {
/>`);
assert.dom('[data-test-component="info-table-row"]').exists();
assert.dom('[data-test-row-value]').hasText(VALUE, 'renders value as passed through');
assert.dom(GENERAL.infoRowValue(this.label)).hasText(VALUE, 'renders value as passed through');
});
test('it does not render if a value is empty and alwaysRender is false (even if default exists)', async function (assert) {
this.set('value', '');
await render(hbs`<InfoTableRow
@value={{this.value}}
@label={{this.label}}
@defaultShown={{this.default}}
/>`);
assert
.dom('[data-test-label-div]')
.dom(GENERAL.infoRowValue(this.label))
.doesNotExist('does not render if no value and alwaysRender is false (even if default exists)');
});
@ -69,8 +78,7 @@ module('Integration | Component | InfoTableRow', function (hooks) {
@tooltipText={{this.tooltipText}}
/>`);
await triggerEvent('[data-test-value-div="test label"] .ember-basic-dropdown-trigger', 'mouseenter');
await triggerEvent('.ember-basic-dropdown-trigger', 'mouseenter');
const tooltip = document.querySelector('div.box').textContent.trim();
assert.strictEqual(tooltip, 'Tooltip text!', 'renders tooltip text');
});
@ -89,7 +97,7 @@ module('Integration | Component | InfoTableRow', function (hooks) {
/>
`);
await triggerEvent('[data-test-value-div="test label"] .ember-basic-dropdown-trigger', 'mouseenter');
await triggerEvent('.ember-basic-dropdown-trigger', 'mouseenter');
assert.dom('[data-test-tooltip-copy]').doesNotExist('Tooltip has no copy button');
this.set('isCopyable', true);
@ -146,7 +154,7 @@ module('Integration | Component | InfoTableRow', function (hooks) {
assert.dom('div.column.is-flex-center .hds-icon').exists('Renders a dash (-) for undefined value');
this.set('default', DEFAULT);
assert.dom('[data-test-value-div]').hasText(DEFAULT, 'Renders default text if value is empty');
assert.dom(GENERAL.infoRowValue(this.label)).hasText(DEFAULT, 'Renders default text if value is empty');
this.set('value', '');
this.set('label', '');
@ -167,7 +175,7 @@ module('Integration | Component | InfoTableRow', function (hooks) {
Block content is here
</InfoTableRow>`);
const block = document.querySelector('[data-test-value-div]').textContent.trim();
const block = document.querySelector(GENERAL.infoRowValue(this.label)).textContent.trim();
assert.strictEqual(block, 'Block content is here', 'renders block passed through');
});
@ -177,8 +185,8 @@ module('Integration | Component | InfoTableRow', function (hooks) {
@alwaysRender={{false}}>
Block content
</InfoTableRow>`);
assert.dom('[data-test-value-div]').exists('renders block');
assert.dom('[data-test-value-div]').hasText('Block content', 'renders block');
assert.dom(GENERAL.infoRowValue(this.label)).exists('renders block');
assert.dom(GENERAL.infoRowValue(this.label)).hasText('Block content', 'renders block');
});
test('Row does not render empty block content when alwaysRender = false', async function (assert) {
@ -195,6 +203,7 @@ module('Integration | Component | InfoTableRow', function (hooks) {
assert.dom('[data-test-component="info-table-row"]').exists();
assert.dom('[data-test-icon="minus"]').exists('renders dash when no label');
});
test('Truncates the label if too long', async function (assert) {
this.set('label', 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz');
await render(hbs`<div style="width: 100px;">
@ -204,26 +213,29 @@ module('Integration | Component | InfoTableRow', function (hooks) {
/>
</div>`);
assert.dom('[data-test-component="info-table-row"]').exists('Row renders');
assert.dom('[data-test-label-div].label-overflow').exists('Label has class label-overflow');
await triggerEvent('[data-test-row-label]', 'mouseenter');
assert.dom('[data-test-label-tooltip]').exists('Label tooltip exists on hover');
});
test('Renders if block value and alwaysrender=false', async function (assert) {
await render(hbs`<InfoTableRow @alwaysRender={{false}}>{{this.value}}</InfoTableRow>`);
assert.dom('[data-test-component="info-table-row"]').exists();
});
test('Does not render if value is empty and alwaysrender=false', async function (assert) {
await render(hbs`<InfoTableRow @alwaysRender={{false}} @value="" />`);
assert.dom('[data-test-component="info-table-row"]').doesNotExist();
});
test('Renders dash for value if value empty and alwaysRender=true', async function (assert) {
await render(hbs`<InfoTableRow
@label={{this.label}}
@alwaysRender={{true}}
/>`);
assert.dom('[data-test-component="info-table-row"]').exists();
assert.dom('[data-test-value-div] [data-test-icon="minus"]').exists('renders dash for value');
assert.dom(GENERAL.infoRowValue(this.label)).exists('renders dash for value');
});
test('Renders block over @value or @defaultShown', async function (assert) {
await render(hbs`<InfoTableRow
@label={{this.label}}
@ -233,8 +245,9 @@ module('Integration | Component | InfoTableRow', function (hooks) {
foo
</InfoTableRow>`);
assert.dom('[data-test-component="info-table-row"]').exists();
assert.dom('[data-test-value-div]').hasText('foo', 'renders block value');
assert.dom(GENERAL.infoRowValue(this.label)).hasText('foo', 'renders block value');
});
test('Renders icons if value is boolean', async function (assert) {
this.set('value', true);
await render(hbs`<InfoTableRow
@ -243,10 +256,10 @@ module('Integration | Component | InfoTableRow', function (hooks) {
/>`);
assert.dom('[data-test-boolean-true]').exists('check icon exists');
assert.dom('[data-test-value-div]').hasText('Yes', 'Renders yes text');
assert.dom(GENERAL.infoRowValue(this.label)).hasText('Yes', 'Renders yes text');
this.set('value', false);
assert.dom('[data-test-boolean-false]').exists('x icon exists');
assert.dom('[data-test-value-div]').hasText('No', 'renders no text');
assert.dom(GENERAL.infoRowValue(this.label)).hasText('No', 'renders no text');
});
test('Renders data-test attrs passed from parent', async function (assert) {
this.set('value', true);
@ -267,7 +280,7 @@ module('Integration | Component | InfoTableRow', function (hooks) {
@formatDate={{'yyyy'}}
/>`);
assert.dom('[data-test-value-div]').hasText('2018', 'Renders date with passed format');
assert.dom(GENERAL.infoRowValue(this.label)).hasText('2018', 'Renders date with passed format');
});
test('Formats the value as TTL when formatTtl present', async function (assert) {
@ -279,7 +292,7 @@ module('Integration | Component | InfoTableRow', function (hooks) {
/>`);
assert
.dom('[data-test-value-div]')
.dom(GENERAL.infoRowValue(this.label))
.hasText('1 hour 40 minutes', 'Translates number value to largest unit with carryover of minutes');
});
@ -291,6 +304,6 @@ module('Integration | Component | InfoTableRow', function (hooks) {
@formatTtl={{true}}
/>`);
assert.dom('[data-test-value-div]').hasText('45 minutes', 'it formats string duration');
assert.dom(GENERAL.infoRowValue(this.label)).hasText('45 minutes', 'it formats string duration');
});
});

View File

@ -10,6 +10,7 @@ import { hbs } from 'ember-cli-htmlbars';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { click, settled, fillIn } from '@ember/test-helpers';
import { setRunOptions } from 'ember-a11y-testing/test-support';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
const ts = 'data-test-kms-provider';
const root = {
@ -150,7 +151,7 @@ module('Integration | Component | keymgmt/provider-edit', function (hooks) {
/>`);
assert
.dom('[data-test-value-div="Keys"]')
.dom(GENERAL.infoRowValue('Keys'))
.hasText('None', 'None is displayed when no keys exist for provider');
await click(`[${ts}-delete]`);

View File

@ -10,6 +10,7 @@ import { setupEngine } from 'ember-engines/test-support';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { render, click, fillIn } from '@ember/test-helpers';
import { Response } from 'miragejs';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
import hbs from 'htmlbars-inline-precompile';
import timestamp from 'core/utils/timestamp';
@ -91,7 +92,7 @@ module('Integration | Component | kubernetes | Page::Credentials', function (hoo
assert.expect(15);
this.server.post('/kubernetes-test/creds/role-0', () => {
assert.ok('POST request made to generate credentials');
assert.true(true, 'POST request made to generate credentials');
return {
request_id: '58fefc6c-5195-c17a-94f2-8f889f3df57c',
lease_id: 'kubernetes/creds/default-role/aWczfcfJ7NKUdiirJrPXIs38',
@ -120,20 +121,20 @@ module('Integration | Component | kubernetes | Page::Credentials', function (hoo
.dom('[data-test-k8-alert-message]')
.hasText("You won't be able to access these credentials later, so please copy them now.");
assert.dom('[data-test-row-label="Service account token"]').hasText('Service account token');
await click('[data-test-value-div="Service account token"] [data-test-button]');
await click(`${GENERAL.infoRowValue('Service account token')} [data-test-button]`);
assert
.dom('[data-test-value-div="Service account token"] .display-only')
.dom(`${GENERAL.infoRowValue('Service account token')} .display-only`)
.hasText('eyJhbGciOiJSUzI1NiIsImtpZCI6Imlr');
assert.dom('[data-test-row-label="Namespace"]').hasText('Namespace');
assert.dom('[data-test-value-div="Namespace"]').exists();
assert.dom(GENERAL.infoRowValue('Namespace')).exists();
assert.dom('[data-test-row-label="Service account name"]').hasText('Service account name');
assert.dom('[data-test-value-div="Service account name"]').exists();
assert.dom(GENERAL.infoRowValue('Service account name')).exists();
assert.dom('[data-test-row-label="Lease expiry"]').hasText('Lease expiry');
assert.dom('[data-test-value-div="Lease expiry"]').hasText('April 3rd 2018, 3:15:30 PM');
assert.dom(GENERAL.infoRowValue('Lease expiry')).hasText('April 3rd 2018, 3:15:30 PM');
assert.dom('[data-test-row-label="lease_id"]').hasText('lease_id');
assert
.dom('[data-test-value-div="lease_id"] [data-test-row-value="lease_id"]')
.dom(GENERAL.infoRowValue('lease_id'))
.hasText('kubernetes/creds/default-role/aWczfcfJ7NKUdiirJrPXIs38');
});
});

View File

@ -40,8 +40,8 @@ module('Integration | Component | kv-v2 | KvPathsCard', function (hooks) {
await this.renderComponent();
assert.dom('[data-test-component="info-table-row"] .helper-text').doesNotExist('subtext does not render');
assert.dom('[data-test-label-div]').hasClass('is-one-quarter');
assert.dom(PAGE.infoRowValue('API path for metadata')).doesNotExist();
assert.dom('[data-test-component="info-table-row"] div').hasClass('is-one-quarter');
assert.dom(PAGE.paths.codeSnippet('cli')).doesNotExist();
assert.dom(PAGE.paths.codeSnippet('api')).doesNotExist();
@ -59,7 +59,7 @@ module('Integration | Component | kv-v2 | KvPathsCard', function (hooks) {
await this.renderComponent();
assert.dom('[data-test-component="info-table-row"] .helper-text').exists('subtext renders');
assert.dom('[data-test-label-div]').hasClass('is-one-third');
assert.dom('[data-test-component="info-table-row"] div').hasClass('is-one-third');
assert.dom(PAGE.infoRowValue('API path for metadata')).exists();
assert.dom(PAGE.paths.codeSnippet('cli')).exists();
assert.dom(PAGE.paths.codeSnippet('api')).exists();

View File

@ -12,6 +12,7 @@ import hbs from 'htmlbars-inline-precompile';
import { duration } from 'core/helpers/format-duration';
import { createSecretsEngine, generateBreadcrumbs } from 'vault/tests/helpers/ldap/ldap-helpers';
import { setRunOptions } from 'ember-a11y-testing/test-support';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
const selectors = {
rotateAction: '[data-test-toolbar-rotate-action]',
@ -20,7 +21,6 @@ const selectors = {
configCta: '[data-test-config-cta]',
mountConfig: '[data-test-mount-config]',
pageError: '[data-test-page-error]',
fieldValue: (label) => `[data-test-value-div="${label}"]`,
};
module('Integration | Component | ldap | Page::Configuration', function (hooks) {
@ -90,21 +90,21 @@ module('Integration | Component | ldap | Page::Configuration', function (hooks)
test('it should render display fields', async function (assert) {
await this.renderComponent();
assert.dom(selectors.fieldValue('Administrator Distinguished Name')).hasText(this.config.binddn);
assert.dom(selectors.fieldValue('URL')).hasText(this.config.url);
assert.dom(selectors.fieldValue('Schema')).hasText(this.config.schema);
assert.dom(selectors.fieldValue('Password Policy')).hasText(this.config.password_policy);
assert.dom(selectors.fieldValue('Userdn')).hasText(this.config.userdn);
assert.dom(selectors.fieldValue('Userattr')).hasText(this.config.userattr);
assert.dom(GENERAL.infoRowValue('Administrator Distinguished Name')).hasText(this.config.binddn);
assert.dom(GENERAL.infoRowValue('URL')).hasText(this.config.url);
assert.dom(GENERAL.infoRowValue('Schema')).hasText(this.config.schema);
assert.dom(GENERAL.infoRowValue('Password Policy')).hasText(this.config.password_policy);
assert.dom(GENERAL.infoRowValue('Userdn')).hasText(this.config.userdn);
assert.dom(GENERAL.infoRowValue('Userattr')).hasText(this.config.userattr);
assert
.dom(selectors.fieldValue('Connection Timeout'))
.dom(GENERAL.infoRowValue('Connection Timeout'))
.hasText(duration([this.config.connection_timeout]));
assert.dom(selectors.fieldValue('Request Timeout')).hasText(duration([this.config.request_timeout]));
assert.dom(selectors.fieldValue('CA Certificate')).hasText(this.config.certificate);
assert.dom(selectors.fieldValue('Start TLS')).includesText('No');
assert.dom(selectors.fieldValue('Insecure TLS')).includesText('No');
assert.dom(selectors.fieldValue('Client TLS Certificate')).hasText(this.config.client_tls_cert);
assert.dom(selectors.fieldValue('Client TLS Key')).hasText(this.config.client_tls_key);
assert.dom(GENERAL.infoRowValue('Request Timeout')).hasText(duration([this.config.request_timeout]));
assert.dom(GENERAL.infoRowValue('CA Certificate')).hasText(this.config.certificate);
assert.dom(GENERAL.infoRowValue('Start TLS')).includesText('No');
assert.dom(GENERAL.infoRowValue('Insecure TLS')).includesText('No');
assert.dom(GENERAL.infoRowValue('Client TLS Certificate')).hasText(this.config.client_tls_cert);
assert.dom(GENERAL.infoRowValue('Client TLS Key')).hasText(this.config.client_tls_key);
});
test('it should rotate root password', async function (assert) {

View File

@ -8,6 +8,7 @@ import { setupRenderingTest } from 'ember-qunit';
import { setupEngine } from 'ember-engines/test-support';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { render, click } from '@ember/test-helpers';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
import hbs from 'htmlbars-inline-precompile';
import sinon from 'sinon';
@ -70,27 +71,27 @@ module('Integration | Component | ldap | Page::Library::CheckOut', function (hoo
);
assert.dom('[data-test-row-value="Account name"]').hasText('foo.bar', 'Account name renders');
await click('[data-test-button="toggle-masked"]');
assert.dom('[data-test-value-div="Password"] .masked-value').hasText('password', 'Password renders');
assert.dom(`${GENERAL.infoRowValue('Password')} .masked-value`).hasText('password', 'Password renders');
assert
.dom('[data-test-row-value="Lease ID"]')
.hasText('ldap/library/test/check-out/123', 'Lease ID renders');
assert
.dom('[data-test-value-div="Lease renewable"] svg')
.dom(`${GENERAL.infoRowValue('Lease renewable')} svg`)
.hasClass('hds-icon-check-circle', 'Lease renewable true icon renders');
assert
.dom('[data-test-value-div="Lease renewable"] svg')
.dom(`${GENERAL.infoRowValue('Lease renewable')} svg`)
.hasClass('has-text-success', 'Lease renewable true icon color renders');
assert.dom('[data-test-value-div="Lease renewable"] span').hasText('True', 'Lease renewable renders');
assert.dom(`${GENERAL.infoRowValue('Lease renewable')} span`).hasText('True', 'Lease renewable renders');
this.creds.renewable = false;
await this.renderComponent();
assert
.dom('[data-test-value-div="Lease renewable"] svg')
.dom(`${GENERAL.infoRowValue('Lease renewable')} svg`)
.hasClass('hds-icon-x-circle', 'Lease renewable false icon renders');
assert
.dom('[data-test-value-div="Lease renewable"] svg')
.dom(`${GENERAL.infoRowValue('Lease renewable')} svg`)
.hasClass('has-text-danger', 'Lease renewable false icon color renders');
assert.dom('[data-test-value-div="Lease renewable"] span').hasText('False', 'Lease renewable renders');
assert.dom(`${GENERAL.infoRowValue('Lease renewable')} span`).hasText('False', 'Lease renewable renders');
await click('[data-test-done]');
const didTransition = transitionStub.calledWith(

View File

@ -10,6 +10,7 @@ import { setupMirage } from 'ember-cli-mirage/test-support';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import { duration } from 'core/helpers/format-duration';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
module('Integration | Component | ldap | Page::Library::Details::Configuration', function (hooks) {
setupRenderingTest(hooks);
@ -46,8 +47,8 @@ module('Integration | Component | ldap | Page::Library::Details::Configuration',
const value = label.includes('TTL') ? duration([this.model[key]]) : this.model[key];
const method = key === 'disable_check_in_enforcement' ? 'includesText' : 'hasText';
assert.dom(`[data-test-row-label="${label}"]`).hasText(label, `${label} info row label renders`);
assert.dom(`[data-test-value-div="${label}"]`)[method](value, `${label} info row label renders`);
assert.dom(GENERAL.infoRowLabel(label)).hasText(label, `${label} info row label renders`);
assert.dom(GENERAL.infoRowValue(label))[method](value, `${label} info row value renders`);
});
assert

View File

@ -12,6 +12,7 @@ import hbs from 'htmlbars-inline-precompile';
import sinon from 'sinon';
import { duration } from 'core/helpers/format-duration';
import { dateFormat } from 'core/helpers/date-format';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
module('Integration | Component | ldap | Page::Role::Credentials', function (hooks) {
setupRenderingTest(hooks);
@ -77,16 +78,14 @@ module('Integration | Component | ldap | Page::Role::Credentials', function (hoo
);
for (const field of fields) {
assert
.dom(`[data-test-row-label="${field.label}"]`)
.hasText(field.label, `${field.label} label renders`);
assert.dom(GENERAL.infoRowLabel(field.label)).hasText(field.label, `${field.label} label renders`);
if (field.isMasked) {
await click(`[data-test-value-div="${field.label}"] [data-test-button="toggle-masked"]`);
await click(`${GENERAL.infoRowValue(field.label)} ${GENERAL.testButton('toggle-masked')}`);
}
const value = field.value ? field.value() : this.creds[field.key];
assert.dom(`[data-test-value-div="${field.label}"]`).hasText(value, `${field.label} value renders`);
assert.dom(GENERAL.infoRowValue(field.label)).hasText(value, `${field.label} value renders`);
}
await click('[data-test-done]');
@ -120,16 +119,14 @@ module('Integration | Component | ldap | Page::Role::Credentials', function (hoo
);
for (const field of fields) {
assert
.dom(`[data-test-row-label="${field.label}"]`)
.hasText(field.label, `${field.label} label renders`);
assert.dom(GENERAL.infoRowLabel(field.label)).hasText(field.label, `${field.label} label renders`);
if (field.isMasked) {
await click(`[data-test-value-div="${field.label}"] [data-test-button="toggle-masked"]`);
await click(`${GENERAL.infoRowValue(field.label)} ${GENERAL.testButton('toggle-masked')}`);
}
const value = field.value ? field.value() : this.creds[field.key];
assert.dom(`[data-test-value-div="${field.label}"]`).hasText(value, `${field.label} value renders`);
assert.dom(GENERAL.infoRowValue(field.label)).hasText(value, `${field.label} value renders`);
}
await click('[data-test-done]');

View File

@ -9,6 +9,7 @@ import { render, click, fillIn } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { setRunOptions } from 'ember-a11y-testing/test-support';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
module('Integration | Component | mfa-login-enforcement-form', function (hooks) {
setupRenderingTest(hooks);
@ -170,10 +171,10 @@ module('Integration | Component | mfa-login-enforcement-form', function (hooks)
.dom('.search-select-list-item small')
.hasText('123456', 'MFA method id renders in selected option');
assert
.dom('[data-test-row-label="Authentication mount"]')
.dom(GENERAL.infoRowLabel('Authentication mount'))
.hasText('Authentication mount', 'Selected target type renders');
assert
.dom('[data-test-value-div="Authentication mount"]')
.dom(GENERAL.infoRowValue('Authentication mount'))
.hasText('auth_userpass_1234', 'Selected target value renders');
await click('[data-test-mlef-remove-target]');
@ -237,10 +238,10 @@ module('Integration | Component | mfa-login-enforcement-form', function (hooks)
for (const [index, target] of targets.entries()) {
// target populated from model
assert
.dom(`[data-test-row-label="${target.label}"]`)
.dom(GENERAL.infoRowLabel(target.label))
.hasText(target.label, `${target.label} target populated with correct type label`);
assert
.dom(`[data-test-value-div="${target.label}"]`)
.dom(GENERAL.infoRowValue(target.label))
.hasText(target.value, `${target.label} target populated with correct value`);
// remove target
await click(`[data-test-mlef-remove-target="${target.label}"]`);

View File

@ -9,6 +9,7 @@ import { click, render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { setupEngine } from 'ember-engines/test-support';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
import sinon from 'sinon';
module('Integration | Component | pki | Page::PkiCertificateDetails', function (hooks) {
@ -91,9 +92,9 @@ module('Integration | Component | pki | Page::PkiCertificateDetails', function (
.dom('[data-test-component="info-table-row"]')
.exists({ count: 5 }, 'Correct number of fields render when certificate has not been revoked');
assert
.dom('[data-test-value-div="Certificate"] [data-test-certificate-card]')
.dom(`${GENERAL.infoRowValue('Certificate')} [data-test-certificate-card]`)
.exists('Certificate card renders for certificate');
assert.dom('[data-test-value-div="Serial number"] code').exists('Serial number renders as monospace');
assert.dom(`${GENERAL.infoRowValue('Serial number')} code`).exists('Serial number renders as monospace');
await click('[data-test-pki-cert-download-button]');
const { serialNumber, certificate } = this.model;
@ -105,7 +106,7 @@ module('Integration | Component | pki | Page::PkiCertificateDetails', function (
await click('[data-test-confirm-action-trigger]');
await click('[data-test-confirm-button]');
assert.dom('[data-test-value-div="Revocation time"]').exists('Revocation time is displayed');
assert.dom(GENERAL.infoRowValue('Revocation time')).exists('Revocation time is displayed');
});
test('it should render actions and fields for generated cert', async function (assert) {
@ -132,17 +133,17 @@ module('Integration | Component | pki | Page::PkiCertificateDetails', function (
.dom('[data-test-component="info-table-row"]')
.exists({ count: 9 }, 'Correct number of fields render when certificate has not been revoked');
assert
.dom('[data-test-value-div="Certificate"] [data-test-certificate-card]')
.dom(`${GENERAL.infoRowValue('Certificate')} [data-test-certificate-card]`)
.exists('Certificate card renders for certificate');
assert.dom('[data-test-value-div="Serial number"] code').exists('Serial number renders as monospace');
assert.dom(`${GENERAL.infoRowValue('Serial number')} code`).exists('Serial number renders as monospace');
assert
.dom('[data-test-value-div="CA Chain"] [data-test-certificate-card]')
.dom(`${GENERAL.infoRowValue('CA Chain')} [data-test-certificate-card]`)
.exists('Certificate card renders for CA Chain');
assert
.dom('[data-test-value-div="Issuing CA"] [data-test-certificate-card]')
.dom(`${GENERAL.infoRowValue('Issuing CA')} [data-test-certificate-card]`)
.exists('Certificate card renders for Issuing CA');
assert
.dom('[data-test-value-div="Private key"] [data-test-certificate-card]')
.dom(`${GENERAL.infoRowValue('Private key')} [data-test-certificate-card]`)
.exists('Certificate card renders for private key');
await click('[data-test-pki-cert-download-button]');
@ -155,7 +156,7 @@ module('Integration | Component | pki | Page::PkiCertificateDetails', function (
await click('[data-test-confirm-action-trigger]');
await click('[data-test-confirm-button]');
assert.dom('[data-test-value-div="Revocation time"]').exists('Revocation time is displayed');
assert.dom(GENERAL.infoRowValue('Revocation time')).exists('Revocation time is displayed');
});
test('it should render back button', async function (assert) {

View File

@ -9,11 +9,10 @@ import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { setupEngine } from 'ember-engines/test-support';
import { setRunOptions } from 'ember-a11y-testing/test-support';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
const SELECTORS = {
rowLabel: (attr) => `[data-test-row-label="${attr}"]`,
rowValue: (attr) => `[data-test-value-div="${attr}"]`,
rowIcon: (attr, icon) => `[data-test-row-value="${attr}"] [data-test-icon="${icon}"]`,
rowIcon: (attr, icon) => `${GENERAL.infoRowValue(attr)} ${GENERAL.icon(icon)}`,
};
module('Integration | Component | Page::PkiConfigurationDetails', function (hooks) {
@ -60,9 +59,9 @@ module('Integration | Component | Page::PkiConfigurationDetails', function (hook
owner: this.engine,
});
assert
.dom(SELECTORS.rowValue("Mount's API path"))
.dom(GENERAL.infoRowValue("Mount's API path"))
.hasText('https://pr-a.vault.example.com/v1/ns1/pki-root', 'mount API path row renders');
assert.dom(SELECTORS.rowValue('AIA path')).hasText('None', "renders 'None' when no data");
assert.dom(GENERAL.infoRowValue('AIA path')).hasText('None', "renders 'None' when no data");
});
test('shows the correct information on global urls section', async function (assert) {
@ -72,10 +71,10 @@ module('Integration | Component | Page::PkiConfigurationDetails', function (hook
);
assert
.dom(SELECTORS.rowLabel('Issuing certificates'))
.dom(GENERAL.infoRowLabel('Issuing certificates'))
.hasText('Issuing certificates', 'issuing certificate row label renders');
assert
.dom(SELECTORS.rowValue('Issuing certificates'))
.dom(GENERAL.infoRowValue('Issuing certificates'))
.hasText('example.com', 'issuing certificate value renders');
this.urls.issuingCertificates = null;
await render(
@ -83,13 +82,13 @@ module('Integration | Component | Page::PkiConfigurationDetails', function (hook
{ owner: this.engine }
);
assert
.dom(SELECTORS.rowValue('Issuing certificates'))
.dom(GENERAL.infoRowValue('Issuing certificates'))
.hasText('None', 'issuing certificate value renders None if none is configured');
assert
.dom(SELECTORS.rowLabel('CRL distribution points'))
.dom(GENERAL.infoRowLabel('CRL distribution points'))
.hasText('CRL distribution points', 'crl distribution points row label renders');
assert
.dom(SELECTORS.rowValue('CRL distribution points'))
.dom(GENERAL.infoRowValue('CRL distribution points'))
.hasText('None', 'crl distribution points value renders None if none is configured');
});
@ -99,24 +98,24 @@ module('Integration | Component | Page::PkiConfigurationDetails', function (hook
{ owner: this.engine }
);
assert.dom(SELECTORS.rowLabel('CRL building')).hasText('CRL building', 'crl expiry row label renders');
assert.dom(SELECTORS.rowValue('CRL building')).hasText('Enabled', 'enabled renders');
assert.dom(SELECTORS.rowValue('Expiry')).hasText('20h', 'expiry value renders');
assert.dom(SELECTORS.rowLabel('Auto-rebuild')).hasText('Auto-rebuild', 'auto rebuild label renders');
assert.dom(SELECTORS.rowValue('Auto-rebuild')).hasText('On', 'it renders truthy auto build');
assert.dom(GENERAL.infoRowLabel('CRL building')).hasText('CRL building', 'crl expiry row label renders');
assert.dom(GENERAL.infoRowValue('CRL building')).hasText('Enabled', 'enabled renders');
assert.dom(GENERAL.infoRowValue('Expiry')).hasText('20h', 'expiry value renders');
assert.dom(GENERAL.infoRowLabel('Auto-rebuild')).hasText('Auto-rebuild', 'auto rebuild label renders');
assert.dom(GENERAL.infoRowValue('Auto-rebuild')).hasText('On', 'it renders truthy auto build');
assert.dom(SELECTORS.rowIcon('Auto-rebuild', 'check-circle'));
assert
.dom(SELECTORS.rowValue('Auto-rebuild grace period'))
.dom(GENERAL.infoRowValue('Auto-rebuild grace period'))
.hasText('13h', 'it renders auto build grace period');
assert.dom(SELECTORS.rowValue('Delta CRL building')).hasText('On', 'it renders truthy delta crl build');
assert.dom(GENERAL.infoRowValue('Delta CRL building')).hasText('On', 'it renders truthy delta crl build');
assert.dom(SELECTORS.rowIcon('Delta CRL building', 'check-circle'));
assert
.dom(SELECTORS.rowValue('Delta rebuild interval'))
.dom(GENERAL.infoRowValue('Delta rebuild interval'))
.hasText('15m', 'it renders delta build duration');
assert
.dom(SELECTORS.rowValue('Responder APIs'))
.dom(GENERAL.infoRowValue('Responder APIs'))
.hasText('Enabled', 'responder apis value renders Enabled if ocsp_disable=false');
assert.dom(SELECTORS.rowValue('Interval')).hasText('77h', 'interval value renders');
assert.dom(GENERAL.infoRowValue('Interval')).hasText('77h', 'interval value renders');
// check falsy aut_rebuild and _enable_delta hides duration values
this.crl.autoRebuild = false;
this.crl.enableDelta = false;
@ -124,15 +123,15 @@ module('Integration | Component | Page::PkiConfigurationDetails', function (hook
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @hasConfig={{true}} />,`,
{ owner: this.engine }
);
assert.dom(SELECTORS.rowValue('Auto-rebuild')).hasText('Off', 'it renders falsy auto build');
assert.dom(GENERAL.infoRowValue('Auto-rebuild')).hasText('Off', 'it renders falsy auto build');
assert.dom(SELECTORS.rowIcon('Auto-rebuild', 'x-square'));
assert
.dom(SELECTORS.rowValue('Auto-rebuild grace period'))
.dom(GENERAL.infoRowValue('Auto-rebuild grace period'))
.doesNotExist('does not render auto-rebuild grace period');
assert.dom(SELECTORS.rowValue('Delta CRL building')).hasText('Off', 'it renders falsy delta cr build');
assert.dom(GENERAL.infoRowValue('Delta CRL building')).hasText('Off', 'it renders falsy delta cr build');
assert.dom(SELECTORS.rowIcon('Delta CRL building', 'x-square'));
assert
.dom(SELECTORS.rowValue('Delta rebuild interval'))
.dom(GENERAL.infoRowValue('Delta rebuild interval'))
.doesNotExist('does not render delta rebuild duration');
// check falsy disable and ocsp_disable hides duration values and other params
@ -144,16 +143,16 @@ module('Integration | Component | Page::PkiConfigurationDetails', function (hook
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @hasConfig={{true}} />,`,
{ owner: this.engine }
);
assert.dom(SELECTORS.rowValue('CRL building')).hasText('Disabled', 'disabled renders');
assert.dom(SELECTORS.rowValue('Expiry')).doesNotExist();
assert.dom(GENERAL.infoRowValue('CRL building')).hasText('Disabled', 'disabled renders');
assert.dom(GENERAL.infoRowValue('Expiry')).doesNotExist();
assert
.dom(SELECTORS.rowValue('Responder APIs'))
.dom(GENERAL.infoRowValue('Responder APIs'))
.hasText('Disabled', 'responder apis value renders Disabled');
assert.dom(SELECTORS.rowValue('Interval')).doesNotExist();
assert.dom(SELECTORS.rowValue('Auto-rebuild')).doesNotExist();
assert.dom(SELECTORS.rowValue('Auto-rebuild grace period')).doesNotExist();
assert.dom(SELECTORS.rowValue('Delta CRL building')).doesNotExist();
assert.dom(SELECTORS.rowValue('Delta rebuild interval')).doesNotExist();
assert.dom(GENERAL.infoRowValue('Interval')).doesNotExist();
assert.dom(GENERAL.infoRowValue('Auto-rebuild')).doesNotExist();
assert.dom(GENERAL.infoRowValue('Auto-rebuild grace period')).doesNotExist();
assert.dom(GENERAL.infoRowValue('Delta CRL building')).doesNotExist();
assert.dom(GENERAL.infoRowValue('Delta rebuild interval')).doesNotExist();
});
test('it renders enterprise params in crl section', async function (assert) {
@ -163,11 +162,11 @@ module('Integration | Component | Page::PkiConfigurationDetails', function (hook
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @hasConfig={{true}} />,`,
{ owner: this.engine }
);
assert.dom(SELECTORS.rowValue('Cross-cluster revocation')).hasText('Yes');
assert.dom(GENERAL.infoRowValue('Cross-cluster revocation')).hasText('Yes');
assert.dom(SELECTORS.rowIcon('Cross-cluster revocation', 'check-circle'));
assert.dom(SELECTORS.rowValue('Unified CRL')).hasText('Yes');
assert.dom(GENERAL.infoRowValue('Unified CRL')).hasText('Yes');
assert.dom(SELECTORS.rowIcon('Unified CRL', 'check-circle'));
assert.dom(SELECTORS.rowValue('Unified CRL on existing paths')).hasText('Yes');
assert.dom(GENERAL.infoRowValue('Unified CRL on existing paths')).hasText('Yes');
assert.dom(SELECTORS.rowIcon('Unified CRL on existing paths', 'check-circle'));
});
@ -178,8 +177,8 @@ module('Integration | Component | Page::PkiConfigurationDetails', function (hook
hbs`<Page::PkiConfigurationDetails @urls={{this.urls}} @crl={{this.crl}} @hasConfig={{true}} />,`,
{ owner: this.engine }
);
assert.dom(SELECTORS.rowValue('Cross-cluster revocation')).doesNotExist();
assert.dom(SELECTORS.rowValue('Unified CRL')).doesNotExist();
assert.dom(SELECTORS.rowValue('Unified CRL on existing paths')).doesNotExist();
assert.dom(GENERAL.infoRowValue('Cross-cluster revocation')).doesNotExist();
assert.dom(GENERAL.infoRowValue('Unified CRL')).doesNotExist();
assert.dom(GENERAL.infoRowValue('Unified CRL on existing paths')).doesNotExist();
});
});

View File

@ -10,6 +10,7 @@ import { hbs } from 'ember-cli-htmlbars';
import { setupEngine } from 'ember-engines/test-support';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { Response } from 'miragejs';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
import sinon from 'sinon';
const selectors = {
@ -27,7 +28,6 @@ const selectors = {
certUrlRemove: '[data-test-string-list-button="delete"]',
crlDist: '[data-test-input="crlDistributionPoints"] [data-test-string-list-input="0"]',
ocspServers: '[data-test-input="ocspServers"] [data-test-string-list-input="0"]',
save: '[data-test-save]',
cancel: '[data-test-cancel]',
error: '[data-test-message-error]',
alert: '[data-test-inline-error-message]',
@ -132,7 +132,7 @@ module('Integration | Component | pki | Page::PkiIssuerEditPage::PkiIssuerEdit',
await render(hbs`<Page::PkiIssuerEdit @model={{this.model}} />`, { owner: this.engine });
await this.update();
await click(selectors.save);
await click(GENERAL.saveButton);
assert.ok(this.transitionCalled(), 'Transitions to details route on save success');
});
@ -140,7 +140,7 @@ module('Integration | Component | pki | Page::PkiIssuerEditPage::PkiIssuerEdit',
this.server.post('/pki/issuer/test', () => new Response(404, {}, { errors: ['Some error occurred'] }));
await render(hbs`<Page::PkiIssuerEdit @model={{this.model}} />`, { owner: this.engine });
await click(selectors.save);
await click(GENERAL.saveButton);
assert
.dom(selectors.alert)

View File

@ -8,6 +8,7 @@ import { setupRenderingTest } from 'vault/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { setupEngine } from 'ember-engines/test-support';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
module('Integration | Component | page/pki-tidy-auto-settings', function (hooks) {
setupRenderingTest(hooks);
@ -50,26 +51,26 @@ module('Integration | Component | page/pki-tidy-auto-settings', function (hooks)
.dom('[data-test-pki-edit-tidy-auto-link]')
.hasText('Edit auto-tidy', 'toolbar edit link has correct text');
assert.dom('[data-test-row="enabled"] [data-test-label-div]').hasText('Automatic tidy enabled');
assert.dom('[data-test-value-div="Automatic tidy enabled"]').hasText('No');
assert.dom('[data-test-value-div="Interval duration"]').hasText('2 days');
assert.dom('[data-test-row="enabled"] [data-test-row-label]').hasText('Automatic tidy enabled');
assert.dom(GENERAL.infoRowValue('Automatic tidy enabled')).hasText('No');
assert.dom(GENERAL.infoRowValue('Interval duration')).hasText('2 days');
// Universal operations
assert.dom('[data-test-group-title="Universal operations"]').hasText('Universal operations');
assert
.dom('[data-test-value-div="Tidy the certificate store"]')
.dom(GENERAL.infoRowValue('Tidy the certificate store'))
.exists('Renders universal field when value exists');
assert.dom('[data-test-value-div="Tidy the certificate store"]').hasText('No');
assert.dom(GENERAL.infoRowValue('Tidy the certificate store')).hasText('No');
assert
.dom('[data-test-value-div="Tidy revoked certificates"]')
.dom(GENERAL.infoRowValue('Tidy revoked certificates'))
.doesNotExist('Does not render universal field when value null');
// Issuer operations
assert.dom('[data-test-group-title="Issuer operations"]').hasText('Issuer operations');
assert
.dom('[data-test-value-div="Tidy expired issuers"]')
.dom(GENERAL.infoRowValue('Tidy expired issuers'))
.exists('Renders issuer op field when value exists');
assert.dom('[data-test-value-div="Tidy expired issuers"]').hasText('Yes');
assert.dom(GENERAL.infoRowValue('Tidy expired issuers')).hasText('Yes');
assert
.dom('[data-test-value-div="Tidy legacy CA bundle"]')
.dom(GENERAL.infoRowValue('Tidy legacy CA bundle'))
.doesNotExist('Does not render issuer op field when value null');
});
});

View File

@ -8,6 +8,7 @@ import { setupRenderingTest } from 'vault/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { setupEngine } from 'ember-engines/test-support';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
module('Integration | Component | parsed-certificate-info-rows', function (hooks) {
setupRenderingTest(hooks);
@ -37,10 +38,10 @@ module('Integration | Component | parsed-certificate-info-rows', function (hooks
});
assert.dom('[data-test-component="info-table-row"]').exists({ count: 2 }, 'renders 2 rows');
assert.dom('[data-test-value-div="Common name"]').doesNotExist('common name is never rendered');
assert.dom(GENERAL.infoRowValue('Common name')).doesNotExist('common name is never rendered');
assert.dom('[data-test-row-value="Subject Alternative Names (SANs)"]').hasText('something,here');
assert.dom('[data-test-value-div="Use PSS"]').hasText('No', 'Booleans are rendered');
assert.dom('[data-test-value-div="ttl"]').doesNotExist('ttl is not rendered because value undefined');
assert.dom(GENERAL.infoRowValue('Use PSS')).hasText('No', 'Booleans are rendered');
assert.dom(GENERAL.infoRowValue('ttl')).doesNotExist('ttl is not rendered because value undefined');
assert
.dom('[data-test-parsing-error-alert-banner]')
.doesNotExist('does not render parsing error info banner');

View File

@ -10,6 +10,7 @@ import { hbs } from 'ember-cli-htmlbars';
import { setupEngine } from 'ember-engines/test-support';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { setRunOptions } from 'ember-a11y-testing/test-support';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
module('Integration | Component | pki-generate-csr', function (hooks) {
setupRenderingTest(hooks);
@ -121,16 +122,16 @@ module('Integration | Component | pki-generate-csr', function (hooks) {
);
assert
.dom('[data-test-value-div="CSR"] [data-test-certificate-card] button')
.dom(`${GENERAL.infoRowValue('CSR')} [data-test-certificate-card] button`)
.hasAttribute('data-test-copy-button', this.model.csr, 'it renders copyable csr');
assert
.dom('[data-test-value-div="Key ID"] button')
.dom(`${GENERAL.infoRowValue('Key ID')} button`)
.hasAttribute('data-test-copy-button', this.model.keyId, 'it renders copyable key_id');
assert
.dom('[data-test-value-div="Private key"] [data-test-certificate-card] button')
.dom(`${GENERAL.infoRowValue('Private key')} [data-test-certificate-card] button`)
.hasAttribute('data-test-copy-button', this.model.privateKey, 'it renders copyable private_key');
assert
.dom('[data-test-value-div="Private key type"]')
.dom(GENERAL.infoRowValue('Private key type'))
.hasText(this.model.privateKeyType, 'renders private_key_type');
await click('[data-test-done]');
});
@ -152,14 +153,14 @@ module('Integration | Component | pki-generate-csr', function (hooks) {
'renders Next steps alert banner'
);
assert
.dom('[data-test-value-div="CSR"] [data-test-certificate-card] button')
.dom(`${GENERAL.infoRowValue('CSR')} [data-test-certificate-card] button`)
.hasAttribute('data-test-copy-button', this.model.csr, 'it renders copyable csr');
assert
.dom('[data-test-value-div="Key ID"] button')
.dom(`${GENERAL.infoRowValue('Key ID')} button`)
.hasAttribute('data-test-copy-button', this.model.keyId, 'it renders copyable key_id');
assert.dom('[data-test-value-div="Private key"]').hasText('internal', 'does not render private key');
assert.dom(GENERAL.infoRowValue('Private key')).hasText('internal', 'does not render private key');
assert
.dom('[data-test-value-div="Private key type"]')
.dom(GENERAL.infoRowValue('Private key type'))
.hasText('internal', 'does not render private key type');
});
});

View File

@ -9,6 +9,7 @@ import { render, settled } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { setupEngine } from 'ember-engines/test-support';
import { PKI_ISSUER_DETAILS } from 'vault/tests/helpers/pki/pki-selectors';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
module('Integration | Component | page/pki-issuer-details', function (hooks) {
setupRenderingTest(hooks);
@ -89,25 +90,23 @@ module('Integration | Component | page/pki-issuer-details', function (hooks) {
// Default group details:
assert.dom(PKI_ISSUER_DETAILS.defaultGroup).exists('Default group of details exists');
assert.dom(PKI_ISSUER_DETAILS.valueByName('Certificate')).exists('Certificate detail exists');
assert.dom(GENERAL.infoRowValue('Certificate')).exists('Certificate detail exists');
assert.dom(PKI_ISSUER_DETAILS.copyButtonByName('Certificate')).exists('Certificate is copyable');
assert.dom(PKI_ISSUER_DETAILS.valueByName('CA Chain')).exists('CA Chain detail exists');
assert.dom(GENERAL.infoRowValue('CA Chain')).exists('CA Chain detail exists');
assert.dom(PKI_ISSUER_DETAILS.copyButtonByName('CA Chain')).exists('CA Chain is copyable');
assert.dom(PKI_ISSUER_DETAILS.valueByName('Common name')).exists('Common name detail exists');
assert.dom(PKI_ISSUER_DETAILS.valueByName('Issuer name')).exists('Issuer name detail exists');
assert.dom(PKI_ISSUER_DETAILS.valueByName('Issuer ID')).exists('Issuer ID detail exists');
assert.dom(GENERAL.infoRowValue('Common name')).exists('Common name detail exists');
assert.dom(GENERAL.infoRowValue('Issuer name')).exists('Issuer name detail exists');
assert.dom(GENERAL.infoRowValue('Issuer ID')).exists('Issuer ID detail exists');
assert.dom(PKI_ISSUER_DETAILS.copyButtonByName('Issuer ID')).exists('Issuer ID is copyable');
assert.dom(PKI_ISSUER_DETAILS.valueByName('Default key ID')).exists('Default key ID detail exists');
assert.dom(GENERAL.infoRowValue('Default key ID')).exists('Default key ID detail exists');
// Issuer URLs group details:
assert.dom(PKI_ISSUER_DETAILS.urlsGroup).exists('Issuer URLs group of details exists');
assert.dom(GENERAL.infoRowValue('Issuing certificates')).exists('Issuing certificates detail exists');
assert
.dom(PKI_ISSUER_DETAILS.valueByName('Issuing certificates'))
.exists('Issuing certificates detail exists');
assert
.dom(PKI_ISSUER_DETAILS.valueByName('CRL distribution points'))
.dom(GENERAL.infoRowValue('CRL distribution points'))
.exists('CRL distribution points detail exists');
assert.dom(PKI_ISSUER_DETAILS.valueByName('OCSP servers')).exists('OCSP servers detail exists');
assert.dom(GENERAL.infoRowValue('OCSP servers')).exists('OCSP servers detail exists');
});
test('it renders parsing error banner if issuer certificate contains unsupported OIDs', async function (assert) {

View File

@ -10,6 +10,7 @@ import { hbs } from 'ember-cli-htmlbars';
import Sinon from 'sinon';
import { setupEngine } from 'ember-engines/test-support';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
const selectors = {
form: '[data-test-sign-intermediate-form]',
@ -21,8 +22,6 @@ const selectors = {
fieldError: '[data-test-inline-alert]',
formError: '[data-test-form-error]',
resultsContainer: '[data-test-sign-intermediate-result]',
rowByName: (name) => `[data-test-row-label="${name}"]`,
valueByName: (name) => `[data-test-value-div="${name}"]`,
};
module('Integration | Component | pki-sign-intermediate-form', function (hooks) {
setupRenderingTest(hooks);
@ -93,12 +92,12 @@ module('Integration | Component | pki-sign-intermediate-form', function (hooks)
{ label: 'Certificate', isCertificate: true },
{ label: 'Issuing CA', isCertificate: true },
].forEach(({ label, isCertificate }) => {
assert.dom(selectors.rowByName(label)).exists();
assert.dom(GENERAL.infoRowLabel(label)).exists();
if (isCertificate) {
assert.dom(selectors.valueByName(label)).includesText('PEM Format', `${label} is isCertificate`);
assert.dom(GENERAL.infoRowValue(label)).includesText('PEM Format', `${label} is isCertificate`);
} else {
assert.dom(selectors.valueByName(label)).hasText('31:52:b9:09:40', `Renders ${label}`);
assert.dom(`${selectors.valueByName(label)} a`).exists(`${label} is a link`);
assert.dom(GENERAL.infoRowValue(label)).hasText('31:52:b9:09:40', `Renders ${label}`);
assert.dom(`${GENERAL.infoRowValue(label)} a`).exists(`${label} is a link`);
}
});
});

View File

@ -11,6 +11,7 @@ import { run } from '@ember/runloop';
import Service from '@ember/service';
import hbs from 'htmlbars-inline-precompile';
import codemirror from 'vault/tests/helpers/codemirror';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
let capabilities;
const storeService = Service.extend({
@ -86,7 +87,7 @@ module('Integration | Component | secret edit', function (hooks) {
},
});
await render(hbs`<SecretEdit @mode={{this.mode}} @model={{this.model}} @key={{this.key}} />`);
assert.dom('[data-test-secret-save]').isNotDisabled();
assert.dom(GENERAL.saveButton).isNotDisabled();
});
test('it shows an error when editing and the data is not an object', async function (assert) {

View File

@ -7,11 +7,11 @@ import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, click } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
const selectors = {
toggle: '[data-test-mount-config-toggle]',
field: '[data-test-mount-config-field]',
rowValue: (label) => `[data-test-value-div="${label}"]`,
};
module('Integration | Component | secrets-engine-mount-config', function (hooks) {
@ -56,15 +56,15 @@ module('Integration | Component | secrets-engine-mount-config', function (hooks)
await click(selectors.toggle);
assert
.dom(selectors.rowValue('Secret Engine Type'))
.dom(GENERAL.infoRowValue('Secret Engine Type'))
.hasText(this.model.engineType, 'Secret engine type renders');
assert.dom(selectors.rowValue('Path')).hasText(this.model.path, 'Path renders');
assert.dom(selectors.rowValue('Accessor')).hasText(this.model.accessor, 'Accessor renders');
assert.dom(selectors.rowValue('Local')).includesText('No', 'Local renders');
assert.dom(selectors.rowValue('Seal Wrap')).includesText('Yes', 'Seal wrap renders');
assert.dom(selectors.rowValue('Default Lease TTL')).includesText('0', 'Default Lease TTL renders');
assert.dom(GENERAL.infoRowValue('Path')).hasText(this.model.path, 'Path renders');
assert.dom(GENERAL.infoRowValue('Accessor')).hasText(this.model.accessor, 'Accessor renders');
assert.dom(GENERAL.infoRowValue('Local')).includesText('No', 'Local renders');
assert.dom(GENERAL.infoRowValue('Seal Wrap')).includesText('Yes', 'Seal wrap renders');
assert.dom(GENERAL.infoRowValue('Default Lease TTL')).includesText('0', 'Default Lease TTL renders');
assert
.dom(selectors.rowValue('Max Lease TTL'))
.dom(GENERAL.infoRowValue('Max Lease TTL'))
.includesText('2 hours 46 minutes 40 seconds', 'Max Lease TTL renders');
});

View File

@ -4,9 +4,10 @@
*/
import { create, visitable, text } from 'ember-cli-page-object';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
export default create({
visit: visitable('/vault/secrets/:backend/configuration'),
defaultTTL: text('[data-test-value-div="Default Lease TTL"]'),
maxTTL: text('[data-test-value-div="Max Lease TTL"]'),
defaultTTL: text(GENERAL.infoRowValue('Default Lease TTL')),
maxTTL: text(GENERAL.infoRowValue('Max Lease TTL')),
});

View File

@ -18,7 +18,6 @@ export default create({
url: fillable('[data-test-input="url"]'),
username: fillable('[data-test-input="username"]'),
password: fillable('[data-test-input="password"]'),
save: clickable('[data-test-secret-save]'),
addRole: clickable('[data-test-add-role]'), // only from connection show
enable: clickable('[data-test-enable-connection]'),
edit: clickable('[data-test-edit-link]'),

View File

@ -14,6 +14,5 @@ export default create({
createLink: clickable('[data-test-secret-create]'),
name: fillable('[data-test-input="name"]'),
roleType: selectable('[data-test-input="type"'),
save: clickable('[data-test-secret-save]'),
edit: clickable('[data-test-edit-link]'),
});

View File

@ -11,6 +11,5 @@ export default create({
path: fillable('[data-test-secret-path="true"]'),
secretKey: fillable('[data-test-secret-key]'),
secretValue: fillable('[data-test-secret-value] textarea'),
save: clickable('[data-test-secret-save]'),
toggleJSON: clickable('[data-test-toggle-input="json"]'),
});

View File

@ -13,9 +13,6 @@ export default create({
path: text('[data-test-secret-path]'),
menu: clickable('[data-test-popup-menu-trigger]'),
}),
configLink: clickable('[data-test-engine-config]', {
testContainer: '#ember-testing',
}),
disableButton: clickable('[data-test-confirm-action-trigger]'),
confirmDisable: clickable('[data-test-confirm-button]'),
console: uiPanel,