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

View File

@ -1,3 +1,3 @@
import buildPluginAdapter from 'admin/adapters/build-plugin';
import buildPluginAdapter from "admin/adapters/build-plugin";
export default buildPluginAdapter('chat');
export default buildPluginAdapter("chat");

View File

@ -1,3 +1,3 @@
import buildPluginAdapter from 'admin/adapters/build-plugin';
import buildPluginAdapter from "admin/adapters/build-plugin";
export default buildPluginAdapter('chat');
export default buildPluginAdapter("chat");

View File

@ -1,3 +1,3 @@
import buildPluginAdapter from 'admin/adapters/build-plugin';
import buildPluginAdapter from "admin/adapters/build-plugin";
export default buildPluginAdapter('chat');
export default buildPluginAdapter("chat");

View File

@ -1,11 +1,9 @@
export default {
resource: 'admin.adminPlugins',
path: '/plugins',
resource: "admin.adminPlugins",
path: "/plugins",
map() {
this.route('chat', function(){
this.route('provider', {path: '/:provider'});
});
this.route("chat", function() {
this.route("provider", { path: "/:provider" });
});
}
};
};

View File

@ -1,3 +1,3 @@
export default Ember.Component.extend({
classNames: ['channel-info'],
});
classNames: ["channel-info"]
});

View File

@ -1,37 +1,40 @@
import { popupAjaxError } from 'discourse/lib/ajax-error';
import computed from 'ember-addons/ember-computed-decorators';
import { popupAjaxError } from "discourse/lib/ajax-error";
import computed from "ember-addons/ember-computed-decorators";
export default Ember.Component.extend({
tagName: 'tr',
tagName: "tr",
@computed('rule.type')
@computed("rule.type")
isCategory(type) {
return type === 'normal';
return type === "normal";
},
@computed('rule.type')
@computed("rule.type")
isMessage(type) {
return type === 'group_message';
return type === "group_message";
},
@computed('rule.type')
@computed("rule.type")
isMention(type) {
return type === 'group_mention';
return type === "group_mention";
},
actions: {
edit() {
this.sendAction('edit', this.get('rule'));
this.sendAction("edit", this.get("rule"));
},
delete(rule) {
rule.destroyRecord().then(() => {
this.send('refresh');
}).catch(popupAjaxError);
rule
.destroyRecord()
.then(() => {
this.send("refresh");
})
.catch(popupAjaxError);
},
refresh() {
this.sendAction('refresh');
this.sendAction("refresh");
}
}
});

View File

@ -1,3 +1 @@
export default Ember.Controller.extend({
});
export default Ember.Controller.extend({});

View File

@ -1,26 +1,39 @@
import ModalFunctionality from 'discourse/mixins/modal-functionality';
import { popupAjaxError } from 'discourse/lib/ajax-error';
import InputValidation from 'discourse/models/input-validation';
import { default as computed, observes, on } from 'ember-addons/ember-computed-decorators';
import ModalFunctionality from "discourse/mixins/modal-functionality";
import { popupAjaxError } from "discourse/lib/ajax-error";
import InputValidation from "discourse/models/input-validation";
import {
default as computed,
observes,
on
} from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend(ModalFunctionality, {
@on('init')
@on("init")
setupKeydown() {
Ember.run.schedule('afterRender', () => {
$('#chat-integration-edit-channel-modal').keydown(e => {
Ember.run.schedule("afterRender", () => {
$("#chat-integration-edit-channel-modal").keydown(e => {
if (e.keyCode === 13) {
this.send('save');
this.send("save");
}
});
});
},
// The validation property must be defined at runtime since the possible parameters vary by provider
@observes('model')
@observes("model")
setupValidations() {
if (this.get('model.provider')) {
const theKeys = this.get('model.provider.channel_parameters').map( ( param ) => param['key'] );
Ember.defineProperty(this,'paramValidation', Ember.computed(`model.channel.data.{${theKeys.join(',')}}`, this._paramValidation));
if (this.get("model.provider")) {
const theKeys = this.get("model.provider.channel_parameters").map(
param => param["key"]
);
Ember.defineProperty(
this,
"paramValidation",
Ember.computed(
`model.channel.data.{${theKeys.join(",")}}`,
this._paramValidation
)
);
}
},
@ -33,31 +46,38 @@ export default Ember.Controller.extend(ModalFunctionality, {
val = "";
}
if (val === "") { // Fail silently if field blank
if (val === "") {
// Fail silently if field blank
return InputValidation.create({
failed: true,
failed: true
});
} else if (!regString) { // Pass silently if no regex available for provider
} else if (!regString) {
// Pass silently if no regex available for provider
return InputValidation.create({
ok: true
});
} else if (regex.test(val)) {
// Test against regex
return InputValidation.create({
ok: true,
reason: I18n.t(
"chat_integration.edit_channel_modal.channel_validation.ok"
)
});
} else if (regex.test(val)) { // Test against regex
return InputValidation.create({
ok: true,
reason: I18n.t('chat_integration.edit_channel_modal.channel_validation.ok')
});
} else { // Failed regex
} else {
// Failed regex
return InputValidation.create({
failed: true,
reason: I18n.t('chat_integration.edit_channel_modal.channel_validation.fail')
reason: I18n.t(
"chat_integration.edit_channel_modal.channel_validation.fail"
)
});
}
},
_paramValidation() {
const response = {};
const parameters = this.get('model.provider.channel_parameters');
const parameters = this.get("model.provider.channel_parameters");
parameters.forEach(parameter => {
response[parameter.key] = this.validate(parameter);
@ -66,19 +86,19 @@ export default Ember.Controller.extend(ModalFunctionality, {
return response;
},
@computed('paramValidation')
@computed("paramValidation")
saveDisabled(paramValidation) {
if (!paramValidation) return true;
let invalid = false;
Object.keys(paramValidation).forEach(key =>{
Object.keys(paramValidation).forEach(key => {
if (!paramValidation[key]) {
invalid = true;
}
if (!paramValidation[key]['ok']) {
invalid = true;
if (!paramValidation[key]["ok"]) {
invalid = true;
}
});
@ -87,15 +107,18 @@ export default Ember.Controller.extend(ModalFunctionality, {
actions: {
cancel() {
this.send('closeModal');
this.send("closeModal");
},
save() {
if (this.get('saveDisabled')) return;
if (this.get("saveDisabled")) return;
this.get('model.channel').save().then(() => {
this.send('closeModal');
}).catch(popupAjaxError);
this.get("model.channel")
.save()
.then(() => {
this.send("closeModal");
})
.catch(popupAjaxError);
}
}
});

View File

@ -1,37 +1,43 @@
import ModalFunctionality from 'discourse/mixins/modal-functionality';
import { popupAjaxError } from 'discourse/lib/ajax-error';
import { default as computed, on } from "ember-addons/ember-computed-decorators";
import ModalFunctionality from "discourse/mixins/modal-functionality";
import { popupAjaxError } from "discourse/lib/ajax-error";
import {
default as computed,
on
} from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend(ModalFunctionality, {
saveDisabled: false,
@on('init')
@on("init")
setupKeydown() {
Ember.run.schedule('afterRender', () => {
$('#chat-integration-edit-channel-modal').keydown(e => {
Ember.run.schedule("afterRender", () => {
$("#chat-integration-edit-channel-modal").keydown(e => {
if (e.keyCode === 13) {
this.send('save');
this.send("save");
}
});
});
},
@computed('model.rule.type')
@computed("model.rule.type")
showCategory(type) {
return type === "normal";
},
actions: {
cancel() {
this.send('closeModal');
this.send("closeModal");
},
save() {
if (this.get('saveDisabled')) return;
if (this.get("saveDisabled")) return;
this.get('model.rule').save().then(() => {
this.send('closeModal');
}).catch(popupAjaxError);
this.get("model.rule")
.save()
.then(() => {
this.send("closeModal");
})
.catch(popupAjaxError);
}
}
});

View File

@ -1,40 +1,45 @@
import ModalFunctionality from 'discourse/mixins/modal-functionality';
import { ajax } from 'discourse/lib/ajax';
import { popupAjaxError } from 'discourse/lib/ajax-error';
import { default as computed, on } from "ember-addons/ember-computed-decorators";
import ModalFunctionality from "discourse/mixins/modal-functionality";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import {
default as computed,
on
} from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend(ModalFunctionality, {
@on('init')
@on("init")
setupKeydown() {
Ember.run.schedule('afterRender', () => {
$('#chat_integration_test_modal').keydown(e => {
Ember.run.schedule("afterRender", () => {
$("#chat_integration_test_modal").keydown(e => {
if (e.keyCode === 13) {
this.send('send');
this.send("send");
}
});
});
},
@computed('model.topic_id')
@computed("model.topic_id")
sendDisabled(topicId) {
return !topicId;
},
actions: {
send() {
if (this.get('sendDisabled')) return;
this.set('loading', true);
if (this.get("sendDisabled")) return;
this.set("loading", true);
ajax("/admin/plugins/chat/test", {
data: {
channel_id: this.get('model.channel.id'),
topic_id: this.get('model.topic_id')
channel_id: this.get("model.channel.id"),
topic_id: this.get("model.topic_id")
},
type: 'POST'
}).then(() => {
this.set('loading', false);
this.flash(I18n.t('chat_integration.test_modal.success'), 'success');
}).catch(popupAjaxError);
type: "POST"
})
.then(() => {
this.set("loading", false);
this.flash(I18n.t("chat_integration.test_modal.success"), "success");
})
.catch(popupAjaxError);
}
}
});

View File

@ -1,11 +1,11 @@
import RestModel from 'discourse/models/rest';
import RestModel from "discourse/models/rest";
export default RestModel.extend({
updateProperties() {
return this.getProperties(['data']);
return this.getProperties(["data"]);
},
createProperties() {
return this.getProperties(['provider','data']);
return this.getProperties(["provider", "data"]);
}
});

View File

@ -1,5 +1,3 @@
import RestModel from 'discourse/models/rest';
import RestModel from "discourse/models/rest";
export default RestModel.extend({
});
export default RestModel.extend({});

View File

@ -1,57 +1,88 @@
import RestModel from 'discourse/models/rest';
import Category from 'discourse/models/category';
import { default as computed, observes } from "ember-addons/ember-computed-decorators";
import RestModel from "discourse/models/rest";
import Category from "discourse/models/category";
import {
default as computed,
observes
} from "ember-addons/ember-computed-decorators";
export default RestModel.extend({
available_filters: [
{ id: 'watch', name: I18n.t('chat_integration.filter.watch'), icon: 'exclamation-circle' },
{ id: 'follow', name: I18n.t('chat_integration.filter.follow'), icon: 'circle'},
{ id: 'mute', name: I18n.t('chat_integration.filter.mute'), icon: 'times-circle' }
{
id: "watch",
name: I18n.t("chat_integration.filter.watch"),
icon: "exclamation-circle"
},
{
id: "follow",
name: I18n.t("chat_integration.filter.follow"),
icon: "circle"
},
{
id: "mute",
name: I18n.t("chat_integration.filter.mute"),
icon: "times-circle"
}
],
available_types: [
{ id: 'normal', name: I18n.t('chat_integration.type.normal')},
{ id: 'group_message', name: I18n.t('chat_integration.type.group_message')},
{ id: 'group_mention', name: I18n.t('chat_integration.type.group_mention')}
{ id: "normal", name: I18n.t("chat_integration.type.normal") },
{
id: "group_message",
name: I18n.t("chat_integration.type.group_message")
},
{ id: "group_mention", name: I18n.t("chat_integration.type.group_mention") }
],
category_id: null,
tags: null,
channel_id: null,
filter: 'watch',
type: 'normal',
filter: "watch",
type: "normal",
error_key: null,
@observes('type')
@observes("type")
removeUnneededInfo() {
const type = this.get('type');
const type = this.get("type");
if (type === 'normal') {
this.set('group_id', null);
if (type === "normal") {
this.set("group_id", null);
} else {
this.set('category_id', null);
this.set("category_id", null);
}
},
@computed('category_id')
@computed("category_id")
category(categoryId) {
if (categoryId){
if (categoryId) {
return Category.findById(categoryId);
} else {
return false;
}
},
@computed('filter')
@computed("filter")
filterName(filter) {
return I18n.t(`chat_integration.filter.${filter}`);
},
updateProperties() {
return this.getProperties(['type','category_id','group_id','tags','filter']);
return this.getProperties([
"type",
"category_id",
"group_id",
"tags",
"filter"
]);
},
createProperties() {
return this.getProperties(['type','channel_id', 'category_id','group_id','tags','filter']);
return this.getProperties([
"type",
"channel_id",
"category_id",
"group_id",
"tags",
"filter"
]);
}
});

View File

@ -1,7 +1,10 @@
export default Discourse.Route.extend({
afterModel(model) {
if (model.totalRows > 0) {
this.transitionTo('adminPlugins.chat.provider', model.get('firstObject').name);
this.transitionTo(
"adminPlugins.chat.provider",
model.get("firstObject").name
);
}
}
});

View File

@ -1,21 +1,26 @@
import Group from 'discourse/models/group';
import Group from "discourse/models/group";
export default Discourse.Route.extend({
model(params) {
return Ember.RSVP.hash({
channels: this.store.findAll('channel', {provider: params.provider}),
provider: this.modelFor("admin-plugins-chat").findBy('id',params.provider),
channels: this.store.findAll("channel", { provider: params.provider }),
provider: this.modelFor("admin-plugins-chat").findBy(
"id",
params.provider
),
groups: Group.findAll().then(groups => {
return groups.filter(g => !g.get('automatic'));
return groups.filter(g => !g.get("automatic"));
})
}).then(value => {
value.channels.forEach(channel => {
channel.set('rules', channel.rules.map(rule => {
rule = this.store.createRecord('rule', rule);
rule.channel = channel;
return rule;
}));
channel.set(
"rules",
channel.rules.map(rule => {
rule = this.store.createRecord("rule", rule);
rule.channel = channel;
return rule;
})
);
});
return value;
@ -23,14 +28,14 @@ export default Discourse.Route.extend({
},
serialize(model) {
return { provider: model['provider'].get('id') };
return { provider: model["provider"].get("id") };
},
actions: {
closeModal() {
if (this.get('controller.modalShowing')) {
if (this.get("controller.modalShowing")) {
this.refresh();
this.set('controller.modalShowing', false);
this.set("controller.modalShowing", false);
}
return true; // Continue bubbling up, so the modal actually closes

View File

@ -1,12 +1,12 @@
export default Discourse.Route.extend({
model() {
return this.store.findAll('provider');
return this.store.findAll("provider");
},
actions: {
showSettings() {
this.transitionTo('adminSiteSettingsCategory', 'plugins', {
queryParams: { filter: 'chat_integration'}
this.transitionTo("adminSiteSettingsCategory", "plugins", {
queryParams: { filter: "chat_integration" }
});
}
}

View File

@ -1,3 +1,3 @@
export default function() {
this.route('transcript', { path: '/chat-transcript/:secret' });
};
this.route("transcript", { path: "/chat-transcript/:secret" });
}

View File

@ -1,23 +1,30 @@
import { ajax } from 'discourse/lib/ajax';
import { popupAjaxError } from 'discourse/lib/ajax-error';
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
export default Discourse.Route.extend({
beforeModel(transition) {
if (this.currentUser) {
const secret = transition.params.transcript.secret;
this.replaceWith('discovery.latest').then(e => {
if (this.controllerFor('navigation/default').get('canCreateTopic')) {
this.replaceWith("discovery.latest").then(e => {
if (this.controllerFor("navigation/default").get("canCreateTopic")) {
Ember.run.next(() => {
ajax(`chat-transcript/${secret}`).then(result => {
e.send('createNewTopicViaParams', null, result['content'], null, null, null);
e.send(
"createNewTopicViaParams",
null,
result["content"],
null,
null,
null
);
}, popupAjaxError);
});
}
});
} else {
this.session.set("shouldRedirectToUrl", window.location.href);
this.replaceWith('login');
this.replaceWith("login");
}
}
});

View File

@ -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"
);
});
});