|
1 | 1 | import { click, fillIn, render, settled } from '@ember/test-helpers'; |
2 | 2 | import { hbs } from 'ember-cli-htmlbars'; |
3 | 3 | import { setupMirage } from 'ember-cli-mirage/test-support'; |
| 4 | +import { t } from 'ember-intl/test-support'; |
4 | 5 | import { setupRenderingTest } from 'ember-qunit'; |
5 | 6 | import moment from 'moment'; |
6 | 7 | import { module, test } from 'qunit'; |
7 | 8 |
|
| 9 | +import stripHtmlTags from 'ember-osf-web/utils/strip-html-tags'; |
| 10 | + |
8 | 11 | module('Integration | Component | finalize-registration-modal', hooks => { |
9 | 12 | setupRenderingTest(hooks); |
10 | 13 | setupMirage(hooks); |
11 | 14 |
|
12 | 15 | test('make registration public immediately', async function(assert) { |
13 | 16 | this.store = this.owner.lookup('service:store'); |
14 | | - const registration = server.create('registration'); |
| 17 | + const provider = server.create('registration-provider'); |
| 18 | + const registration = server.create('registration', { provider }); |
15 | 19 |
|
16 | 20 | const registrationModel = await this.store.findRecord('registration', registration.id); |
| 21 | + this.set('draftManager', { provider }); |
17 | 22 | this.set('model', registrationModel); |
18 | 23 | this.set('isOpen', false); |
19 | 24 | await render(hbs` |
20 | 25 | <Registries::FinalizeRegistrationModal::Manager |
21 | 26 | @registration={{this.model}} |
| 27 | + @draftManager={{this.draftManager}} |
22 | 28 | as |manager| |
23 | 29 | > |
24 | 30 | <Registries::FinalizeRegistrationModal @isOpen={{this.isOpen}} @manager={{manager}} /> |
@@ -55,14 +61,17 @@ module('Integration | Component | finalize-registration-modal', hooks => { |
55 | 61 |
|
56 | 62 | test('embargo registration', async function(assert) { |
57 | 63 | this.store = this.owner.lookup('service:store'); |
58 | | - const registration = server.create('registration'); |
| 64 | + const provider = server.create('registration-provider'); |
| 65 | + const registration = server.create('registration', { provider }); |
59 | 66 |
|
60 | 67 | const registrationModel = await this.store.findRecord('registration', registration.id); |
| 68 | + this.set('draftManager', { provider }); |
61 | 69 | this.set('model', registrationModel); |
62 | 70 | this.set('isOpen', false); |
63 | 71 | await render(hbs` |
64 | 72 | <Registries::FinalizeRegistrationModal::Manager |
65 | 73 | @registration={{this.model}} |
| 74 | + @draftManager={{this.draftManager}} |
66 | 75 | as |manager| |
67 | 76 | > |
68 | 77 | <Registries::FinalizeRegistrationModal @isOpen={{this.isOpen}} @manager={{manager}} /> |
@@ -102,4 +111,67 @@ module('Integration | Component | finalize-registration-modal', hooks => { |
102 | 111 | // // Close the dialog |
103 | 112 | this.set('isOpen', false); |
104 | 113 | }); |
| 114 | + |
| 115 | + test('almost done modal content: no moderation', async function(assert) { |
| 116 | + this.store = this.owner.lookup('service:store'); |
| 117 | + const noModerationProvider = server.create('registration-provider', { reviewsWorkflow: null }); |
| 118 | + const noModRegistration = server.create('registration', { provider: noModerationProvider }); |
| 119 | + |
| 120 | + const registrationModel = await this.store.findRecord('registration', noModRegistration.id); |
| 121 | + this.set('draftManager', { provider: noModerationProvider }); |
| 122 | + this.set('model', registrationModel); |
| 123 | + this.set('isOpen', true); |
| 124 | + await render(hbs` |
| 125 | + <Registries::FinalizeRegistrationModal::Manager |
| 126 | + @registration={{this.model}} |
| 127 | + @draftManager={{this.draftManager}} |
| 128 | + as |manager| |
| 129 | + > |
| 130 | + <Registries::FinalizeRegistrationModal @isOpen={{this.isOpen}} @manager={{manager}} /> |
| 131 | + </Registries::FinalizeRegistrationModal::Manager> |
| 132 | + `); |
| 133 | + // Click immediate radio button |
| 134 | + await click('[data-test-immediate-button]'); |
| 135 | + // Click submit button |
| 136 | + await click('[data-test-submit-registration-button]'); |
| 137 | + |
| 138 | + const opts = { learnMoreLink: 'aaa.aa', htmlSafe: true }; |
| 139 | + assert.dom('[data-test-finalize-main]').hasTextContaining( |
| 140 | + stripHtmlTags(t('registries.finalizeRegistrationModal.notice.noModerationFromProject', opts).toString()), |
| 141 | + 'modal shows warning', |
| 142 | + ); |
| 143 | + assert.dom('[data-test-finalize-main]').doesNotHaveTextContaining( |
| 144 | + 'A moderator must review and approve', 'modal does not mention moderation for unmoderated providers', |
| 145 | + ); |
| 146 | + }); |
| 147 | + |
| 148 | + test('almost done modal content: with moderation', async function(assert) { |
| 149 | + this.store = this.owner.lookup('service:store'); |
| 150 | + const withModerationProvider = server.create('registration-provider'); |
| 151 | + const withModRegistration = server.create('registration', { provider: withModerationProvider }); |
| 152 | + |
| 153 | + const registrationModel = await this.store.findRecord('registration', withModRegistration.id); |
| 154 | + this.set('draftManager', { provider: withModerationProvider, reviewsWorkflow: 'pre-moderation' }); |
| 155 | + this.set('model', registrationModel); |
| 156 | + this.set('isOpen', true); |
| 157 | + await render(hbs` |
| 158 | + <Registries::FinalizeRegistrationModal::Manager |
| 159 | + @registration={{this.model}} |
| 160 | + @draftManager={{this.draftManager}} |
| 161 | + as |manager| |
| 162 | + > |
| 163 | + <Registries::FinalizeRegistrationModal @isOpen={{this.isOpen}} @manager={{manager}} /> |
| 164 | + </Registries::FinalizeRegistrationModal::Manager> |
| 165 | + `); |
| 166 | + // Click immediate radio button |
| 167 | + await click('[data-test-immediate-button]'); |
| 168 | + // Click submit button |
| 169 | + await click('[data-test-submit-registration-button]'); |
| 170 | + |
| 171 | + const opts = { learnMoreLink: 'aaa.aa', htmlSafe: true }; |
| 172 | + assert.dom('[data-test-finalize-main]').hasTextContaining( |
| 173 | + stripHtmlTags(t('registries.finalizeRegistrationModal.notice.withModerationFromProject', opts).toString()), |
| 174 | + 'modal shows warning with moderation for moderated providers', |
| 175 | + ); |
| 176 | + }); |
105 | 177 | }); |
0 commit comments