Skip to content
This repository was archived by the owner on Apr 14, 2026. It is now read-only.

Commit f69ae59

Browse files
authored
[ENG-4492] Add data-test selectors to registration components and links page (#1851)
* Add data-test selectors to registration components and links page * Fix tests
1 parent cffb157 commit f69ae59

6 files changed

Lines changed: 90 additions & 3 deletions

File tree

lib/registries/addon/overview/children/template.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
<NodeCard @node={{child}} />
1111
{{/list.item}}
1212
{{#list.empty}}
13-
<p>{{t 'registries.overview.components.no_components'}}</p>
13+
<p data-test-no-components>{{t 'registries.overview.components.no_components'}}</p>
1414
{{/list.empty}}
1515
{{/paginated-list/has-many}}

lib/registries/addon/overview/links/template.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<NodeCard @node={{child}} />
1111
{{/list.item}}
1212
{{#list.empty}}
13-
<p>{{t 'registries.overview.links.no_linked_nodes'}}</p>
13+
<p data-test-no-linked-nodes>{{t 'registries.overview.links.no_linked_nodes'}}</p>
1414
{{/list.empty}}
1515
{{/paginated-list/has-many}}
1616

@@ -24,6 +24,6 @@
2424
<NodeCard @node={{child}} />
2525
{{/list.item}}
2626
{{#list.empty}}
27-
<p>{{t 'registries.overview.links.no_linked_registrations'}}</p>
27+
<p data-test-no-linked-registrations>{{t 'registries.overview.links.no_linked_registrations'}}</p>
2828
{{/list.empty}}
2929
{{/paginated-list/has-many}}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { setupMirage } from 'ember-cli-mirage/test-support';
2+
import { module, test } from 'qunit';
3+
4+
import { Permission } from 'ember-osf-web/models/osf-model';
5+
import { visit } from 'ember-osf-web/tests/helpers';
6+
import { setupEngineApplicationTest } from 'ember-osf-web/tests/helpers/engines';
7+
8+
9+
module('Registries | Acceptance | overview.components', hooks => {
10+
setupEngineApplicationTest(hooks, 'registries');
11+
setupMirage(hooks);
12+
13+
test('With components', async assert => {
14+
const parentRegistration = server.create('registration');
15+
const childRegistration = server.create('registration', {
16+
currentUserPermissions: Object.values(Permission),
17+
title: 'Child registration',
18+
});
19+
const childRegistration2 = server.create('registration', {
20+
currentUserPermissions: Object.values(Permission),
21+
title: 'Child registration 2',
22+
});
23+
24+
parentRegistration.update({
25+
children: [childRegistration, childRegistration2],
26+
});
27+
await visit(`/${parentRegistration.id}/components`);
28+
29+
assert.dom('[data-test-node-card]').exists({ count: 2 }, 'Two child registrations are shown');
30+
assert.dom('[data-test-no-components]').doesNotExist('No components message is not shown');
31+
});
32+
33+
test('Without components', async assert => {
34+
const registration = server.create('registration');
35+
await visit(`/${registration.id}/components`);
36+
37+
assert.dom('[data-test-no-components]').exists('No components message is shown');
38+
assert.dom('[data-test-node-card]').doesNotExist('No child registrations are shown');
39+
});
40+
});
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { setupMirage } from 'ember-cli-mirage/test-support';
2+
import { module, test } from 'qunit';
3+
4+
import { visit } from 'ember-osf-web/tests/helpers';
5+
import { setupEngineApplicationTest } from 'ember-osf-web/tests/helpers/engines';
6+
7+
module('Registries | Acceptance | overview.links', hooks => {
8+
setupEngineApplicationTest(hooks, 'registries');
9+
setupMirage(hooks);
10+
11+
test('With linked node and no linked registration', async assert => {
12+
const registration = server.create('registration');
13+
const linkedNode = server.create('node', {
14+
title: 'Linked node',
15+
});
16+
17+
registration.update({
18+
linkedNodes: [linkedNode],
19+
});
20+
await visit(`/${registration.id}/links`);
21+
assert.dom(`[data-test-node-title="${linkedNode.id}"]`).containsText('Linked node', 'Linked node is shown');
22+
assert.dom('[data-test-no-linked-registrations]').exists('No linked registrations message is shown');
23+
});
24+
25+
test('With linked registration and no linked node', async assert => {
26+
const registration = server.create('registration');
27+
const linkedRegistration = server.create('registration', {
28+
title: 'Linked registration',
29+
});
30+
31+
registration.update({
32+
linkedRegistrations: [linkedRegistration],
33+
});
34+
await visit(`/${registration.id}/links`);
35+
36+
assert.dom(`[data-test-node-title="${linkedRegistration.id}"]`)
37+
.containsText('Linked registration', 'Linked registration is shown');
38+
assert.dom('[data-test-no-linked-nodes]').exists('No linked nodes message is shown');
39+
});
40+
});

tests/integration/components/license-text/licence-text-test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { render } from '@ember/test-helpers';
22
import { hbs } from 'ember-cli-htmlbars';
33
import { setupMirage } from 'ember-cli-mirage/test-support';
4+
import { timeout } from 'ember-concurrency';
45
import { t } from 'ember-intl/test-support';
56
import { setupRenderingTest } from 'ember-qunit';
67
import { TestContext } from 'ember-test-helpers';
@@ -26,6 +27,7 @@ module('Osf components | Integration | Component | License text', hooks => {
2627
this.setProperties({ node });
2728

2829
await render(hbs`<LicenseText @node={{this.node}} />`);
30+
await timeout(100);
2931

3032
assert.dom(this.element).hasText('I am an emu.');
3133
});
@@ -48,6 +50,7 @@ module('Osf components | Integration | Component | License text', hooks => {
4850
this.setProperties({ node });
4951

5052
await render(hbs`<LicenseText @node={{this.node}} />`);
53+
await timeout(100);
5154

5255
assert.dom(this.element).hasText('I am an emu. You are Bill and Ted from 1989.');
5356
});
@@ -71,6 +74,7 @@ module('Osf components | Integration | Component | License text', hooks => {
7174
this.setProperties({ node });
7275

7376
await render(hbs`<LicenseText @node={{this.node}} />`);
77+
await timeout(100);
7478

7579
const placeholder = t('app_components.license_text.anonymized_placeholder');
7680
assert.dom(this.element).hasText(`I am an emu. You are ${placeholder} from ${placeholder}.`);

tests/integration/components/registries/new-update-modal/component-test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { render } from '@ember/test-helpers';
22
import { hbs } from 'ember-cli-htmlbars';
33
import { setupMirage } from 'ember-cli-mirage/test-support';
4+
import { timeout } from 'ember-concurrency';
45
import { setupIntl, TestContext } from 'ember-intl/test-support';
56
import { setupRenderingTest } from 'ember-qunit';
67
import { module, test } from 'qunit';
@@ -30,6 +31,7 @@ module('Integration | Component | new-update-modal', hooks => {
3031
@onClose={{this.noop}}
3132
/>`,
3233
);
34+
await timeout(100);
3335
assert.dom('[data-test-new-update-dialog-heading]').hasText(
3436
this.intl.t('registries.newUpdateModal.modalHeader'),
3537
'Modal header is correct',
@@ -57,6 +59,7 @@ module('Integration | Component | new-update-modal', hooks => {
5759
@onClose={{this.noop}}
5860
/>`,
5961
);
62+
await timeout(100);
6063
assert.dom('[data-test-new-update-dialog-heading]').hasText(
6164
this.intl.t('registries.newUpdateModal.modalHeaderNoUpdates'),
6265
'Modal header is correct',

0 commit comments

Comments
 (0)