Add qunit acceptance tests for admin interface

This commit is contained in:
David Taylor 2017-07-11 15:37:44 +01:00
parent bc579fb6e1
commit e85657181c
4 changed files with 133 additions and 4 deletions

View File

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

View File

@ -46,7 +46,7 @@
<div class="modal-footer"> <div class="modal-footer">
{{#conditional-loading-spinner condition=loading}} {{#conditional-loading-spinner condition=loading}}
{{d-button class='btn-primary btn-large' action="send" title="chat_integration.test_modal.send" label="chat_integration.test_modal.send" disabled=sendDisabled}} {{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"}} {{d-button class="btn-large" action="closeModal" title="chat_integration.test_modal.close" label="chat_integration.test_modal.close"}}
{{/conditional-loading-spinner}} {{/conditional-loading-spinner}}

View File

@ -67,9 +67,9 @@
</table> </table>
<div class="table-footer"> <div class="table-footer">
{{d-button action="test" actionParam=model.provider icon="rocket" title="chat_integration.test_provider" label="chat_integration.test_provider"}} {{d-button id="test_provider" action="test" actionParam=model.provider icon="rocket" title="chat_integration.test_provider" label="chat_integration.test_provider"}}
<div class="pull-right"> <div class="pull-right">
{{d-button action="create" actionParam=model.provider icon="plus" title="chat_integration.create_rule" label="chat_integration.create_rule"}} {{d-button id="create_rule" action="create" actionParam=model.provider icon="plus" title="chat_integration.create_rule" label="chat_integration.create_rule"}}
</div> </div>
</div> </div>

View File

@ -0,0 +1,129 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Chat Integration", {
loggedIn: true,
beforeEach() {
const response = (object) => {
return [
200,
{"Content-Type": "text/html; charset=utf-8"},
object
];
};
server.get('/admin/plugins/chat/providers', () => {
return response({ providers: [{name: 'dummy', id:'dummy',channel_regex:null}] });
});
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.put('/admin/plugins/chat/rules', () => {
return response({ });
});
server.put('/admin/plugins/chat/rules/:id', () => {
return response({ });
});
server.delete('/admin/plugins/chat/rules/:id', () => {
return response({ });
});
server.post('/admin/plugins/chat/test', () => {
return response({ });
});
}
});
test("Rules load successfully", assert => {
visit("/admin/plugins/chat");
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');
});
});
test("Create rule works", assert => {
visit("/admin/plugins/chat");
andThen(() => {
click('#create_rule');
});
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');
});
click('#save_rule');
andThen(() => {
assert.ok(!exists('#chat_integration_edit_rule_modal'), 'modal closes on save');
})
});
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');
});
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');
});
andThen(() => {
assert.ok(!find('#send_test').prop('disabled'), 'it enables the send button');
});
andThen(() => {
click('#send_test');
});
andThen(() => {
assert.ok(exists('#chat_integration_test_modal'), 'modal doesn\'t close on send');
assert.ok(exists('#modal-alert.alert-success'), 'success message displayed');
})
});