2020-08-01 03:43:15 +02:00
|
|
|
"use strict";
|
|
|
|
|
2020-11-30 23:46:45 +01:00
|
|
|
const {strict: assert} = require("assert");
|
|
|
|
|
2023-02-22 23:04:10 +01:00
|
|
|
const {zrequire} = require("./lib/namespace");
|
|
|
|
const {run_test} = require("./lib/test");
|
|
|
|
const blueslip = require("./lib/zblueslip");
|
|
|
|
const $ = require("./lib/zjquery");
|
2020-12-01 00:02:16 +01:00
|
|
|
|
2023-02-22 23:04:10 +01:00
|
|
|
const {PollData} = zrequire("../shared/src/poll_data");
|
2021-04-16 12:05:12 +02:00
|
|
|
|
2021-02-10 04:53:22 +01:00
|
|
|
const poll_widget = zrequire("poll_widget");
|
2018-07-02 16:48:23 +02:00
|
|
|
|
2020-08-20 21:24:06 +02:00
|
|
|
const people = zrequire("people");
|
2018-07-05 13:33:58 +02:00
|
|
|
|
2021-04-16 14:43:17 +02:00
|
|
|
const me = {
|
|
|
|
email: "me@zulip.com",
|
|
|
|
full_name: "Me Myself",
|
|
|
|
user_id: 99,
|
|
|
|
};
|
|
|
|
const alice = {
|
|
|
|
email: "alice@zulip.com",
|
|
|
|
full_name: "Alice Lee",
|
|
|
|
user_id: 100,
|
|
|
|
};
|
|
|
|
people.add_active_user(me);
|
|
|
|
people.add_active_user(alice);
|
|
|
|
people.initialize_current_user(me.user_id);
|
|
|
|
|
2020-07-23 02:04:27 +02:00
|
|
|
run_test("PollData my question", () => {
|
2018-07-02 16:48:23 +02:00
|
|
|
const is_my_poll = true;
|
2020-07-15 01:29:15 +02:00
|
|
|
const question = "Favorite color?";
|
2018-07-02 16:48:23 +02:00
|
|
|
|
2021-04-16 12:05:12 +02:00
|
|
|
const data_holder = new PollData({
|
2021-04-16 11:54:38 +02:00
|
|
|
current_user_id: me.user_id,
|
2021-06-13 14:46:31 +02:00
|
|
|
message_sender_id: me.user_id,
|
2021-04-16 11:54:38 +02:00
|
|
|
is_my_poll,
|
|
|
|
question,
|
|
|
|
options: [],
|
2021-05-11 16:33:52 +02:00
|
|
|
comma_separated_names: people.get_full_names_for_poll_option,
|
2021-04-16 11:54:38 +02:00
|
|
|
report_error_function: blueslip.warn,
|
|
|
|
});
|
2018-07-02 16:48:23 +02:00
|
|
|
|
2018-07-05 13:33:58 +02:00
|
|
|
let data = data_holder.get_widget_data();
|
2018-07-02 16:48:23 +02:00
|
|
|
|
|
|
|
assert.deepEqual(data, {
|
2019-01-28 19:13:56 +01:00
|
|
|
options: [],
|
2020-07-15 01:29:15 +02:00
|
|
|
question: "Favorite color?",
|
2018-07-02 16:48:23 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
const question_event = {
|
2020-07-15 01:29:15 +02:00
|
|
|
type: "question",
|
|
|
|
question: "best plan?",
|
2018-07-02 16:48:23 +02:00
|
|
|
};
|
|
|
|
|
2021-04-16 14:43:17 +02:00
|
|
|
data_holder.handle_event(me.user_id, question_event);
|
2018-07-02 16:48:23 +02:00
|
|
|
data = data_holder.get_widget_data();
|
|
|
|
|
|
|
|
assert.deepEqual(data, {
|
2019-01-28 19:13:56 +01:00
|
|
|
options: [],
|
2020-07-15 01:29:15 +02:00
|
|
|
question: "best plan?",
|
2018-07-02 16:48:23 +02:00
|
|
|
});
|
|
|
|
|
2019-01-28 19:13:56 +01:00
|
|
|
const option_event = {
|
2020-07-15 01:29:15 +02:00
|
|
|
type: "new_option",
|
2018-07-02 16:48:23 +02:00
|
|
|
idx: 1,
|
2020-07-15 01:29:15 +02:00
|
|
|
option: "release now",
|
2018-07-02 16:48:23 +02:00
|
|
|
};
|
|
|
|
|
2021-04-16 14:43:17 +02:00
|
|
|
data_holder.handle_event(me.user_id, option_event);
|
2018-07-02 16:48:23 +02:00
|
|
|
data = data_holder.get_widget_data();
|
|
|
|
|
|
|
|
assert.deepEqual(data, {
|
2019-01-28 19:13:56 +01:00
|
|
|
options: [
|
2018-07-02 16:48:23 +02:00
|
|
|
{
|
2020-07-15 01:29:15 +02:00
|
|
|
option: "release now",
|
|
|
|
names: "",
|
2018-07-02 16:48:23 +02:00
|
|
|
count: 0,
|
2020-07-15 01:29:15 +02:00
|
|
|
key: "99,1",
|
2019-02-27 07:20:12 +01:00
|
|
|
current_user_vote: false,
|
2018-07-02 16:48:23 +02:00
|
|
|
},
|
|
|
|
],
|
2020-07-15 01:29:15 +02:00
|
|
|
question: "best plan?",
|
2018-07-02 16:48:23 +02:00
|
|
|
});
|
|
|
|
|
2020-07-16 23:29:01 +02:00
|
|
|
let vote_event = {
|
2020-07-15 01:29:15 +02:00
|
|
|
type: "vote",
|
|
|
|
key: "99,1",
|
2018-07-02 16:48:23 +02:00
|
|
|
vote: 1,
|
|
|
|
};
|
|
|
|
|
2021-04-16 14:43:17 +02:00
|
|
|
data_holder.handle_event(me.user_id, vote_event);
|
2018-07-02 16:48:23 +02:00
|
|
|
data = data_holder.get_widget_data();
|
|
|
|
|
|
|
|
assert.deepEqual(data, {
|
2019-01-28 19:13:56 +01:00
|
|
|
options: [
|
2018-07-02 16:48:23 +02:00
|
|
|
{
|
2020-07-15 01:29:15 +02:00
|
|
|
option: "release now",
|
2021-04-16 14:43:17 +02:00
|
|
|
names: "Me Myself",
|
2018-07-02 16:48:23 +02:00
|
|
|
count: 1,
|
2020-07-15 01:29:15 +02:00
|
|
|
key: "99,1",
|
2019-02-27 07:20:12 +01:00
|
|
|
current_user_vote: true,
|
2018-07-02 16:48:23 +02:00
|
|
|
},
|
|
|
|
],
|
2020-07-15 01:29:15 +02:00
|
|
|
question: "best plan?",
|
2018-07-02 16:48:23 +02:00
|
|
|
});
|
|
|
|
|
2021-04-16 14:43:17 +02:00
|
|
|
vote_event = {
|
|
|
|
type: "vote",
|
|
|
|
key: "99,1",
|
|
|
|
vote: 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
data_holder.handle_event(alice.user_id, vote_event);
|
|
|
|
data = data_holder.get_widget_data();
|
|
|
|
|
|
|
|
assert.deepEqual(data, {
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
option: "release now",
|
|
|
|
names: "Me Myself, Alice Lee",
|
|
|
|
count: 2,
|
|
|
|
key: "99,1",
|
|
|
|
current_user_vote: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
question: "best plan?",
|
|
|
|
});
|
|
|
|
|
2018-07-05 13:33:58 +02:00
|
|
|
const invalid_vote_event = {
|
2020-07-15 01:29:15 +02:00
|
|
|
type: "vote",
|
|
|
|
key: "98,1",
|
2018-07-05 13:33:58 +02:00
|
|
|
vote: 1,
|
|
|
|
};
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
blueslip.expect("warn", `unknown key for poll: ${invalid_vote_event.key}`);
|
2021-04-16 14:43:17 +02:00
|
|
|
data_holder.handle_event(me.user_id, invalid_vote_event);
|
2018-07-05 13:33:58 +02:00
|
|
|
data = data_holder.get_widget_data();
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
const option_outbound_event = data_holder.handle.new_option.outbound("new option");
|
2019-01-28 19:13:56 +01:00
|
|
|
assert.deepEqual(option_outbound_event, {
|
2020-07-15 01:29:15 +02:00
|
|
|
type: "new_option",
|
2018-07-05 13:33:58 +02:00
|
|
|
idx: 2,
|
2020-07-15 01:29:15 +02:00
|
|
|
option: "new option",
|
2018-07-05 13:33:58 +02:00
|
|
|
});
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
const new_question = "Any new plan?";
|
2018-07-05 13:33:58 +02:00
|
|
|
const question_outbound_event = data_holder.handle.question.outbound(new_question);
|
|
|
|
assert.deepEqual(question_outbound_event, {
|
2020-07-15 01:29:15 +02:00
|
|
|
type: "question",
|
2018-07-05 13:33:58 +02:00
|
|
|
question: new_question,
|
|
|
|
});
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
const vote_outbound_event = data_holder.handle.vote.outbound("99,1");
|
2020-07-16 22:40:18 +02:00
|
|
|
assert.deepEqual(vote_outbound_event, {type: "vote", key: "99,1", vote: -1});
|
2018-07-05 13:33:58 +02:00
|
|
|
|
|
|
|
vote_event = {
|
2020-07-15 01:29:15 +02:00
|
|
|
type: "vote",
|
|
|
|
key: "99,1",
|
2018-07-05 13:33:58 +02:00
|
|
|
vote: -1,
|
|
|
|
};
|
|
|
|
|
2021-04-16 14:43:17 +02:00
|
|
|
data_holder.handle_event(me.user_id, vote_event);
|
2018-07-05 13:33:58 +02:00
|
|
|
data = data_holder.get_widget_data();
|
|
|
|
|
|
|
|
assert.deepEqual(data, {
|
2019-01-28 19:13:56 +01:00
|
|
|
options: [
|
2018-07-05 13:33:58 +02:00
|
|
|
{
|
2020-07-15 01:29:15 +02:00
|
|
|
option: "release now",
|
2021-04-16 14:43:17 +02:00
|
|
|
names: "Alice Lee",
|
|
|
|
count: 1,
|
2020-07-15 01:29:15 +02:00
|
|
|
key: "99,1",
|
2019-02-27 07:20:12 +01:00
|
|
|
current_user_vote: false,
|
2018-07-05 13:33:58 +02:00
|
|
|
},
|
|
|
|
],
|
2020-07-15 01:29:15 +02:00
|
|
|
question: "best plan?",
|
2018-07-05 13:33:58 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-06-13 14:46:31 +02:00
|
|
|
run_test("wrong person editing question", () => {
|
|
|
|
const is_my_poll = true;
|
|
|
|
const question = "Favorite color?";
|
|
|
|
|
|
|
|
const data_holder = new PollData({
|
|
|
|
current_user_id: me.user_id,
|
|
|
|
message_sender_id: me.user_id,
|
|
|
|
is_my_poll,
|
|
|
|
question,
|
|
|
|
options: [],
|
|
|
|
comma_separated_names: people.get_full_names_for_poll_option,
|
|
|
|
report_error_function: blueslip.warn,
|
|
|
|
});
|
|
|
|
|
|
|
|
const question_event = {
|
|
|
|
type: "question",
|
|
|
|
question: "best plan?",
|
|
|
|
};
|
|
|
|
|
|
|
|
blueslip.expect("warn", "user 100 is not allowed to edit the question");
|
|
|
|
|
|
|
|
data_holder.handle_event(alice.user_id, question_event);
|
|
|
|
|
|
|
|
assert.deepEqual(data_holder.get_widget_data(), {
|
|
|
|
options: [],
|
|
|
|
question: "Favorite color?",
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-06-28 00:41:05 +02:00
|
|
|
run_test("activate another person poll", ({mock_template}) => {
|
|
|
|
mock_template("widgets/poll_widget.hbs", false, () => "widgets/poll_widget");
|
|
|
|
mock_template("widgets/poll_widget_results.hbs", false, () => "widgets/poll_widget_results");
|
2018-07-05 13:33:58 +02:00
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
const $widget_elem = $("<div>").addClass("widget-content");
|
2018-07-05 13:33:58 +02:00
|
|
|
|
2020-07-16 23:29:01 +02:00
|
|
|
let out_data; // Used to check the event data sent to the server
|
2018-07-05 13:33:58 +02:00
|
|
|
const callback = (data) => {
|
|
|
|
out_data = data;
|
|
|
|
};
|
|
|
|
|
|
|
|
const opts = {
|
2022-01-25 11:36:19 +01:00
|
|
|
$elem: $widget_elem,
|
2020-07-20 22:18:43 +02:00
|
|
|
callback,
|
2018-07-05 13:33:58 +02:00
|
|
|
message: {
|
2021-04-16 14:43:17 +02:00
|
|
|
sender_id: alice.user_id,
|
2018-07-05 13:33:58 +02:00
|
|
|
},
|
2019-01-09 17:55:42 +01:00
|
|
|
extra_data: {
|
2020-07-15 01:29:15 +02:00
|
|
|
question: "What do you want?",
|
2019-01-09 17:55:42 +01:00
|
|
|
},
|
2018-07-05 13:33:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const set_widget_find_result = (selector) => {
|
2022-01-25 11:36:19 +01:00
|
|
|
const $elem = $.create(selector);
|
|
|
|
$widget_elem.set_find_results(selector, $elem);
|
|
|
|
return $elem;
|
2018-07-05 13:33:58 +02:00
|
|
|
};
|
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
const $poll_option = set_widget_find_result("button.poll-option");
|
|
|
|
const $poll_option_input = set_widget_find_result("input.poll-option");
|
|
|
|
const $widget_option_container = set_widget_find_result("ul.poll-widget");
|
2018-07-05 13:33:58 +02:00
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
const $poll_question_submit = set_widget_find_result("button.poll-question-check");
|
|
|
|
const $poll_edit_question = set_widget_find_result(".poll-edit-question");
|
|
|
|
const $poll_question_header = set_widget_find_result(".poll-question-header");
|
|
|
|
const $poll_question_container = set_widget_find_result(".poll-question-bar");
|
|
|
|
const $poll_option_container = set_widget_find_result(".poll-option-bar");
|
2018-07-05 13:33:58 +02:00
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
const $poll_vote_button = set_widget_find_result("button.poll-vote");
|
|
|
|
const $poll_please_wait = set_widget_find_result(".poll-please-wait");
|
|
|
|
const $poll_author_help = set_widget_find_result(".poll-author-help");
|
2019-01-09 17:55:42 +01:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
set_widget_find_result("button.poll-question-remove");
|
|
|
|
set_widget_find_result("input.poll-question");
|
2018-07-05 13:33:58 +02:00
|
|
|
|
2024-05-08 16:16:22 +02:00
|
|
|
const handle_events = poll_widget.activate(opts);
|
2019-01-09 17:55:42 +01:00
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
assert.ok($poll_option_container.visible());
|
|
|
|
assert.ok($poll_question_header.visible());
|
2019-01-09 17:55:42 +01:00
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
assert.ok(!$poll_question_container.visible());
|
|
|
|
assert.ok(!$poll_question_submit.visible());
|
|
|
|
assert.ok(!$poll_edit_question.visible());
|
|
|
|
assert.ok(!$poll_please_wait.visible());
|
|
|
|
assert.ok(!$poll_author_help.visible());
|
2018-07-05 13:33:58 +02:00
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
assert.equal($widget_elem.html(), "widgets/poll_widget");
|
|
|
|
assert.equal($widget_option_container.html(), "widgets/poll_widget_results");
|
|
|
|
assert.equal($poll_question_header.text(), "What do you want?");
|
2018-07-05 13:33:58 +02:00
|
|
|
|
|
|
|
{
|
2019-01-28 19:13:56 +01:00
|
|
|
/* Testing data sent to server on adding option */
|
2022-01-25 11:36:19 +01:00
|
|
|
$poll_option_input.val("cool choice");
|
2018-07-05 13:33:58 +02:00
|
|
|
out_data = undefined;
|
2022-01-25 11:36:19 +01:00
|
|
|
$poll_option.trigger("click");
|
2020-07-16 23:29:01 +02:00
|
|
|
assert.deepEqual(out_data, {type: "new_option", idx: 1, option: "cool choice"});
|
2018-07-05 13:33:58 +02:00
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
$poll_option_input.val("");
|
2018-07-05 13:33:58 +02:00
|
|
|
out_data = undefined;
|
2022-01-25 11:36:19 +01:00
|
|
|
$poll_option.trigger("click");
|
2018-07-05 13:33:58 +02:00
|
|
|
assert.deepEqual(out_data, undefined);
|
|
|
|
}
|
|
|
|
|
|
|
|
const vote_events = [
|
|
|
|
{
|
2021-04-16 14:43:17 +02:00
|
|
|
sender_id: alice.user_id,
|
2018-07-05 13:33:58 +02:00
|
|
|
data: {
|
2020-07-15 01:29:15 +02:00
|
|
|
type: "new_option",
|
2018-07-05 13:33:58 +02:00
|
|
|
idx: 1,
|
2020-07-15 01:29:15 +02:00
|
|
|
option: "release now",
|
2018-07-05 13:33:58 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-04-16 14:43:17 +02:00
|
|
|
sender_id: alice.user_id,
|
2018-07-05 13:33:58 +02:00
|
|
|
data: {
|
2020-07-15 01:29:15 +02:00
|
|
|
type: "vote",
|
|
|
|
key: "100,1",
|
2018-07-05 13:33:58 +02:00
|
|
|
vote: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2024-05-08 16:16:22 +02:00
|
|
|
handle_events(vote_events);
|
2018-07-05 13:33:58 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
/* Testing data sent to server on voting */
|
2022-01-25 11:36:19 +01:00
|
|
|
$poll_vote_button.attr("data-key", "100,1");
|
2018-07-05 13:33:58 +02:00
|
|
|
out_data = undefined;
|
2022-01-25 11:36:19 +01:00
|
|
|
$poll_vote_button.trigger("click");
|
2020-07-16 22:40:18 +02:00
|
|
|
assert.deepEqual(out_data, {type: "vote", key: "100,1", vote: 1});
|
2018-07-05 13:33:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const add_question_event = [
|
|
|
|
{
|
|
|
|
sender_id: 100,
|
|
|
|
data: {
|
2020-07-15 01:29:15 +02:00
|
|
|
type: "question",
|
|
|
|
question: "best plan?",
|
2018-07-05 13:33:58 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2024-05-08 16:16:22 +02:00
|
|
|
handle_events(add_question_event);
|
2018-07-05 13:33:58 +02:00
|
|
|
});
|
|
|
|
|
2021-06-28 00:41:05 +02:00
|
|
|
run_test("activate own poll", ({mock_template}) => {
|
|
|
|
mock_template("widgets/poll_widget.hbs", false, () => "widgets/poll_widget");
|
|
|
|
mock_template("widgets/poll_widget_results.hbs", false, () => "widgets/poll_widget_results");
|
2018-07-05 13:33:58 +02:00
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
const $widget_elem = $("<div>").addClass("widget-content");
|
2018-07-05 13:33:58 +02:00
|
|
|
let out_data;
|
|
|
|
const callback = (data) => {
|
|
|
|
out_data = data;
|
|
|
|
};
|
|
|
|
const opts = {
|
2022-01-25 11:36:19 +01:00
|
|
|
$elem: $widget_elem,
|
2020-07-20 22:18:43 +02:00
|
|
|
callback,
|
2018-07-05 13:33:58 +02:00
|
|
|
message: {
|
2021-04-16 14:43:17 +02:00
|
|
|
sender_id: me.user_id,
|
2018-07-05 13:33:58 +02:00
|
|
|
},
|
|
|
|
extra_data: {
|
2020-07-15 01:29:15 +02:00
|
|
|
question: "Where to go?",
|
2018-07-05 13:33:58 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const set_widget_find_result = (selector) => {
|
2022-01-25 11:36:19 +01:00
|
|
|
const $elem = $.create(selector);
|
|
|
|
$widget_elem.set_find_results(selector, $elem);
|
|
|
|
return $elem;
|
2018-07-05 13:33:58 +02:00
|
|
|
};
|
|
|
|
|
2020-07-21 00:23:06 +02:00
|
|
|
set_widget_find_result("button.poll-option");
|
2022-01-25 11:36:19 +01:00
|
|
|
const $poll_option_input = set_widget_find_result("input.poll-option");
|
|
|
|
const $widget_option_container = set_widget_find_result("ul.poll-widget");
|
2018-07-05 13:33:58 +02:00
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
const $poll_question_submit = set_widget_find_result("button.poll-question-check");
|
|
|
|
const $poll_edit_question = set_widget_find_result(".poll-edit-question");
|
|
|
|
const $poll_question_input = set_widget_find_result("input.poll-question");
|
|
|
|
const $poll_question_header = set_widget_find_result(".poll-question-header");
|
|
|
|
const $poll_question_container = set_widget_find_result(".poll-question-bar");
|
|
|
|
const $poll_option_container = set_widget_find_result(".poll-option-bar");
|
2018-07-05 13:33:58 +02:00
|
|
|
|
2020-07-21 00:23:06 +02:00
|
|
|
set_widget_find_result("button.poll-vote");
|
2022-01-25 11:36:19 +01:00
|
|
|
const $poll_please_wait = set_widget_find_result(".poll-please-wait");
|
|
|
|
const $poll_author_help = set_widget_find_result(".poll-author-help");
|
2019-01-09 17:55:42 +01:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
set_widget_find_result("button.poll-question-remove");
|
2018-07-05 13:33:58 +02:00
|
|
|
|
2021-02-09 13:21:48 +01:00
|
|
|
function assert_visibility() {
|
2022-01-25 11:36:19 +01:00
|
|
|
assert.ok($poll_option_container.visible());
|
|
|
|
assert.ok($poll_question_header.visible());
|
|
|
|
assert.ok(!$poll_question_container.visible());
|
|
|
|
assert.ok($poll_edit_question.visible());
|
|
|
|
assert.ok(!$poll_please_wait.visible());
|
|
|
|
assert.ok(!$poll_author_help.visible());
|
2021-02-09 13:21:48 +01:00
|
|
|
}
|
2018-07-05 13:33:58 +02:00
|
|
|
|
2018-12-17 04:46:27 +01:00
|
|
|
poll_widget.activate(opts);
|
2018-07-05 13:33:58 +02:00
|
|
|
|
2021-02-09 13:21:48 +01:00
|
|
|
assert_visibility();
|
2022-01-25 11:36:19 +01:00
|
|
|
assert.ok(!$poll_question_submit.visible());
|
2021-02-09 13:21:48 +01:00
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
assert.equal($widget_elem.html(), "widgets/poll_widget");
|
|
|
|
assert.equal($widget_option_container.html(), "widgets/poll_widget_results");
|
|
|
|
assert.equal($poll_question_header.text(), "Where to go?");
|
2018-07-05 13:33:58 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
/* Testing data sent to server on editing question */
|
2022-01-25 11:36:19 +01:00
|
|
|
$poll_question_input.val("Is it new?");
|
2018-07-05 13:33:58 +02:00
|
|
|
out_data = undefined;
|
2022-01-25 11:36:19 +01:00
|
|
|
$poll_question_submit.trigger("click");
|
2020-07-16 23:29:01 +02:00
|
|
|
assert.deepEqual(out_data, {type: "question", question: "Is it new?"});
|
2018-07-05 13:33:58 +02:00
|
|
|
|
2021-02-09 13:21:48 +01:00
|
|
|
assert_visibility();
|
2022-01-25 11:36:19 +01:00
|
|
|
assert.ok($poll_question_submit.visible());
|
2021-02-09 13:21:48 +01:00
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
$poll_option_input.val("");
|
2018-07-05 13:33:58 +02:00
|
|
|
out_data = undefined;
|
2022-01-25 11:36:19 +01:00
|
|
|
$poll_question_submit.trigger("click");
|
2018-07-05 13:33:58 +02:00
|
|
|
assert.deepEqual(out_data, undefined);
|
|
|
|
}
|
2018-07-02 16:48:23 +02:00
|
|
|
});
|