1
0
mirror of synced 2026-08-31 19:35:40 +00:00

DEV: Apply prettier to JS and SCSS files

This commit is contained in:
David Taylor
2018-09-12 16:16:18 +01:00
parent e6ed0480d8
commit 44001e259b
19 changed files with 394 additions and 225 deletions
@@ -3,53 +3,85 @@ acceptance("Chat Integration", {
loggedIn: true,
beforeEach() {
const response = (object) => {
return [
200,
{"Content-Type": "text/html; charset=utf-8"},
object
];
const response = object => {
return [200, { "Content-Type": "text/html; charset=utf-8" }, object];
};
server.get('/admin/plugins/chat/providers', () => { // eslint-disable-line no-undef
return response({ providers: [{name: 'dummy', id:'dummy',channel_parameters:[{key:'somekey', regex:"^\\S+$"}]}] });
server.get("/admin/plugins/chat/providers", () => {
// eslint-disable-line no-undef
return response({
providers: [
{
name: "dummy",
id: "dummy",
channel_parameters: [{ key: "somekey", regex: "^\\S+$" }]
}
]
});
});
server.get('/admin/plugins/chat/channels', () => { // eslint-disable-line no-undef
return response({"channels":[{"id":97,"provider":"dummy","data":{somekey:"#general"},"rules":[
{"id":98,"channel_id":97,"category_id":null,"team_id":null,"type":"normal","tags":[],"filter":"watch","error_key":null}
]}]});
server.get("/admin/plugins/chat/channels", () => {
// eslint-disable-line no-undef
return response({
channels: [
{
id: 97,
provider: "dummy",
data: { somekey: "#general" },
rules: [
{
id: 98,
channel_id: 97,
category_id: null,
team_id: null,
type: "normal",
tags: [],
filter: "watch",
error_key: null
}
]
}
]
});
});
server.post('/admin/plugins/chat/channels', () => { // eslint-disable-line no-undef
return response({ });
server.post("/admin/plugins/chat/channels", () => {
// eslint-disable-line no-undef
return response({});
});
server.put('/admin/plugins/chat/channels/:id', () => { // eslint-disable-line no-undef
return response({ });
server.put("/admin/plugins/chat/channels/:id", () => {
// eslint-disable-line no-undef
return response({});
});
server.delete('/admin/plugins/chat/channels/:id', () => { // eslint-disable-line no-undef
return response({ });
server.delete("/admin/plugins/chat/channels/:id", () => {
// eslint-disable-line no-undef
return response({});
});
server.post('/admin/plugins/chat/rules', () => { // eslint-disable-line no-undef
return response({ });
server.post("/admin/plugins/chat/rules", () => {
// eslint-disable-line no-undef
return response({});
});
server.put('/admin/plugins/chat/rules/:id', () => { // eslint-disable-line no-undef
return response({ });
server.put("/admin/plugins/chat/rules/:id", () => {
// eslint-disable-line no-undef
return response({});
});
server.delete('/admin/plugins/chat/rules/:id', () => { // eslint-disable-line no-undef
return response({ });
server.delete("/admin/plugins/chat/rules/:id", () => {
// eslint-disable-line no-undef
return response({});
});
server.post('/admin/plugins/chat/test', () => { // eslint-disable-line no-undef
return response({ });
server.post("/admin/plugins/chat/test", () => {
// eslint-disable-line no-undef
return response({});
});
server.get('/groups/search.json', () => { // eslint-disable-line no-undef
server.get("/groups/search.json", () => {
// eslint-disable-line no-undef
return response([]);
});
}
@@ -59,8 +91,18 @@ 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(), 'All posts and replies', 'rule displayed');
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(),
"All posts and replies",
"rule displayed"
);
});
});
@@ -68,78 +110,108 @@ test("Create channel works", assert => {
visit("/admin/plugins/chat");
andThen(() => {
click('#create-channel');
click("#create-channel");
});
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');
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(find('#save-channel').prop('disabled') === false, 'it enables the save button');
assert.ok(
find("#save-channel").prop("disabled") === false,
"it enables the save button"
);
});
andThen(() => {
click('#save-channel');
click("#save-channel");
});
andThen(() => {
assert.ok(!exists('#chat-integration-edit-channel-modal'), 'modal closes on save');
assert.ok(
!exists("#chat-integration-edit-channel-modal"),
"modal closes on save"
);
});
});
test("Edit channel works", assert => {
visit("/admin/plugins/chat");
andThen(() => {
click('.channel-header button:first');
click(".channel-header button:first");
});
andThen(() => {
assert.ok(exists('#chat-integration-edit-channel-modal'), 'it displays the modal');
assert.ok(!find('#save-channel').prop('disabled'), 'save is enabled');
fillIn('#chat-integration-edit-channel-modal input', ' general');
assert.ok(
exists("#chat-integration-edit-channel-modal"),
"it displays the modal"
);
assert.ok(!find("#save-channel").prop("disabled"), "save is enabled");
fillIn("#chat-integration-edit-channel-modal input", " general");
});
andThen(() => {
assert.ok(find('#save-channel').prop('disabled'), 'it disables the save button');
assert.ok(
find("#save-channel").prop("disabled"),
"it disables the save button"
);
});
andThen(() => {
fillIn('#chat-integration-edit-channel-modal input', '#random');
fillIn("#chat-integration-edit-channel-modal input", "#random");
});
andThen(() => {
$("#chat-integration-edit-channel-modal input").trigger( $.Event( "keydown", { keyCode: 13 } ) ); // Press enter
$("#chat-integration-edit-channel-modal input").trigger(
$.Event("keydown", { keyCode: 13 })
); // Press enter
});
andThen(() => {
assert.ok(!exists('#chat-integration-edit-channel-modal'), 'modal saves on enter');
assert.ok(
!exists("#chat-integration-edit-channel-modal"),
"modal saves on enter"
);
});
});
test("Create rule works", assert => {
visit("/admin/plugins/chat");
andThen(() => {
assert.ok(exists('.channel-footer button:first'), 'create button is displayed');
assert.ok(
exists(".channel-footer button:first"),
"create button is displayed"
);
});
click('.channel-footer button:first');
click(".channel-footer button:first");
andThen(() => {
assert.ok(exists('#chat-integration-edit-rule_modal'), 'modal opens on edit');
assert.ok(find('#save-rule').prop('disabled') === false, 'save is enabled');
assert.ok(
exists("#chat-integration-edit-rule_modal"),
"modal opens on edit"
);
assert.ok(find("#save-rule").prop("disabled") === false, "save is enabled");
});
click('#save-rule');
click("#save-rule");
andThen(() => {
assert.ok(!exists('#chat-integration-edit-rule_modal'), 'modal closes on save');
assert.ok(
!exists("#chat-integration-edit-rule_modal"),
"modal closes on save"
);
});
});
@@ -147,20 +219,29 @@ test("Edit rule works", assert => {
visit("/admin/plugins/chat");
andThen(() => {
assert.ok(exists('.edit:first'), 'edit button is displayed');
assert.ok(exists(".edit:first"), "edit button is displayed");
});
click('.edit:first');
click(".edit:first");
andThen(() => {
assert.ok(exists('#chat-integration-edit-rule_modal'), 'modal opens on edit');
assert.ok(find('#save-rule').prop('disabled') === false, 'it enables the save button');
assert.ok(
exists("#chat-integration-edit-rule_modal"),
"modal opens on edit"
);
assert.ok(
find("#save-rule").prop("disabled") === false,
"it enables the save button"
);
});
click('#save-rule');
click("#save-rule");
andThen(() => {
assert.ok(!exists('#chat-integration-edit-rule_modal'), 'modal closes on save');
assert.ok(
!exists("#chat-integration-edit-rule_modal"),
"modal closes on save"
);
});
});
@@ -168,17 +249,17 @@ test("Delete channel works", function(assert) {
visit("/admin/plugins/chat");
andThen(() => {
assert.ok(exists('.channel-header button:last'), "delete button exists");
click('.channel-header button:last');
assert.ok(exists(".channel-header button:last"), "delete button exists");
click(".channel-header button:last");
});
andThen(() => {
assert.ok(exists('div.bootbox'), "modal is displayed");
click('div.bootbox .btn-primary');
assert.ok(exists("div.bootbox"), "modal is displayed");
click("div.bootbox .btn-primary");
});
andThen(() => {
assert.ok(exists('div.bootbox')===false, "modal has closed");
assert.ok(exists("div.bootbox") === false, "modal has closed");
});
});
@@ -186,8 +267,8 @@ test("Delete rule works", function(assert) {
visit("/admin/plugins/chat");
andThen(() => {
assert.ok(exists('.delete:first'));
click('.delete:first');
assert.ok(exists(".delete:first"));
click(".delete:first");
});
});
@@ -195,30 +276,41 @@ test("Test channel works", assert => {
visit("/admin/plugins/chat");
andThen(() => {
click('.fa-rocket');
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('#choose-topic-title', '9318');
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');
click("#chat_integration_test_modal .radio:first");
});
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(() => {
assert.ok(exists('#chat_integration_test_modal'), 'modal doesn\'t close on send');
assert.ok(exists('#modal-alert.alert-success'), 'success message displayed');
assert.ok(
exists("#chat_integration_test_modal"),
"modal doesn't close on send"
);
assert.ok(
exists("#modal-alert.alert-success"),
"success message displayed"
);
});
});