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

94 lines
3.1 KiB
TypeScript

import { module, test, skip } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, click } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import { assertThrownException } from '@datahub/utils/test-helpers/test-exception';
import { TrackingEventCategory } from '@datahub/shared/constants/tracking/event-tracking';
import { getRenderedComponent } from '@datahub/utils/test-helpers/register-component';
import TrackUiEvent from '@datahub/shared/components/tracking/track-ui-event';
import sinonTest from 'ember-sinon-qunit/test-support/test';
import UnifiedTracking from '@datahub/shared/services/unified-tracking';
const category = TrackingEventCategory.Entity;
const action = 'testAction';
module('Integration | Component | track-ui-event', function(hooks): void {
setupRenderingTest(hooks);
skip('instantiation errors are raised as expected', async function(assert): Promise<void> {
const category = TrackingEventCategory.Entity;
await assertThrownException(
assert,
async (): Promise<void> => {
await render(hbs`
<Tracking::TrackUiEvent>
<p>Nested Template</p>
</Tracking::TrackUiEvent>
`);
},
(err: Error) => err.message.includes('Expected a category to be provided on initialization of TrackUiEvent')
);
this.set('category', category);
await assertThrownException(
assert,
async (): Promise<void> => {
await render(hbs`
<Tracking::TrackUiEvent @category={{this.category}}>
<p>Nested Template</p>
</Tracking::TrackUiEvent>
`);
},
(err: Error) => err.message.includes('Expected an action to be provided on initialization of TrackUiEvent')
);
});
test('component renders nested template', async function(assert): Promise<void> {
this.setProperties({
action,
category
});
await render(hbs`
<Tracking::TrackUiEvent @category={{this.category}} @action={{this.action}}>
<p>Nested Template</p>
</Tracking::TrackUiEvent>
`);
assert.dom('p').hasText('Nested Template');
});
sinonTest('', async function(this: SinonTestContext, assert): Promise<void> {
const service: UnifiedTracking = this.owner.lookup('service:unified-tracking');
const stubbedTrackEvent = this.stub(service, 'trackEvent');
this.setProperties({
action,
category
});
const component = await getRenderedComponent({
ComponentToRender: TrackUiEvent,
testContext: this,
template: hbs`
<Tracking::TrackUiEvent @category={{this.category}} @action={{this.action}} as |track|>
<button onclick={{action track.trackOnAction}} type="button" />
</Tracking::TrackUiEvent>
`,
componentName: 'tracking/track-ui-event'
});
await click('button');
assert.ok(stubbedTrackEvent.called, "Expected the UnifiedTracking service's trackEvent to have been called");
assert.equal(
component.tracking,
service,
"Expected the component's tracking property to be equal to the UnifiedTracking service"
);
});
});