2017-07-11 10:37:44 -04:00
|
|
|
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
|
|
|
|
];
|
|
|
|
};
|
2017-08-02 06:33:50 -04:00
|
|
|
server.get('/admin/plugins/chat/providers', () => { // eslint-disable-line no-undef
|
2017-07-18 15:42:00 -04:00
|
|
|
return response({ providers: [{name: 'dummy', id:'dummy',channel_parameters:[{key:'somekey', regex:"^\\S+$"}]}] });
|
2017-07-11 10:37:44 -04:00
|
|
|
});
|
2017-08-02 06:33:50 -04:00
|
|
|
server.get('/admin/plugins/chat/channels', () => { // eslint-disable-line no-undef
|
2017-07-18 15:42:00 -04:00
|
|
|
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}]}]});
|
2017-07-11 10:37:44 -04:00
|
|
|
});
|
2017-08-02 06:33:50 -04:00
|
|
|
server.post('/admin/plugins/chat/channels', () => { // eslint-disable-line no-undef
|
2017-07-18 15:42:00 -04:00
|
|
|
return response({ });
|
|
|
|
});
|
2017-08-02 06:33:50 -04:00
|
|
|
server.put('/admin/plugins/chat/channels/:id', () => { // eslint-disable-line no-undef
|
2017-07-18 15:42:00 -04:00
|
|
|
return response({ });
|
2017-08-02 06:33:50 -04:00
|
|
|
});
|
|
|
|
server.delete('/admin/plugins/chat/channels/:id', () => { // eslint-disable-line no-undef
|
2017-07-18 15:42:00 -04:00
|
|
|
return response({ });
|
|
|
|
});
|
2017-08-02 06:33:50 -04:00
|
|
|
server.post('/admin/plugins/chat/rules', () => { // eslint-disable-line no-undef
|
2017-07-11 10:37:44 -04:00
|
|
|
return response({ });
|
|
|
|
});
|
2017-08-02 06:33:50 -04:00
|
|
|
server.put('/admin/plugins/chat/rules/:id', () => { // eslint-disable-line no-undef
|
2017-07-11 10:37:44 -04:00
|
|
|
return response({ });
|
|
|
|
});
|
2017-08-02 06:33:50 -04:00
|
|
|
server.delete('/admin/plugins/chat/rules/:id', () => { // eslint-disable-line no-undef
|
2017-07-11 10:37:44 -04:00
|
|
|
return response({ });
|
|
|
|
});
|
2017-08-02 06:33:50 -04:00
|
|
|
server.post('/admin/plugins/chat/test', () => { // eslint-disable-line no-undef
|
2017-07-11 10:37:44 -04:00
|
|
|
return response({ });
|
|
|
|
});
|
2017-08-02 06:33:50 -04:00
|
|
|
server.get('/groups/search.json', () => { // eslint-disable-line no-undef
|
2017-08-01 12:28:12 -04:00
|
|
|
return response([]);
|
|
|
|
});
|
2017-07-11 10:37:44 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
test("Rules load successfully", assert => {
|
|
|
|
visit("/admin/plugins/chat");
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
assert.ok(exists('#admin-plugin-chat table'), "it shows the table of rules");
|
2017-07-18 15:42:00 -04:00
|
|
|
assert.equal(find('#admin-plugin-chat table tr td').eq(0).text().trim(), 'All posts and replies', 'rule displayed');
|
2017-07-11 10:37:44 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-07-18 15:42:00 -04:00
|
|
|
test("Create channel works", assert => {
|
2017-07-11 10:37:44 -04:00
|
|
|
visit("/admin/plugins/chat");
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-07-18 15:42:00 -04:00
|
|
|
click('#create_channel');
|
2017-07-11 10:37:44 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-07-18 15:42:00 -04:00
|
|
|
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');
|
2017-07-11 10:37:44 -04:00
|
|
|
});
|
|
|
|
|
2017-07-18 15:42:00 -04:00
|
|
|
andThen(() => {
|
|
|
|
assert.ok(!find('#save_channel').prop('disabled'), 'it enables the save button');
|
2017-08-02 06:33:50 -04:00
|
|
|
});
|
2017-07-11 10:37:44 -04:00
|
|
|
|
|
|
|
andThen(() => {
|
2017-07-18 15:42:00 -04:00
|
|
|
click('#save_channel');
|
|
|
|
});
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
assert.ok(!exists('#chat_integration_edit_channel_modal'), 'modal closes on save');
|
2017-08-02 06:33:50 -04:00
|
|
|
});
|
2017-07-11 10:37:44 -04:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2017-07-18 15:42:00 -04:00
|
|
|
// test("Edit channel works", assert => {
|
|
|
|
// visit("/admin/plugins/chat");
|
2017-07-11 10:37:44 -04:00
|
|
|
|
2017-07-18 15:42:00 -04:00
|
|
|
// andThen(() => {
|
|
|
|
// click('#create_channel');
|
|
|
|
// });
|
2017-07-11 10:37:44 -04:00
|
|
|
|
2017-07-18 15:42:00 -04:00
|
|
|
// 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');
|
|
|
|
// });
|
2017-07-11 10:37:44 -04:00
|
|
|
|
2017-07-18 15:42:00 -04:00
|
|
|
// andThen(() => {
|
|
|
|
// assert.ok(!find('#save_channel').prop('disabled'), 'it enables the save button');
|
|
|
|
// })
|
2017-07-11 10:37:44 -04:00
|
|
|
|
2017-07-18 15:42:00 -04:00
|
|
|
// andThen(() => {
|
|
|
|
// click('#save_channel');
|
|
|
|
// });
|
2017-07-11 10:37:44 -04:00
|
|
|
|
2017-07-18 15:42:00 -04:00
|
|
|
// andThen(() => {
|
|
|
|
// assert.ok(!exists('#chat_integration_edit_channel_modal'), 'modal closes on save');
|
|
|
|
// })
|
2017-07-11 10:37:44 -04:00
|
|
|
|
2017-07-18 15:42:00 -04:00
|
|
|
// });
|
2017-07-11 10:37:44 -04:00
|
|
|
|
2017-07-18 15:42:00 -04:00
|
|
|
// 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');
|
|
|
|
// });
|
|
|
|
// });
|
2017-07-11 10:37:44 -04:00
|
|
|
|
|
|
|
test("Test provider works", assert => {
|
|
|
|
visit("/admin/plugins/chat");
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-07-18 15:42:00 -04:00
|
|
|
click('.fa-rocket');
|
2017-07-11 10:37:44 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
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('#choose-topic-title', '9318');
|
|
|
|
});
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
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');
|
2017-08-02 06:33:50 -04:00
|
|
|
});
|
2017-07-11 10:37:44 -04:00
|
|
|
|
|
|
|
});
|