mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-11 09:07:00 +02:00
* KMSE: Key Model / Adapter / Serializer setup (#13638) * First pass model * KMS key adapter (create/update), serializer, model * Add last rotated and provider to key * KeyEdit secret-edit component, and more key model stuff * add formatDate param support to infotablerow * Add keymgmt key to routes and options-for-backend * Rename keymgmt-key to keymgmt/key * Add test, cleanup * Add mirage handler for kms * Address PR comments * KMS Providers (#13797) * adds pagination-controls component * adds kms provider model, adapter and serializer * adds kms provider-edit component * updates secrets routes to handle itemType query param for kms * updates kms key adapter to query by provider * adds tests for provider-edit component * refactors kms provider adapter to account for dynamic path * adds model-validations-helper util * removes keymgmt from supported-secret-backends * fixes issue generating url for fetching keys for a provider * updates modelType method on secret-edit route to accept options object as arg rather than transition * adds additional checks to ensure queryParams are defined in options object for modelType method * UI/keymgmt distribute key (#13840) * Add distribution details on key page, and empty states if no permissions * Allow search-select component to return object so parent can tell when new item was created * Add stringarray transform * Distribute component first pass * Refactor distribute component for use with internal object rather than ember-data model * Specific permission denied errors on key edit * Allow inline errors on search-select component * Style updates for form errors * Styling and error messages on distribute component * Allow block template on inline alert so we can add doc links * Add distribute action, flash messages, cleanup * Cleanup & Add tests * More cleanup * Address PR comments * Move disable operations logic to commponent class * KMSE Enable/Config (#14835) * adds keymgmt secrets engine as supported backend * adds comment to check on keymgmt as member of adp module * updates kms provider to use model-validations decorator * fixes lint errors and tests Co-authored-by: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com>
75 lines
2.5 KiB
JavaScript
75 lines
2.5 KiB
JavaScript
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import { render } from '@ember/test-helpers';
|
|
import { hbs } from 'ember-cli-htmlbars';
|
|
import { click } from '@ember/test-helpers';
|
|
|
|
module('Integration | Component | pagination-controls', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
test('it renders correct number of pages', async function (assert) {
|
|
const totals = [
|
|
[10, 1],
|
|
[40, 3],
|
|
[100, 5],
|
|
];
|
|
for (const [total, count] of totals) {
|
|
this.total = total;
|
|
await render(hbs`<PaginationControls @total={{this.total}} />`);
|
|
assert
|
|
.dom('[data-test-page]')
|
|
.exists({ count }, `Correct page count of ${count} renders for ${total} total items`);
|
|
assert.dom('[data-test-more-pages]')[count === 5 ? 'exists' : 'doesNotExist']();
|
|
}
|
|
});
|
|
|
|
test('it changes pages', async function (assert) {
|
|
assert.expect(10);
|
|
|
|
let expectedPage = 2;
|
|
this.onChange = (page) => {
|
|
assert.equal(page, expectedPage, 'onChange callback is fired with correct page number');
|
|
};
|
|
|
|
await render(hbs`<PaginationControls @total={{75}} @onChange={{this.onChange}} />`);
|
|
|
|
const isActive = (page) => {
|
|
return this.element
|
|
.querySelector(`[data-test-page="${page}"]`)
|
|
.classList.value.includes('is-primary is-underlined is-active');
|
|
};
|
|
|
|
assert.ok(isActive(1), 'Page 1 is active by default');
|
|
assert.dom('[data-test-previous-page]').isDisabled('Previous page button is disabled on page 1');
|
|
|
|
await click('[data-test-next-page]');
|
|
assert.ok(isActive(2), 'Page 2 is active');
|
|
assert.dom('[data-test-previous-page]').isNotDisabled('Previous page button is disabled on page 1');
|
|
|
|
expectedPage = 5;
|
|
await click('[data-test-page="5"]');
|
|
assert.ok(isActive(5), 'Page 5 is active');
|
|
assert.dom('[data-test-next-page]').isDisabled('Next page button is disabled on last page');
|
|
|
|
expectedPage = 4;
|
|
await click('[data-test-previous-page]');
|
|
assert.ok(isActive(4), 'Page 4 is active');
|
|
});
|
|
|
|
test('it renders correct display info', async function (assert) {
|
|
this.onChange = () => {};
|
|
await render(hbs`<PaginationControls @total={{68}} @onChange={{this.onChange}} />`);
|
|
|
|
const ranges = ['1-15', '16-30', '31-45', '46-60', '61-68'];
|
|
for (const [i, range] of ranges.entries()) {
|
|
assert
|
|
.dom('[data-test-page-display-info]')
|
|
.hasText(`${range} of 68`, `Correct display info renders for page ${i + 1}`);
|
|
|
|
if (i < 4) {
|
|
await click(`[data-test-next-page]`);
|
|
}
|
|
}
|
|
});
|
|
});
|