Charlie Tran 843a6c5bbb
feat(frontend): update datahub-web client UI code (#1806)
* 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
2020-08-26 15:44:50 -07:00

89 lines
3.3 KiB
TypeScript

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, settled, click } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import sinon from 'sinon';
import { stubService } from '@datahub/utils/test-helpers/stub-service';
import { TrackingEventCategory } from '@datahub/shared/constants/tracking/event-tracking';
import { getRenderedComponent } from '@datahub/utils/test-helpers/register-component';
import HealthHealthFactorAction from '@datahub/shared/components/health/health-factor-action';
module('Integration | Component | health/health-factor-action', function(hooks): void {
setupRenderingTest(hooks);
const rowData = { validator: 'Ownership' };
const labelConfig = { componentAction: sinon.fake() };
const tableConfigs = { options: { wikiLink: 'http://example.com' } };
test('tracking interactions', async function(assert): Promise<void> {
const category = TrackingEventCategory.ControlInteraction;
const ownershipAction = 'DataHubHealthScoreFactorsActionViewOwnership';
const descriptionAction = 'DataHubHealthScoreFactorsActionViewDescription';
const stubbedTrackEvent = sinon.fake();
stubService('unified-tracking', {
trackEvent: stubbedTrackEvent
});
this.setProperties({ rowData, labelConfig });
const component = await getRenderedComponent({
template: hbs`<Health::HealthFactorAction
@rowData={{this.rowData}}
@labelConfig={{this.labelConfig}}
@tableConfigs={{this.tableConfigs}}
/>`,
ComponentToRender: HealthHealthFactorAction,
testContext: this,
componentName: 'health/health-factor-action'
});
await click('button');
assert.ok(
stubbedTrackEvent.calledWith({ category, action: ownershipAction }),
'Expected tracking handler, trackEvent to have been called with ownership action and category'
);
this.set('rowData', { ...rowData, validator: 'Description' });
await settled();
assert.equal(component.controlName, descriptionAction, 'Expected control name to match description control name');
});
test('it renders', async function(assert): Promise<void> {
const actionLinkSelector = '.health-factor-action__wiki';
await render(hbs`<Health::HealthFactorAction
@rowData={{this.rowData}}
@labelConfig={{this.labelConfig}}
@tableConfigs={{this.tableConfigs}}
/>`);
assert.dom().hasText('', 'Expected DOM to not contain any text when no CTA is provided');
assert.dom('td.nacho-table__cell').exists();
assert.dom('button').doesNotExist();
this.setProperties({ rowData, labelConfig });
await settled();
assert.dom().hasText('View Owners', 'Expected cta to be shown');
await click('button');
assert.ok(
labelConfig.componentAction.calledWith(rowData),
'Expected the component action to be called with rowData on click'
);
this.setProperties({ rowData: { validator: 'Description' }, tableConfigs });
await settled();
assert.dom(actionLinkSelector).hasText('Wiki', 'Expected wiki link cta to be shown and link to exist');
assert
.dom(actionLinkSelector)
.hasAttribute(
'href',
tableConfigs.options.wikiLink,
'Expected the hyperlink reference to match the config value'
);
});
});