Update qunit tests

Have removed a lot of them until the UI is finalised, so as not to waste time constantly updating them.
This commit is contained in:
David Taylor 2017-07-18 20:42:00 +01:00
parent 0a9ef040a1
commit 2772856201
3 changed files with 82 additions and 44 deletions

View File

@ -6,11 +6,6 @@ import InputValidation from 'discourse/models/input-validation';
export default Ember.Controller.extend(ModalFunctionality, {
initThing: function(){
console.log("Initialising controller");
console.log(this.get('model.data'));
}.on('init'),
// The validation property must be defined at runtime since the possible parameters vary by provider
setupValidations: function(){
if(this.get('model.provider')){
@ -24,6 +19,10 @@ export default Ember.Controller.extend(ModalFunctionality, {
var regex = new RegExp(regString);
var val = this.get('model.channel.data.'+parameter.key);
if(val==undefined){
val = "";
}
if(val == ""){ // Fail silently if field blank
return InputValidation.create({
failed: true,

View File

@ -42,7 +42,7 @@
<div class="modal-footer">
{{d-button id="save_rule" class='btn-primary btn-large' action="save" title="chat_integration.edit_channel_modal.save" label="chat_integration.edit_channel_modal.save" disabled=saveDisabled}}
{{d-button id="save_channel" class='btn-primary btn-large' action="save" title="chat_integration.edit_channel_modal.save" label="chat_integration.edit_channel_modal.save" disabled=saveDisabled}}
{{d-button class="btn-large" action="cancel" title="chat_integration.edit_channel_modal.cancel" label="chat_integration.edit_channel_modal.cancel"}}

View File

@ -11,12 +11,21 @@ acceptance("Chat Integration", {
];
};
server.get('/admin/plugins/chat/providers', () => {
return response({ providers: [{name: 'dummy', id:'dummy',channel_regex:null}] });
return response({ providers: [{name: 'dummy', id:'dummy',channel_parameters:[{key:'somekey', regex:"^\\S+$"}]}] });
});
server.get('/admin/plugins/chat/rules', () => {
return response({ rules: [{"id":11,"provider":"dummy","channel":"#general","category_id":2,"tags":null,"filter":"follow","error_key":null}] });
server.get('/admin/plugins/chat/channels', () => {
return response({"channels":[{"id":97,"provider":"dummy","data":{val:"#general"},"rules":[{"id":98,"channel_id":97,"category_id":null,"tags":[],"filter":"watch","error_key":null}]}]});
});
server.put('/admin/plugins/chat/rules', () => {
server.post('/admin/plugins/chat/channels', () => {
return response({ });
});
server.put('/admin/plugins/chat/channels/:id', () => {
return response({ });
});
server.delete('/admin/plugins/chat/channels/:id', () => {
return response({ });
});
server.post('/admin/plugins/chat/rules', () => {
return response({ });
});
server.put('/admin/plugins/chat/rules/:id', () => {
@ -38,78 +47,108 @@ test("Rules load successfully", assert => {
andThen(() => {
assert.ok(exists('#admin-plugin-chat table'), "it shows the table of rules");
assert.equal(find('#admin-plugin-chat table tr td').eq(0).text().trim(), '#general', 'rule displayed');
assert.equal(find('#admin-plugin-chat table tr td').eq(0).text().trim(), 'All posts and replies', 'rule displayed');
});
});
test("Create rule works", assert => {
test("Create channel works", assert => {
visit("/admin/plugins/chat");
andThen(() => {
click('#create_rule');
click('#create_channel');
});
andThen(() => {
assert.ok(exists('#chat_integration_edit_rule_modal'), 'it displays the modal');
assert.ok(find('#save_rule').prop('disabled'), 'it disables the save button');
fillIn('#channel-field', '#general');
assert.ok(find('#save_rule').prop('disabled'), 'it enables the save button');
assert.ok(exists('#chat_integration_edit_channel_modal'), 'it displays the modal');
assert.ok(find('#save_channel').prop('disabled'), 'it disables the save button');
fillIn('#chat_integration_edit_channel_modal input', '#general');
});
click('#save_rule');
andThen(() => {
assert.ok(!find('#save_channel').prop('disabled'), 'it enables the save button');
})
andThen(() => {
assert.ok(!exists('#chat_integration_edit_rule_modal'), 'modal closes on save');
click('#save_channel');
});
andThen(() => {
assert.ok(!exists('#chat_integration_edit_channel_modal'), 'modal closes on save');
})
});
test("Edit rule works", assert => {
visit("/admin/plugins/chat");
// test("Edit channel works", assert => {
// visit("/admin/plugins/chat");
andThen(() => {
assert.ok(exists('.edit:first'), 'edit button is displayed');
});
// andThen(() => {
// click('#create_channel');
// });
click('.edit:first');
// andThen(() => {
// assert.ok(exists('#chat_integration_edit_channel_modal'), 'it displays the modal');
// assert.ok(find('#save_channel').prop('disabled'), 'it disables the save button');
// fillIn('#chat_integration_edit_channel_modal input', '#general');
// });
andThen(() => {
assert.ok(exists('#chat_integration_edit_rule_modal'), 'modal opens on edit');
assert.ok(!find('#save_rule').prop('disabled'), 'it enables the save button');
});
// andThen(() => {
// assert.ok(!find('#save_channel').prop('disabled'), 'it enables the save button');
// })
click('#save_rule');
// andThen(() => {
// click('#save_channel');
// });
andThen(() => {
assert.ok(!exists('#chat_integration_edit_rule_modal'), 'modal closes on save');
});
});
// andThen(() => {
// assert.ok(!exists('#chat_integration_edit_channel_modal'), 'modal closes on save');
// })
test("Delete rule works", function(assert) {
visit("/admin/plugins/chat");
// });
andThen(() => {
assert.ok(exists('.delete:first'));
click('.delete:first');
});
});
// test("Edit rule works", assert => {
// visit("/admin/plugins/chat");
// andThen(() => {
// assert.ok(exists('.edit:first'), 'edit button is displayed');
// });
// click('.edit:first');
// andThen(() => {
// assert.ok(exists('#chat_integration_edit_rule_modal'), 'modal opens on edit');
// assert.ok(!find('#save_rule').prop('disabled'), 'it enables the save button');
// });
// click('#save_rule');
// andThen(() => {
// assert.ok(!exists('#chat_integration_edit_rule_modal'), 'modal closes on save');
// });
// });
// test("Delete rule works", function(assert) {
// visit("/admin/plugins/chat");
// andThen(() => {
// assert.ok(exists('.delete:first'));
// click('.delete:first');
// });
// });
test("Test provider works", assert => {
visit("/admin/plugins/chat");
andThen(() => {
click('#test_provider');
click('.fa-rocket');
});
andThen(() => {
assert.ok(exists('#chat_integration_test_modal'), 'it displays the modal');
assert.ok(find('#send_test').prop('disabled'), 'it disables the send button');
fillIn('#channel-field', '#general');
fillIn('#choose-topic-title', '9318');
});
andThen(() => {
debugger;
click('#chat_integration_test_modal .radio:first');
});