mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-12 02:25:43 +00:00
adds test for compliance purge policy and mirage platform factory to support container/upstream-dataset integration test
This commit is contained in:
parent
4af70ed53b
commit
ce70b8d4c0
@ -1,3 +1,10 @@
|
||||
import { Factory } from 'ember-cli-mirage';
|
||||
import { Factory, faker } from 'ember-cli-mirage';
|
||||
import { DatasetPlatform, PurgePolicy } from 'wherehows-web/constants';
|
||||
|
||||
export default Factory.extend({});
|
||||
export default Factory.extend({
|
||||
name: faker.list.random(...Object.values(DatasetPlatform)),
|
||||
|
||||
type: faker.lorem.words(1),
|
||||
|
||||
supportedPurgePolicies: Object.values(PurgePolicy)
|
||||
});
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
import { IFunctionRouteHandler } from 'wherehows-web/typings/ember-cli-mirage';
|
||||
import { ApiStatus } from 'wherehows-web/utils/api/shared';
|
||||
|
||||
const getDatasetPlatforms = function(this: IFunctionRouteHandler) {
|
||||
const getDatasetPlatforms = function(this: IFunctionRouteHandler, { platforms }: { platforms: any }) {
|
||||
return {
|
||||
platforms: [],
|
||||
status: ApiStatus.OK
|
||||
platforms: this.serialize(platforms.all())
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import { moduleForComponent, test } from 'ember-qunit';
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
import { startMirage } from 'wherehows-web/initializers/ember-cli-mirage';
|
||||
import { waitUntil, find } from 'ember-native-dom-helpers';
|
||||
import { waitUntil, find, findAll } from 'ember-native-dom-helpers';
|
||||
import { DatasetPlatform, PurgePolicy } from 'wherehows-web/constants';
|
||||
import { hdfsUrn } from 'wherehows-web/mirage/fixtures/urn';
|
||||
|
||||
const upstreamElement = '.upstream-dataset';
|
||||
|
||||
moduleForComponent(
|
||||
'datasets/containers/upstream-dataset',
|
||||
'Integration | Component | datasets/containers/upstream dataset',
|
||||
@ -25,9 +27,6 @@ test('it renders', async function(assert) {
|
||||
assert.expect(1);
|
||||
const { server } = this;
|
||||
const { nativeName, platform, uri } = server.create('datasetView');
|
||||
server.createList('platform', 4);
|
||||
|
||||
const upstreamElement = '.upstream-dataset';
|
||||
|
||||
this.set('urn', uri);
|
||||
this.set('platform', platform);
|
||||
@ -36,5 +35,58 @@ test('it renders', async function(assert) {
|
||||
|
||||
await waitUntil(() => find(upstreamElement));
|
||||
|
||||
assert.equal(find(upstreamElement).textContent.trim(), nativeName);
|
||||
assert.equal(find(upstreamElement).textContent.trim(), nativeName, 'renders the nativeName for the upstream element');
|
||||
});
|
||||
|
||||
test('upstreams are rendered', async function(assert) {
|
||||
assert.expect(1);
|
||||
const { server } = this;
|
||||
const upstreamsCount = 4;
|
||||
const [{ uri, platform }] = server.createList('datasetView', upstreamsCount);
|
||||
|
||||
this.set('urn', uri);
|
||||
this.set('platform', platform);
|
||||
|
||||
this.render(hbs`{{datasets/containers/upstream-dataset urn=urn platform=platform}}`);
|
||||
|
||||
await waitUntil(() => find(upstreamElement));
|
||||
|
||||
assert.equal(
|
||||
findAll(upstreamElement).length,
|
||||
upstreamsCount,
|
||||
`renders ${upstreamsCount} elements for ${upstreamsCount} upstream datasets`
|
||||
);
|
||||
});
|
||||
|
||||
test('Compliance Purge Policy', async function(assert) {
|
||||
assert.expect(3);
|
||||
|
||||
const downstreamClass = '.downstream-purge-policy';
|
||||
const purgePolicyClass = '.purge-policy-list__item';
|
||||
const defaultMissingText = 'This dataset does not have a current compliance purge policy';
|
||||
const { server } = this;
|
||||
const { platform, uri } = server.create('datasetView');
|
||||
|
||||
this.set('urn', uri);
|
||||
this.set('platform', platform);
|
||||
this.render(hbs`{{datasets/containers/upstream-dataset urn=urn platform=platform}}`);
|
||||
|
||||
await waitUntil(() => find(downstreamClass));
|
||||
|
||||
assert.equal(
|
||||
find(downstreamClass).textContent.trim(),
|
||||
defaultMissingText,
|
||||
'Shows the missing text string when there is no purge policy set'
|
||||
);
|
||||
|
||||
assert.ok(find('#downstream-purge-edit'), 'policy is editable');
|
||||
|
||||
server.create('platform');
|
||||
server.create('retention');
|
||||
|
||||
this.render(hbs`{{datasets/containers/upstream-dataset urn=urn platform=platform}}`);
|
||||
|
||||
await waitUntil(() => find(purgePolicyClass) && find(purgePolicyClass).textContent.trim() !== defaultMissingText);
|
||||
|
||||
assert.ok(find.bind(find, purgePolicyClass), 'purge policy radio is rendered');
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user