2018-02-25 20:34:38 -08:00
|
|
|
import { moduleForComponent, test } from 'ember-qunit';
|
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
import { hdfsUrn } from 'wherehows-web/mirage/fixtures/urn';
|
|
|
|
import sinon from 'sinon';
|
|
|
|
import { waitUntil, find } from 'ember-native-dom-helpers';
|
2018-05-18 15:15:43 -07:00
|
|
|
import { DatasetPlatform, PurgePolicy } from 'wherehows-web/constants';
|
2018-02-25 20:34:38 -08:00
|
|
|
|
|
|
|
moduleForComponent(
|
|
|
|
'datasets/containers/upstream-dataset',
|
|
|
|
'Integration | Component | datasets/containers/upstream dataset',
|
|
|
|
{
|
|
|
|
integration: true,
|
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
this.server = sinon.createFakeServer();
|
|
|
|
this.server.respondImmediately = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
afterEach() {
|
|
|
|
this.server.restore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
test('it renders', async function(assert) {
|
2018-05-18 15:15:43 -07:00
|
|
|
assert.expect(1);
|
|
|
|
const upstreamElement = '.upstream-dataset';
|
2018-02-25 20:34:38 -08:00
|
|
|
|
2018-05-18 15:15:43 -07:00
|
|
|
this.set('urn', hdfsUrn);
|
|
|
|
this.set('platform', DatasetPlatform.HDFS);
|
|
|
|
|
|
|
|
this.server.respondWith(/\/api\/v2\/datasets.*\/upstreams/, function(xhr) {
|
2018-02-25 20:34:38 -08:00
|
|
|
xhr.respond(
|
|
|
|
200,
|
|
|
|
{ 'Content-Type': 'application/json' },
|
2018-05-18 15:15:43 -07:00
|
|
|
JSON.stringify([
|
|
|
|
{
|
2018-02-25 20:34:38 -08:00
|
|
|
nativeName: 'A nativeName',
|
2018-05-18 15:15:43 -07:00
|
|
|
platform: DatasetPlatform.HDFS,
|
|
|
|
uri: hdfsUrn
|
2018-02-25 20:34:38 -08:00
|
|
|
}
|
2018-05-18 15:15:43 -07:00
|
|
|
])
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.server.respondWith(/\/api\/v2\/datasets.*\/compliance/, function(xhr) {
|
|
|
|
xhr.respond(
|
|
|
|
200,
|
|
|
|
{ 'Content-Type': 'application/json' },
|
|
|
|
JSON.stringify({
|
|
|
|
datasetUrn: hdfsUrn
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
const retentionPolicy = {
|
|
|
|
datasetUrn: hdfsUrn,
|
|
|
|
purgeType: PurgePolicy.AutoPurge,
|
|
|
|
purgeNote: null
|
|
|
|
};
|
|
|
|
|
|
|
|
this.server.respondWith('GET', /\/api\/v2\/datasets.*\/retention/, [
|
|
|
|
200,
|
|
|
|
{ 'Content-Type': 'application/json' },
|
|
|
|
JSON.stringify({ retentionPolicy })
|
|
|
|
]);
|
|
|
|
|
|
|
|
this.server.respondWith('POST', /\/api\/v2\/datasets.*\/retention/, [
|
|
|
|
200,
|
|
|
|
{ 'Content-Type': 'application/json' },
|
|
|
|
JSON.stringify({ retentionPolicy })
|
|
|
|
]);
|
|
|
|
|
|
|
|
this.server.respondWith(/\/api\/v2\/list.*\/platforms/, function(xhr) {
|
|
|
|
xhr.respond(
|
|
|
|
200,
|
|
|
|
{ 'Content-Type': 'application/json' },
|
|
|
|
JSON.stringify({
|
|
|
|
platforms: [
|
|
|
|
{
|
|
|
|
name: DatasetPlatform.HDFS,
|
|
|
|
supportedPurgePolicies: [PurgePolicy.AutoLimitedRetention, PurgePolicy.AutoPurge]
|
|
|
|
}
|
|
|
|
]
|
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-18 15:15:43 -07:00
|
|
|
assert.equal(find(upstreamElement).textContent.trim(), 'A nativeName');
|
2018-02-25 20:34:38 -08:00
|
|
|
});
|