mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-12 03:07:05 +00:00

* Releases updated version of datahub-web client UI code * Fix typo in yarn lock * Change yarn lock to match yarn registry directories * Previous commit missed some paths * Even more changes to yarnlock missing in previous commit * Include codegen file for typings * Add files to get parity for datahub-web and current OS datahub-midtier * Add in typo fix from previous commit - change to proper license * Implement proper OS fix for person entity picture url * Workarounds for open source DH issues * Fixes institutional memory api and removes unopensourced tabs for datasets * Fixes search dataset deprecation and user search issue as a result of changes * Remove internal only options in the avatar menu
66 lines
2.8 KiB
TypeScript
66 lines
2.8 KiB
TypeScript
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
import { DatasetEntity } from '@datahub/data-models/entity/dataset/dataset-entity';
|
|
import { testDatasetOwnershipUrn } from '@datahub/data-models/mirage-addon/test-helpers/datasets/ownership';
|
|
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
|
import healthScenario from '@datahub/shared/mirage-addon/scenarios/health-metadata';
|
|
import { MirageTestContext } from '@datahub/utils/types/vendor/ember-cli-mirage/mirage-tests';
|
|
import { getRenderedComponent } from '@datahub/utils/test-helpers/register-component';
|
|
import HealthContainersHealthMetadata from '@datahub/shared/components/health/containers/health-metadata';
|
|
import { render } from '@ember/test-helpers';
|
|
import { stubService } from '@datahub/utils/test-helpers/stub-service';
|
|
import sinon from 'sinon';
|
|
|
|
module('Integration | Component | health/containers/health-metadata', function(hooks): void {
|
|
setupRenderingTest(hooks);
|
|
setupMirage(hooks);
|
|
|
|
hooks.beforeEach(function() {
|
|
stubService('configurator', {
|
|
getConfig() {}
|
|
});
|
|
});
|
|
|
|
test('it renders', async function(this: MirageTestContext, assert): Promise<void> {
|
|
assert.expect(5);
|
|
healthScenario(this.server);
|
|
|
|
const entity = DatasetEntity.displayName;
|
|
const urn = testDatasetOwnershipUrn;
|
|
|
|
this.setProperties({ entity, urn });
|
|
|
|
const component = await getRenderedComponent({
|
|
ComponentToRender: HealthContainersHealthMetadata,
|
|
template: hbs`
|
|
<Health::Containers::HealthMetadata @entityName={{this.entity}} @urn={{this.urn}} as |container|>
|
|
<span id="score">Score: {{container.health.score}}</span>
|
|
<span id="validations">Validations: {{container.health.validations.length}}</span>
|
|
</Health::Containers::HealthMetadata>
|
|
`,
|
|
testContext: this,
|
|
componentName: 'health/containers/health-metadata'
|
|
});
|
|
|
|
assert.ok(component.health !== null, 'Expected the health to not be null');
|
|
assert.ok(Array.isArray(component.health?.validations), 'Expected validations to be a list');
|
|
assert.ok(typeof component.health?.score === 'number', 'Expected the health score to be a number');
|
|
assert.dom('#score').hasText(/Score\: \d{1,3}/, 'Expected score to be a number');
|
|
assert.dom('#validations').hasText(/Validations\: \d{1,3}/, 'Expected validations to be a number');
|
|
});
|
|
|
|
test('invokes notification notify method on error', async function(this: MirageTestContext, assert): Promise<void> {
|
|
const notify = sinon.fake();
|
|
stubService('notifications', {
|
|
notify
|
|
});
|
|
|
|
await render(hbs`
|
|
<Health::Containers::HealthMetadata @entityName="sdfdsf" @urn="sdfsf" />
|
|
`);
|
|
|
|
assert.ok(notify.calledOnce, 'Expected notify method on notification service to be called');
|
|
});
|
|
});
|