Fix JS tests.

This commit is contained in:
Guo Xiang Tan 2017-10-03 18:11:58 +08:00
parent f836047f90
commit 44ade676e1
7 changed files with 32 additions and 26 deletions

View File

@ -1,10 +1,11 @@
import ModalFunctionality from 'discourse/mixins/modal-functionality';
import { popupAjaxError } from 'discourse/lib/ajax-error';
import InputValidation from 'discourse/models/input-validation';
import { default as computed, observes } from 'ember-addons/ember-computed-decorators';
import { default as computed, observes, on } from 'ember-addons/ember-computed-decorators';
export default Ember.Controller.extend(ModalFunctionality, {
@on('init')
setupKeydown() {
Ember.run.schedule('afterRender', () => {
$('#chat_integration_edit_channel_modal').keydown(e => {
@ -13,7 +14,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
}
});
});
}.on('init'),
},
// The validation property must be defined at runtime since the possible parameters vary by provider
@observes('model')

View File

@ -1,10 +1,11 @@
import ModalFunctionality from 'discourse/mixins/modal-functionality';
import { popupAjaxError } from 'discourse/lib/ajax-error';
import computed from "ember-addons/ember-computed-decorators";
import { default as computed, on } from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend(ModalFunctionality, {
saveDisabled: false,
@on('init')
setupKeydown() {
Ember.run.schedule('afterRender', () => {
$('#chat_integration_edit_channel_modal').keydown(e => {
@ -13,7 +14,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
}
});
});
}.on('init'),
},
@computed('model.rule.type')
showCategory(type) {

View File

@ -1,8 +1,9 @@
import ModalFunctionality from 'discourse/mixins/modal-functionality';
import { ajax } from 'discourse/lib/ajax';
import computed from "ember-addons/ember-computed-decorators";
import { default as computed, on } from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend(ModalFunctionality, {
@on('init')
setupKeydown() {
Ember.run.schedule('afterRender', () => {
$('#chat_integration_test_modal').keydown(e => {
@ -11,7 +12,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
}
});
});
}.on('init'),
},
@computed('model.topic_id')
sendDisabled(topicId) {
@ -21,8 +22,8 @@ export default Ember.Controller.extend(ModalFunctionality, {
actions: {
send() {
if (this.get('sendDisabled')) return;
this.set('loading', true);
ajax("/admin/plugins/chat/test", {
data: {
channel_id: this.get('model.channel.id'),
@ -32,7 +33,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
}).then(() => {
this.set('loading', false);
this.flash(I18n.t('chat_integration.test_modal.success'), 'success');
}.catch(popupAjaxError);
}).catch(popupAjaxError);
}
}
});

View File

@ -1,4 +1,4 @@
{{#d-modal-body id="chat_integration_edit_rule_modal" title="chat_integration.edit_rule_modal.title"}}
{{!-- {{#d-modal-body id="chat_integration_edit_rule_modal" title="chat_integration.edit_rule_modal.title"}}
<div>
<form {{action "save" on="submit"}}>
<table>
@ -56,8 +56,7 @@
value=model.rule.category_id
rootNoneLabel="chat_integration.all_categories"
rootNone=true
overrideWidths=false
}}
overrideWidths=false}}
</td>
</tr>
<tr class="instructions">
@ -77,8 +76,6 @@
</tr>
{{/if}}
{{#if siteSettings.tagging_enabled}}
<tr class="input">
<td class="label"><label for='tags'>{{i18n "chat_integration.edit_rule_modal.tags"}}</label></td>
@ -110,4 +107,4 @@
action="cancel"
title="chat_integration.edit_rule_modal.cancel"
label="chat_integration.edit_rule_modal.cancel"}}
</div>
</div> --}}

View File

@ -10,14 +10,21 @@
</tr>
</table>
</form>
</div>
</div>
{{/d-modal-body}}
<div class="modal-footer">
{{#conditional-loading-spinner condition=loading}}
{{d-button id="send_test" class='btn-primary btn-large' action="send" title="chat_integration.test_modal.send" label="chat_integration.test_modal.send" disabled=sendDisabled}}
{{d-button class="btn-large" action="closeModal" title="chat_integration.test_modal.close" label="chat_integration.test_modal.close"}}
{{/conditional-loading-spinner}}
{{d-button id="send-test"
class='btn-primary btn-large'
action="send"
title="chat_integration.test_modal.send"
label="chat_integration.test_modal.send"
disabled=sendDisabled}}
</div>
{{d-button class="btn-large"
action="closeModal"
title="chat_integration.test_modal.close"
label="chat_integration.test_modal.close"}}
{{/conditional-loading-spinner}}
</div>

View File

@ -9,8 +9,7 @@
</div>
<div class="pull-right">
{{#d-button
action="showSettings"
{{d-button action="showSettings"
icon="gear"
title="chat_integration.settings"
label="chat_integration.settings"}}

View File

@ -200,7 +200,7 @@ test("Test channel works", assert => {
andThen(() => {
assert.ok(exists('#chat_integration_test_modal'), 'it displays the modal');
assert.ok(find('#send_test').prop('disabled'), 'it disables the send button');
assert.ok(find('#send-test').prop('disabled'), 'it disables the send button');
fillIn('#choose-topic-title', '9318');
});
@ -209,11 +209,11 @@ test("Test channel works", assert => {
});
andThen(() => {
assert.ok(find('#send_test').prop('disabled') === false, 'it enables the send button');
assert.ok(find('#send-test').prop('disabled') === false, 'it enables the send button');
});
andThen(() => {
click('#send_test');
click('#send-test');
});
andThen(() => {