fixes failing tests for purge-policy and upstream-dataset components

This commit is contained in:
Seyi Adebajo 2018-05-18 15:15:43 -07:00
parent c726f136a1
commit d64ce2e202
7 changed files with 148 additions and 160 deletions

View File

@ -5,7 +5,7 @@ import { action } from '@ember-decorators/object';
export default class UpstreamDataset extends Component { export default class UpstreamDataset extends Component {
tagName = 'section'; tagName = 'section';
classNames = ['upstream-dataset-banner']; classNames = ['upstream-downstream-retention'];
/** /**
* Flag indicating the component is in view only mode and not editable * Flag indicating the component is in view only mode and not editable

View File

@ -23,7 +23,7 @@ export default class PurgePolicyComponent extends Component {
* Reference to the informational text if the dataset does not have a saved purge policy * Reference to the informational text if the dataset does not have a saved purge policy
* @type {string} * @type {string}
*/ */
missingPolicyText: string = ''; missingPolicyText: string;
/** /**
* Reference to client options for each purge policy * Reference to client options for each purge policy

View File

@ -1,29 +1,3 @@
.upstream-dataset-banner {
&:hover {
.upstream-dataset-banner__description {
height: item-spacing(7);
}
}
&__description {
margin: 0;
height: 0;
overflow: hidden;
transition: height 0.2s ease-in-out;
}
&__informational {
display: flex;
flex-direction: row;
align-items: center;
&__text {
margin: 0;
padding: item-spacing(2);
}
}
}
.upstream-dataset { .upstream-dataset {
@include nacho-container; @include nacho-container;
padding: item-spacing(2 5); padding: item-spacing(2 5);

View File

@ -1,16 +1,15 @@
<section class="upstream-dataset-banner__content"> <h3>Compliance Info</h3>
<h3>Compliance Info</h3> <p>
<p>
Compliance Policy on this dataset is inherited from it's parent dataset(s). To make modifications on the purge Compliance Policy on this dataset is inherited from it's parent dataset(s). To make modifications on the purge
<br> <br>
policy on this page, please complete the Compliance Metadata on all of the parent datasets. policy on this page, please complete the Compliance Metadata on all of the parent datasets.
</p> </p>
<hr class="nacho-divider"> <hr class="nacho-divider">
<h4>Parent Dataset</h4> <h4>Parent Dataset</h4>
{{#each upstreamsMetadata as |parent|}} {{#each upstreamsMetadata as |parent|}}
<div class="upstream-dataset"> <div class="upstream-dataset">
<span class="upstream-dataset__compliance-status"> <span class="upstream-dataset__compliance-status">
{{tooltip-on-element {{tooltip-on-element
@ -43,9 +42,9 @@
{{/link-to}} {{/link-to}}
</div> </div>
{{/each}} {{/each}}
<header class="downstream-purge-policy-header"> <header class="downstream-purge-policy-header">
<h4>Compliance Purge Policy</h4> <h4>Compliance Purge Policy</h4>
<div class="downstream-purge-policy__edit"> <div class="downstream-purge-policy__edit">
{{#unless hasIncompleteUpstream}} {{#unless hasIncompleteUpstream}}
@ -77,9 +76,9 @@
{{/unless}} {{/unless}}
</div> </div>
</header> </header>
<div class="downstream-purge-policy"> <div class="downstream-purge-policy">
{{#if hasIncompleteUpstream}} {{#if hasIncompleteUpstream}}
<p class="downstream-purge-policy__no-policy"> <p class="downstream-purge-policy__no-policy">
This dataset does not have a current compliance purge policy. To update, please complete the Compliance Metadata This dataset does not have a current compliance purge policy. To update, please complete the Compliance Metadata
@ -97,5 +96,4 @@
onPolicyChange=onChange onPolicyChange=onChange
}} }}
{{/if}} {{/if}}
</div> </div>
</section>

View File

@ -3,6 +3,7 @@ import hbs from 'htmlbars-inline-precompile';
import { hdfsUrn } from 'wherehows-web/mirage/fixtures/urn'; import { hdfsUrn } from 'wherehows-web/mirage/fixtures/urn';
import sinon from 'sinon'; import sinon from 'sinon';
import { waitUntil, find } from 'ember-native-dom-helpers'; import { waitUntil, find } from 'ember-native-dom-helpers';
import { DatasetPlatform, PurgePolicy } from 'wherehows-web/constants';
moduleForComponent( moduleForComponent(
'datasets/containers/upstream-dataset', 'datasets/containers/upstream-dataset',
@ -22,28 +23,72 @@ moduleForComponent(
); );
test('it renders', async function(assert) { test('it renders', async function(assert) {
assert.expect(2); assert.expect(1);
const titleElementQuery = '.upstream-dataset-banner__title strong'; const upstreamElement = '.upstream-dataset';
const descriptionElementQuery = '.upstream-dataset-banner__description strong';
this.set('upstreamUrn', hdfsUrn); this.set('urn', hdfsUrn);
this.server.respondWith(/\/api\/v2\/datasets.*/, function(xhr) { this.set('platform', DatasetPlatform.HDFS);
this.server.respondWith(/\/api\/v2\/datasets.*\/upstreams/, function(xhr) {
xhr.respond(
200,
{ 'Content-Type': 'application/json' },
JSON.stringify([
{
nativeName: 'A nativeName',
platform: DatasetPlatform.HDFS,
uri: hdfsUrn
}
])
);
});
this.server.respondWith(/\/api\/v2\/datasets.*\/compliance/, function(xhr) {
xhr.respond( xhr.respond(
200, 200,
{ 'Content-Type': 'application/json' }, { 'Content-Type': 'application/json' },
JSON.stringify({ JSON.stringify({
dataset: { datasetUrn: hdfsUrn
nativeName: 'A nativeName',
description: 'A dataset description'
}
}) })
); );
}); });
this.render(hbs`{{datasets/containers/upstream-dataset upstreamUrn=upstreamUrn}}`); const retentionPolicy = {
datasetUrn: hdfsUrn,
purgeType: PurgePolicy.AutoPurge,
purgeNote: null
};
await waitUntil(() => find(descriptionElementQuery)); this.server.respondWith('GET', /\/api\/v2\/datasets.*\/retention/, [
200,
{ 'Content-Type': 'application/json' },
JSON.stringify({ retentionPolicy })
]);
assert.equal(find(titleElementQuery).textContent.trim(), 'A nativeName'); this.server.respondWith('POST', /\/api\/v2\/datasets.*\/retention/, [
assert.equal(find(descriptionElementQuery).textContent.trim(), 'A dataset description'); 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]
}
]
})
);
});
this.render(hbs`{{datasets/containers/upstream-dataset urn=urn platform=platform}}`);
await waitUntil(() => find(upstreamElement));
assert.equal(find(upstreamElement).textContent.trim(), 'A nativeName');
}); });

View File

@ -9,40 +9,14 @@ moduleForComponent('datasets/upstream-dataset', 'Integration | Component | datas
test('it renders', function(assert) { test('it renders', function(assert) {
this.render(hbs`{{datasets/upstream-dataset}}`); this.render(hbs`{{datasets/upstream-dataset}}`);
assert.ok(document.querySelector('.upstream-dataset-banner'), 'renders upstream-dataset as expected'); assert.ok(document.querySelector('.upstream-downstream-retention'), 'renders upstream-dataset as expected');
}); });
test('it renders upstream dataset properties', function(assert) { test('it renders upstream dataset properties', function(assert) {
const titleElementQuery = '.upstream-dataset-banner__title strong'; const upstreamLink = '.upstream-dataset__upstream-link';
const descriptionElementQuery = '.upstream-dataset-banner__description strong'; const upstreamsMetadata = [{}, {}];
const nativeName = 'Upstream Dataset'; this.set('upstreamsMetadata', upstreamsMetadata);
const description = 'Upstream Dataset Description'; this.render(hbs`{{datasets/upstream-dataset upstreamsMetadata=upstreamsMetadata}}`);
this.set('nativeName', nativeName); assert.equal(document.querySelectorAll(upstreamLink).length, 2, 'renders a link for each upstream dataset');
this.set('description', description);
this.render(hbs`{{datasets/upstream-dataset nativeName=nativeName description=description}}`);
assert.ok(
document
.querySelector(titleElementQuery)
.textContent.trim()
.includes(nativeName),
'renders nativeName'
);
assert.ok(
document
.querySelector(descriptionElementQuery)
.textContent.trim()
.includes(description),
'renders description'
);
});
test('it creates a link to the upstream dataset', function(assert) {
this.set('upstreamUrn', hdfsUrn);
this.render(hbs`{{datasets/upstream-dataset upstreamUrn=upstreamUrn}}`);
assert.ok(document.querySelector('.upstream-dataset-banner a'), 'anchor element is rendered');
}); });

View File

@ -3,13 +3,7 @@ import hbs from 'htmlbars-inline-precompile';
import { triggerEvent } from 'ember-native-dom-helpers'; import { triggerEvent } from 'ember-native-dom-helpers';
import sinon from 'sinon'; import sinon from 'sinon';
import { import { purgePolicyProps, exemptPolicy, PurgePolicy, getSupportedPurgePolicies } from 'wherehows-web/constants';
missingPolicyText,
purgePolicyProps,
exemptPolicy,
PurgePolicy,
getSupportedPurgePolicies
} from 'wherehows-web/constants';
import { DatasetPlatform } from 'wherehows-web/constants/datasets/platform'; import { DatasetPlatform } from 'wherehows-web/constants/datasets/platform';
import platforms from 'wherehows-web/mirage/fixtures/list-platforms'; import platforms from 'wherehows-web/mirage/fixtures/list-platforms';
import { ApiStatus } from 'wherehows-web/utils/api'; import { ApiStatus } from 'wherehows-web/utils/api';
@ -28,6 +22,7 @@ moduleForComponent('purge-policy', 'Integration | Component | purge policy', {
const policyList = '.purge-policy-list'; const policyList = '.purge-policy-list';
const policyTypes = Object.keys(purgePolicyProps); const policyTypes = Object.keys(purgePolicyProps);
const missingPolicyText = 'No policy';
test('it renders', function(assert) { test('it renders', function(assert) {
assert.expect(1); assert.expect(1);
@ -70,9 +65,11 @@ test('it triggers the onPolicyChange action', function(assert) {
test('it renders a user message if the purge policy is not set and is in readonly mode', function(assert) { test('it renders a user message if the purge policy is not set and is in readonly mode', function(assert) {
assert.expect(1); assert.expect(1);
this.render(hbs`{{purge-policy}}`); this.set('missingPolicyText', missingPolicyText);
this.set('isEditable', false);
this.render(hbs`{{purge-policy missingPolicyText=missingPolicyText isEditable=isEditable}}`);
assert.equal( assert.equal(
document.querySelector(`${policyList} p`).textContent, document.querySelector(`${policyList}`).textContent.trim(),
missingPolicyText, missingPolicyText,
`${missingPolicyText} is rendered` `${missingPolicyText} is rendered`
); );