2018-02-25 20:34:38 -08:00
|
|
|
import { moduleForComponent, test } from 'ember-qunit';
|
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
2018-05-21 00:19:45 -07:00
|
|
|
import { startMirage } from 'wherehows-web/initializers/ember-cli-mirage';
|
2018-05-21 01:38:07 -07:00
|
|
|
import { waitUntil, find, findAll } from 'ember-native-dom-helpers';
|
2018-05-18 15:15:43 -07:00
|
|
|
import { DatasetPlatform, PurgePolicy } from 'wherehows-web/constants';
|
2018-05-21 00:19:45 -07:00
|
|
|
import { hdfsUrn } from 'wherehows-web/mirage/fixtures/urn';
|
2018-02-25 20:34:38 -08:00
|
|
|
|
2018-05-21 01:38:07 -07:00
|
|
|
const upstreamElement = '.upstream-dataset';
|
|
|
|
|
2018-02-25 20:34:38 -08:00
|
|
|
moduleForComponent(
|
|
|
|
'datasets/containers/upstream-dataset',
|
|
|
|
'Integration | Component | datasets/containers/upstream dataset',
|
|
|
|
{
|
|
|
|
integration: true,
|
|
|
|
|
|
|
|
beforeEach() {
|
2018-05-21 00:19:45 -07:00
|
|
|
this.server = startMirage();
|
2018-02-25 20:34:38 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
afterEach() {
|
2018-05-21 00:19:45 -07:00
|
|
|
this.server.shutdown();
|
2018-02-25 20:34:38 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
test('it renders', async function(assert) {
|
2018-05-18 15:15:43 -07:00
|
|
|
assert.expect(1);
|
2018-05-21 00:19:45 -07:00
|
|
|
const { server } = this;
|
|
|
|
const { nativeName, platform, uri } = server.create('datasetView');
|
2018-05-18 15:15:43 -07:00
|
|
|
|
2018-05-21 01:38:07 -07:00
|
|
|
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(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);
|
2018-05-18 15:15:43 -07:00
|
|
|
|
2018-05-21 00:19:45 -07:00
|
|
|
this.set('urn', uri);
|
|
|
|
this.set('platform', platform);
|
2018-02-25 20:34:38 -08:00
|
|
|
|
2018-05-18 15:15:43 -07:00
|
|
|
this.render(hbs`{{datasets/containers/upstream-dataset urn=urn platform=platform}}`);
|
2018-02-25 20:34:38 -08:00
|
|
|
|
2018-05-18 15:15:43 -07:00
|
|
|
await waitUntil(() => find(upstreamElement));
|
2018-02-25 20:34:38 -08:00
|
|
|
|
2018-05-21 01:38:07 -07:00
|
|
|
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');
|
2018-02-25 20:34:38 -08:00
|
|
|
});
|