mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-30 03:56:04 +00:00
fixes failing tests for purge-policy and upstream-dataset components
This commit is contained in:
parent
c726f136a1
commit
d64ce2e202
@ -5,7 +5,7 @@ import { action } from '@ember-decorators/object';
|
||||
export default class UpstreamDataset extends Component {
|
||||
tagName = 'section';
|
||||
|
||||
classNames = ['upstream-dataset-banner'];
|
||||
classNames = ['upstream-downstream-retention'];
|
||||
|
||||
/**
|
||||
* Flag indicating the component is in view only mode and not editable
|
||||
|
@ -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
|
||||
* @type {string}
|
||||
*/
|
||||
missingPolicyText: string = '';
|
||||
missingPolicyText: string;
|
||||
|
||||
/**
|
||||
* Reference to client options for each purge policy
|
||||
|
@ -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 {
|
||||
@include nacho-container;
|
||||
padding: item-spacing(2 5);
|
||||
|
@ -1,17 +1,16 @@
|
||||
<section class="upstream-dataset-banner__content">
|
||||
<h3>Compliance Info</h3>
|
||||
<p>
|
||||
Compliance Policy on this dataset is inherited from it's parent dataset(s). To make modifications on the purge
|
||||
<br>
|
||||
policy on this page, please complete the Compliance Metadata on all of the parent datasets.
|
||||
</p>
|
||||
<h3>Compliance Info</h3>
|
||||
<p>
|
||||
Compliance Policy on this dataset is inherited from it's parent dataset(s). To make modifications on the purge
|
||||
<br>
|
||||
policy on this page, please complete the Compliance Metadata on all of the parent datasets.
|
||||
</p>
|
||||
|
||||
<hr class="nacho-divider">
|
||||
<hr class="nacho-divider">
|
||||
|
||||
<h4>Parent Dataset</h4>
|
||||
<h4>Parent Dataset</h4>
|
||||
|
||||
{{#each upstreamsMetadata as |parent|}}
|
||||
<div class="upstream-dataset">
|
||||
{{#each upstreamsMetadata as |parent|}}
|
||||
<div class="upstream-dataset">
|
||||
<span class="upstream-dataset__compliance-status">
|
||||
{{tooltip-on-element
|
||||
text=(if parent.hasCompliance "Compliance completed for parent dataset" "Please complete the Compliance on this parent dataset")
|
||||
@ -24,78 +23,77 @@
|
||||
{{/if}}
|
||||
</span>
|
||||
|
||||
{{#link-to
|
||||
"datasets.dataset"
|
||||
"urn"
|
||||
(query-params urn=parent.urn)
|
||||
class="upstream-dataset__upstream-link"
|
||||
}}
|
||||
<strong>{{parent.nativeName}}</strong>
|
||||
{{/link-to}}
|
||||
{{#link-to
|
||||
"datasets.dataset"
|
||||
"urn"
|
||||
(query-params urn=parent.urn)
|
||||
class="upstream-dataset__upstream-link"
|
||||
}}
|
||||
<strong>{{parent.nativeName}}</strong>
|
||||
{{/link-to}}
|
||||
|
||||
{{#link-to
|
||||
"datasets.dataset"
|
||||
"urn"
|
||||
(query-params urn=parent.urn)
|
||||
class="upstream-dataset__upstream-link-chevron"
|
||||
}}
|
||||
<i class="glyphicon glyphicon-menu-right" aria-label="Navigate to upstream dataset"></i>
|
||||
{{/link-to}}
|
||||
{{#link-to
|
||||
"datasets.dataset"
|
||||
"urn"
|
||||
(query-params urn=parent.urn)
|
||||
class="upstream-dataset__upstream-link-chevron"
|
||||
}}
|
||||
<i class="glyphicon glyphicon-menu-right" aria-label="Navigate to upstream dataset"></i>
|
||||
{{/link-to}}
|
||||
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/each}}
|
||||
|
||||
<header class="downstream-purge-policy-header">
|
||||
<h4>Compliance Purge Policy</h4>
|
||||
<div class="downstream-purge-policy__edit">
|
||||
{{#unless hasIncompleteUpstream}}
|
||||
<label for="downstream-purge-edit" class="downstream-purge-policy__edit--label">
|
||||
Modifying this will not affect the purge policy on the parent dataset
|
||||
</label>
|
||||
<header class="downstream-purge-policy-header">
|
||||
<h4>Compliance Purge Policy</h4>
|
||||
<div class="downstream-purge-policy__edit">
|
||||
{{#unless hasIncompleteUpstream}}
|
||||
<label for="downstream-purge-edit" class="downstream-purge-policy__edit--label">
|
||||
Modifying this will not affect the purge policy on the parent dataset
|
||||
</label>
|
||||
|
||||
{{#if isReadOnly}}
|
||||
<button
|
||||
class="nacho-button nacho-button--large"
|
||||
id="downstream-purge-edit"
|
||||
onclick={{action "onEdit"}}>
|
||||
Edit
|
||||
</button>
|
||||
{{else}}
|
||||
<button
|
||||
class="nacho-button nacho-button--large"
|
||||
disabled={{not retention.purgeType}}
|
||||
{{#if isReadOnly}}
|
||||
<button
|
||||
class="nacho-button nacho-button--large"
|
||||
id="downstream-purge-edit"
|
||||
onclick={{action "onEdit"}}>
|
||||
Edit
|
||||
</button>
|
||||
{{else}}
|
||||
<button
|
||||
class="nacho-button nacho-button--large"
|
||||
disabled={{not retention.purgeType}}
|
||||
onclick={{perform saveRetentionTask}}>
|
||||
|
||||
{{#if saveRetentionTask.isRunning}}
|
||||
{{pendulum-ellipsis-animation}}
|
||||
{{else}}
|
||||
Save
|
||||
{{/if}}
|
||||
{{#if saveRetentionTask.isRunning}}
|
||||
{{pendulum-ellipsis-animation}}
|
||||
{{else}}
|
||||
Save
|
||||
{{/if}}
|
||||
|
||||
</button>
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
</div>
|
||||
|
||||
</header>
|
||||
|
||||
<div class="downstream-purge-policy">
|
||||
{{#if hasIncompleteUpstream}}
|
||||
<p class="downstream-purge-policy__no-policy">
|
||||
This dataset does not have a current compliance purge policy. To update, please complete the Compliance Metadata
|
||||
on the parent dataset(s).
|
||||
</p>
|
||||
{{else}}
|
||||
|
||||
{{purge-policy
|
||||
isEditable=(not isReadOnly)
|
||||
platform=platform
|
||||
supportedPurgePolicies=supportedPurgePolicies
|
||||
purgeNote=retention.purgeNote
|
||||
purgePolicy=(readonly retention.purgeType)
|
||||
missingPolicyText="This dataset does not have a current compliance purge policy"
|
||||
onPolicyChange=onChange
|
||||
}}
|
||||
{{/if}}
|
||||
</button>
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</header>
|
||||
|
||||
<div class="downstream-purge-policy">
|
||||
{{#if hasIncompleteUpstream}}
|
||||
<p class="downstream-purge-policy__no-policy">
|
||||
This dataset does not have a current compliance purge policy. To update, please complete the Compliance Metadata
|
||||
on the parent dataset(s).
|
||||
</p>
|
||||
{{else}}
|
||||
|
||||
{{purge-policy
|
||||
isEditable=(not isReadOnly)
|
||||
platform=platform
|
||||
supportedPurgePolicies=supportedPurgePolicies
|
||||
purgeNote=retention.purgeNote
|
||||
purgePolicy=(readonly retention.purgeType)
|
||||
missingPolicyText="This dataset does not have a current compliance purge policy"
|
||||
onPolicyChange=onChange
|
||||
}}
|
||||
{{/if}}
|
||||
</div>
|
||||
|
@ -3,6 +3,7 @@ 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';
|
||||
import { DatasetPlatform, PurgePolicy } from 'wherehows-web/constants';
|
||||
|
||||
moduleForComponent(
|
||||
'datasets/containers/upstream-dataset',
|
||||
@ -22,28 +23,72 @@ moduleForComponent(
|
||||
);
|
||||
|
||||
test('it renders', async function(assert) {
|
||||
assert.expect(2);
|
||||
const titleElementQuery = '.upstream-dataset-banner__title strong';
|
||||
const descriptionElementQuery = '.upstream-dataset-banner__description strong';
|
||||
assert.expect(1);
|
||||
const upstreamElement = '.upstream-dataset';
|
||||
|
||||
this.set('upstreamUrn', hdfsUrn);
|
||||
this.server.respondWith(/\/api\/v2\/datasets.*/, function(xhr) {
|
||||
this.set('urn', hdfsUrn);
|
||||
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(
|
||||
200,
|
||||
{ 'Content-Type': 'application/json' },
|
||||
JSON.stringify({
|
||||
dataset: {
|
||||
nativeName: 'A nativeName',
|
||||
description: 'A dataset description'
|
||||
}
|
||||
datasetUrn: hdfsUrn
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
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');
|
||||
assert.equal(find(descriptionElementQuery).textContent.trim(), 'A dataset description');
|
||||
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]
|
||||
}
|
||||
]
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
this.render(hbs`{{datasets/containers/upstream-dataset urn=urn platform=platform}}`);
|
||||
|
||||
await waitUntil(() => find(upstreamElement));
|
||||
|
||||
assert.equal(find(upstreamElement).textContent.trim(), 'A nativeName');
|
||||
});
|
||||
|
@ -9,40 +9,14 @@ moduleForComponent('datasets/upstream-dataset', 'Integration | Component | datas
|
||||
test('it renders', function(assert) {
|
||||
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) {
|
||||
const titleElementQuery = '.upstream-dataset-banner__title strong';
|
||||
const descriptionElementQuery = '.upstream-dataset-banner__description strong';
|
||||
const nativeName = 'Upstream Dataset';
|
||||
const description = 'Upstream Dataset Description';
|
||||
const upstreamLink = '.upstream-dataset__upstream-link';
|
||||
const upstreamsMetadata = [{}, {}];
|
||||
this.set('upstreamsMetadata', upstreamsMetadata);
|
||||
this.render(hbs`{{datasets/upstream-dataset upstreamsMetadata=upstreamsMetadata}}`);
|
||||
|
||||
this.set('nativeName', nativeName);
|
||||
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');
|
||||
assert.equal(document.querySelectorAll(upstreamLink).length, 2, 'renders a link for each upstream dataset');
|
||||
});
|
||||
|
@ -3,13 +3,7 @@ import hbs from 'htmlbars-inline-precompile';
|
||||
import { triggerEvent } from 'ember-native-dom-helpers';
|
||||
import sinon from 'sinon';
|
||||
|
||||
import {
|
||||
missingPolicyText,
|
||||
purgePolicyProps,
|
||||
exemptPolicy,
|
||||
PurgePolicy,
|
||||
getSupportedPurgePolicies
|
||||
} from 'wherehows-web/constants';
|
||||
import { purgePolicyProps, exemptPolicy, PurgePolicy, getSupportedPurgePolicies } from 'wherehows-web/constants';
|
||||
import { DatasetPlatform } from 'wherehows-web/constants/datasets/platform';
|
||||
import platforms from 'wherehows-web/mirage/fixtures/list-platforms';
|
||||
import { ApiStatus } from 'wherehows-web/utils/api';
|
||||
@ -28,6 +22,7 @@ moduleForComponent('purge-policy', 'Integration | Component | purge policy', {
|
||||
|
||||
const policyList = '.purge-policy-list';
|
||||
const policyTypes = Object.keys(purgePolicyProps);
|
||||
const missingPolicyText = 'No policy';
|
||||
|
||||
test('it renders', function(assert) {
|
||||
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) {
|
||||
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(
|
||||
document.querySelector(`${policyList} p`).textContent,
|
||||
document.querySelector(`${policyList}`).textContent.trim(),
|
||||
missingPolicyText,
|
||||
`${missingPolicyText} is rendered`
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user