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:
parent
0a9ef040a1
commit
2772856201
|
@ -6,11 +6,6 @@ import InputValidation from 'discourse/models/input-validation';
|
||||||
|
|
||||||
export default Ember.Controller.extend(ModalFunctionality, {
|
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
|
// The validation property must be defined at runtime since the possible parameters vary by provider
|
||||||
setupValidations: function(){
|
setupValidations: function(){
|
||||||
if(this.get('model.provider')){
|
if(this.get('model.provider')){
|
||||||
|
@ -24,6 +19,10 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
var regex = new RegExp(regString);
|
var regex = new RegExp(regString);
|
||||||
var val = this.get('model.channel.data.'+parameter.key);
|
var val = this.get('model.channel.data.'+parameter.key);
|
||||||
|
|
||||||
|
if(val==undefined){
|
||||||
|
val = "";
|
||||||
|
}
|
||||||
|
|
||||||
if(val == ""){ // Fail silently if field blank
|
if(val == ""){ // Fail silently if field blank
|
||||||
return InputValidation.create({
|
return InputValidation.create({
|
||||||
failed: true,
|
failed: true,
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
<div class="modal-footer">
|
<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"}}
|
{{d-button class="btn-large" action="cancel" title="chat_integration.edit_channel_modal.cancel" label="chat_integration.edit_channel_modal.cancel"}}
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,21 @@ acceptance("Chat Integration", {
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
server.get('/admin/plugins/chat/providers', () => {
|
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', () => {
|
server.get('/admin/plugins/chat/channels', () => {
|
||||||
return response({ rules: [{"id":11,"provider":"dummy","channel":"#general","category_id":2,"tags":null,"filter":"follow","error_key":null}] });
|
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({ });
|
return response({ });
|
||||||
});
|
});
|
||||||
server.put('/admin/plugins/chat/rules/:id', () => {
|
server.put('/admin/plugins/chat/rules/:id', () => {
|
||||||
|
@ -38,78 +47,108 @@ test("Rules load successfully", assert => {
|
||||||
|
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
assert.ok(exists('#admin-plugin-chat table'), "it shows the table of rules");
|
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");
|
visit("/admin/plugins/chat");
|
||||||
|
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
click('#create_rule');
|
click('#create_channel');
|
||||||
});
|
});
|
||||||
|
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
assert.ok(exists('#chat_integration_edit_rule_modal'), 'it displays the modal');
|
assert.ok(exists('#chat_integration_edit_channel_modal'), 'it displays the modal');
|
||||||
assert.ok(find('#save_rule').prop('disabled'), 'it disables the save button');
|
assert.ok(find('#save_channel').prop('disabled'), 'it disables the save button');
|
||||||
fillIn('#channel-field', '#general');
|
fillIn('#chat_integration_edit_channel_modal input', '#general');
|
||||||
assert.ok(find('#save_rule').prop('disabled'), 'it enables the save button');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
click('#save_rule');
|
andThen(() => {
|
||||||
|
assert.ok(!find('#save_channel').prop('disabled'), 'it enables the save button');
|
||||||
|
})
|
||||||
|
|
||||||
andThen(() => {
|
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 => {
|
// test("Edit channel works", assert => {
|
||||||
visit("/admin/plugins/chat");
|
// visit("/admin/plugins/chat");
|
||||||
|
|
||||||
andThen(() => {
|
// andThen(() => {
|
||||||
assert.ok(exists('.edit:first'), 'edit button is displayed');
|
// 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(() => {
|
// andThen(() => {
|
||||||
assert.ok(exists('#chat_integration_edit_rule_modal'), 'modal opens on edit');
|
// assert.ok(!find('#save_channel').prop('disabled'), 'it enables the save button');
|
||||||
assert.ok(!find('#save_rule').prop('disabled'), 'it enables the save button');
|
// })
|
||||||
});
|
|
||||||
|
|
||||||
click('#save_rule');
|
// andThen(() => {
|
||||||
|
// click('#save_channel');
|
||||||
|
// });
|
||||||
|
|
||||||
andThen(() => {
|
// andThen(() => {
|
||||||
assert.ok(!exists('#chat_integration_edit_rule_modal'), 'modal closes on save');
|
// assert.ok(!exists('#chat_integration_edit_channel_modal'), 'modal closes on save');
|
||||||
});
|
// })
|
||||||
});
|
|
||||||
|
|
||||||
test("Delete rule works", function(assert) {
|
// });
|
||||||
visit("/admin/plugins/chat");
|
|
||||||
|
|
||||||
andThen(() => {
|
// test("Edit rule works", assert => {
|
||||||
assert.ok(exists('.delete:first'));
|
// visit("/admin/plugins/chat");
|
||||||
click('.delete:first');
|
|
||||||
});
|
// 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 => {
|
test("Test provider works", assert => {
|
||||||
visit("/admin/plugins/chat");
|
visit("/admin/plugins/chat");
|
||||||
|
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
click('#test_provider');
|
click('.fa-rocket');
|
||||||
});
|
});
|
||||||
|
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
assert.ok(exists('#chat_integration_test_modal'), 'it displays the modal');
|
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('#channel-field', '#general');
|
|
||||||
fillIn('#choose-topic-title', '9318');
|
fillIn('#choose-topic-title', '9318');
|
||||||
});
|
});
|
||||||
|
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
debugger;
|
|
||||||
click('#chat_integration_test_modal .radio:first');
|
click('#chat_integration_test_modal .radio:first');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue