claire bontempo 7874f06ca3
UI: Only include upgrades with previous versions (#26870)
* only include upgrades with previous versions

* update tests

* fix prettier linting

* update counts test

* why are you failing??

* match key order of expected object to actual

* timezones -_-

* attempt to fix flaky openapi test again
2024-05-08 13:29:07 +00:00

61 lines
2.0 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { module, test } from 'qunit';
import { setupRenderingTest } from 'vault/tests/helpers';
import { fillIn, render, typeIn, waitFor } from '@ember/test-helpers';
import { setupEngine } from 'ember-engines/test-support';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { hbs } from 'ember-cli-htmlbars';
const SELECTORS = {
container: '[data-test-swagger-ui]',
searchInput: 'input.operation-filter-input',
apiPathBlock: '.opblock-post',
};
module('Integration | Component | open-api-explorer | swagger-ui', function (hooks) {
setupRenderingTest(hooks);
setupEngine(hooks, 'open-api-explorer');
setupMirage(hooks);
hooks.beforeEach(function () {
this.store = this.owner.lookup('service:store');
const openApiResponse = this.server.create('open-api-explorer');
this.server.get('sys/internal/specs/openapi', () => {
return openApiResponse;
});
this.totalApiPaths = Object.keys(openApiResponse.paths).length;
this.renderComponent = async () => {
await render(hbs`<SwaggerUi/>`, {
owner: this.engine,
});
};
});
test(`it renders`, async function (assert) {
await this.renderComponent();
await waitFor(SELECTORS.container);
assert.dom(SELECTORS.container).exists('renders component');
assert.dom(SELECTORS.apiPathBlock).exists({ count: this.totalApiPaths }, 'renders all api paths');
});
test(`it can search`, async function (assert) {
await this.renderComponent();
// in testing only the input is not filling correctly except after the second time
await fillIn(SELECTORS.searchInput, 'moot');
await typeIn(SELECTORS.searchInput, 'token');
// for some reason search results are not rendered immediately in tests,
// so asserting that the search input has the value we expect is the best we can do here
// if the search fn breaks, this test will fail
assert.dom(SELECTORS.searchInput).hasValue('token', 'search input has value');
});
});