Angel Garbarino a51c5ed362
Clean up button test selectors (#30694)
* clean up selectors file and then update testButton to buttonByAttr

* a lot but not really in the scheme of things

* fix component test failures

* fix acceptance test failures

* fix namespace selector

* clean up remaining tests

* another test

* last test

* small changes, but I have test failures

* a mess in custom messages, really hard to test because of test pollution.

* make data-test-submit vs data-test-save

* change other-methods to sign in with other methods

* clean up of failing test

* buttonByAttr to button

* clean up test pollution on config messages

* sweep of clean ups

* another round of small cleanups

* fix some message things, remaining oidc issue?

* use a runCmd to better delete things

* fix to amend for recent auth test changes

* remove skip
2025-06-10 16:25:34 -04:00

103 lines
4.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { setupEngine } from 'ember-engines/test-support';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
module('Integration | Component | kubernetes | Page::Configuration', function (hooks) {
setupRenderingTest(hooks);
setupEngine(hooks, 'kubernetes');
setupMirage(hooks);
hooks.beforeEach(function () {
this.store = this.owner.lookup('service:store');
this.store.pushPayload('secret-engine', {
modelName: 'secret-engine',
data: {
accessor: 'kubernetes_f3400dee',
path: 'kubernetes-test/',
type: 'kubernetes',
},
});
this.backend = this.store.peekRecord('secret-engine', 'kubernetes-test');
this.config = null;
this.setConfig = (disableLocal) => {
const data = this.server.create(
'kubernetes-config',
!disableLocal ? { disable_local_ca_jwt: false } : null
);
this.store.pushPayload('kubernetes/config', {
modelName: 'kubernetes/config',
backend: 'kubernetes-test',
...data,
});
this.config = this.store.peekRecord('kubernetes/config', 'kubernetes-test');
};
this.breadcrumbs = [
{ label: 'Secrets', route: 'secrets', linkExternal: true },
{ label: this.backend.id },
];
this.renderComponent = () => {
return render(
hbs`<Page::Configuration @backend={{this.backend}} @config={{this.config}} @breadcrumbs={{this.breadcrumbs}} />`,
{
owner: this.engine,
}
);
};
});
test('it should render tab page header, config cta and mount config', async function (assert) {
await this.renderComponent();
assert.dom('.title svg').hasClass('hds-icon-kubernetes-color', 'Kubernetes icon renders in title');
assert.dom('.title').hasText('kubernetes-test', 'Mount path renders in title');
assert
.dom('[data-test-toolbar-config-action]')
.hasText('Configure Kubernetes', 'Toolbar action has correct text');
assert.dom('[data-test-config-cta]').exists('Config cta renders');
assert.dom('[data-test-mount-config]').exists('Mount config renders');
});
test('it should render message for inferred configuration', async function (assert) {
this.setConfig(false);
await this.renderComponent();
assert
.dom('[data-test-inferred-message] svg')
.hasClass('hds-icon-check-circle-fill', 'Inferred message icon renders');
const message =
'These details were successfully inferred from Vaults kubernetes environment and were not explicity set in this config.';
assert.dom('[data-test-inferred-message]').hasText(message, 'Inferred message renders');
assert
.dom('[data-test-toolbar-config-action]')
.hasText('Edit configuration', 'Toolbar action has correct text');
});
test('it should render host and certificate info', async function (assert) {
this.setConfig(true);
await this.renderComponent();
assert.dom('[data-test-row-label="Kubernetes host"]').exists('Kubernetes host label renders');
assert
.dom('[data-test-row-value="Kubernetes host"]')
.hasText(this.config.kubernetesHost, 'Kubernetes host value renders');
assert.dom('[data-test-row-label="Certificate"]').exists('Certificate label renders');
assert.dom('[data-test-certificate-card]').exists('Certificate card component renders');
assert.dom('[data-test-certificate-icon]').hasClass('hds-icon-certificate', 'Certificate icon renders');
assert.dom(GENERAL.copyButton).exists('Certificate copy button renders');
assert.dom('[data-test-certificate-label]').hasText('PEM Format', 'Certificate label renders');
assert
.dom('[data-test-certificate-value]')
.hasText(this.config.kubernetesCaCert, 'Certificate value renders');
});
});