mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-15 02:57:04 +02:00
* Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License. Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUS-1.1 * Fix test that expected exact offset on hcl file --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Sarah Thompson <sthompson@hashicorp.com> Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
87 lines
2.8 KiB
JavaScript
87 lines
2.8 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import { render } from '@ember/test-helpers';
|
|
import { setupEngine } from 'ember-engines/test-support';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
const CLUSTER = {
|
|
canAddSecondary: true,
|
|
replicationMode: 'dr',
|
|
};
|
|
|
|
const REPLICATION_ATTRS = {
|
|
secondaries: [
|
|
{ node_id: 'secondary-1', api_address: 'https://stuff.com/', connection_status: 'connected' },
|
|
{ node_id: '2nd', connection_status: 'disconnected' },
|
|
{ node_id: '_three_', api_address: 'https://10.0.0.2:1000/', connection_status: 'connected' },
|
|
],
|
|
};
|
|
|
|
module('Integration | Component | replication known-secondaries-card', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
setupEngine(hooks, 'replication');
|
|
|
|
hooks.beforeEach(function () {
|
|
this.context = { owner: this.engine }; // this.engine set by setupEngine
|
|
this.set('cluster', CLUSTER);
|
|
this.set('replicationAttrs', REPLICATION_ATTRS);
|
|
});
|
|
|
|
test('it renders with a table of known secondaries', async function (assert) {
|
|
await render(
|
|
hbs`<KnownSecondariesCard @cluster={{this.cluster}} @replicationAttrs={{this.replicationAttrs}} />`,
|
|
this.context
|
|
);
|
|
|
|
assert
|
|
.dom('[data-test-known-secondaries-table]')
|
|
.exists('shows known secondaries table when there are known secondaries');
|
|
assert.dom('[data-test-manage-link]').exists('shows manage link');
|
|
});
|
|
|
|
test('it renders an empty state if there are no known secondaries', async function (assert) {
|
|
const noSecondaries = {
|
|
secondaries: [],
|
|
};
|
|
this.set('replicationAttrs', noSecondaries);
|
|
await render(
|
|
hbs`<KnownSecondariesCard @cluster={{this.cluster}} @replicationAttrs={{this.replicationAttrs}} />`,
|
|
this.context
|
|
);
|
|
|
|
assert
|
|
.dom('[data-test-known-secondaries-table]')
|
|
.doesNotExist('does not show the known secondaries table');
|
|
assert
|
|
.dom('.empty-state')
|
|
.includesText('No known dr secondary clusters', 'has a message with the replication mode');
|
|
});
|
|
|
|
test('it renders an Add secondary link if user has capabilites', async function (assert) {
|
|
await render(
|
|
hbs`<KnownSecondariesCard @cluster={{this.cluster}} @replicationAttrs={{this.replicationAttrs}} />`,
|
|
this.context
|
|
);
|
|
|
|
assert.dom('.add-secondaries').exists();
|
|
});
|
|
|
|
test('it does not render an Add secondary link if user does not have capabilites', async function (assert) {
|
|
const noCapabilities = {
|
|
canAddSecondary: false,
|
|
};
|
|
this.set('cluster', noCapabilities);
|
|
await render(
|
|
hbs`<KnownSecondariesCard @cluster={{this.cluster}} @replicationAttrs={{this.replicationAttrs}} />`,
|
|
this.context
|
|
);
|
|
|
|
assert.dom('.add-secondaries').doesNotExist();
|
|
});
|
|
});
|