DEV: fixes eslint/prettier on github actions (#10601)

This commit is contained in:
Joffrey JAFFEUX 2020-09-04 20:01:14 +02:00 committed by GitHub
parent c5b8a47901
commit 110f6ec6dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 278 additions and 280 deletions

View File

@ -146,19 +146,15 @@ jobs:
- name: ESLint (core) - name: ESLint (core)
if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'CORE' if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'CORE'
run: yarn eslint --ext .js app/assets/javascripts test/javascripts run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern app/assets/javascripts test/javascripts
- name: ESLint (core plugins) - name: ESLint (core plugins)
if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'CORE' if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'CORE'
run: | run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern plugins/**/{test,assets}/javascripts
yarn eslint --ext .js plugins/**/assets/javascripts plugins/**/test/javascripts
yarn eslint --ext .es6 plugins/**/assets/javascripts plugins/**/test/javascripts
- name: ESLint (all plugins) - name: ESLint (all plugins)
if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'PLUGINS' if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'PLUGINS'
run: | run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern plugins/**/{test,assets}/javascripts
yarn eslint --ext .js plugins/**/assets/javascripts plugins/**/test/javascripts
yarn eslint --ext .es6 plugins/**/assets/javascripts plugins/**/test/javascripts
- name: Prettier (core and core plugins) - name: Prettier (core and core plugins)
if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'CORE' if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'CORE'

View File

@ -50,6 +50,6 @@ module.exports = {
"simple-unless": true, "simple-unless": true,
"style-concatenation": true, "style-concatenation": true,
"table-groups": true, "table-groups": true,
"link-href-attributes": false "link-href-attributes": false,
} },
}; };

View File

@ -1,15 +1,16 @@
import I18n from "I18n";
import { acceptance } from "helpers/qunit-helpers"; import { acceptance } from "helpers/qunit-helpers";
import { clearPopupMenuOptionsCallback } from "discourse/controllers/composer"; import { clearPopupMenuOptionsCallback } from "discourse/controllers/composer";
import selectKit from "helpers/select-kit-helper"; import selectKit from "helpers/select-kit-helper";
acceptance("Details Button", { acceptance("Details Button", {
loggedIn: true, loggedIn: true,
beforeEach: function() { beforeEach: function () {
clearPopupMenuOptionsCallback(); clearPopupMenuOptionsCallback();
} },
}); });
test("details button", async assert => { test("details button", async (assert) => {
const popupMenu = selectKit(".toolbar-popup-menu-options"); const popupMenu = selectKit(".toolbar-popup-menu-options");
await visit("/"); await visit("/");
@ -109,7 +110,7 @@ test("details button", async assert => {
); );
}); });
test("details button surrounds all selected text in a single details block", async assert => { test("details button surrounds all selected text in a single details block", async (assert) => {
const multilineInput = "first line\n\nsecond line\n\nthird line"; const multilineInput = "first line\n\nsecond line\n\nthird line";
const popupMenu = selectKit(".toolbar-popup-menu-options"); const popupMenu = selectKit(".toolbar-popup-menu-options");

View File

@ -7,13 +7,13 @@ const defaultOpts = buildOptions({
enable_emoji: true, enable_emoji: true,
emoji_set: "emoji_one", emoji_set: "emoji_one",
highlighted_languages: "json|ruby|javascript", highlighted_languages: "json|ruby|javascript",
default_code_lang: "auto" default_code_lang: "auto",
}, },
censoredWords: "shucks|whiz|whizzer", censoredWords: "shucks|whiz|whizzer",
getURL: url => url getURL: (url) => url,
}); });
test("details", assert => { test("details", (assert) => {
const cooked = (input, expected, text) => { const cooked = (input, expected, text) => {
assert.equal( assert.equal(
new PrettyText(defaultOpts).cook(input), new PrettyText(defaultOpts).cook(input),

View File

@ -2,11 +2,11 @@ import { acceptance } from "helpers/qunit-helpers";
acceptance("Local Dates - composer", { acceptance("Local Dates - composer", {
loggedIn: true, loggedIn: true,
settings: { discourse_local_dates_enabled: true } settings: { discourse_local_dates_enabled: true },
}); });
test("composer bbcode", async assert => { test("composer bbcode", async (assert) => {
const getAttr = attr => { const getAttr = (attr) => {
return find(".d-editor-preview .discourse-local-date.cooked-date").attr( return find(".d-editor-preview .discourse-local-date.cooked-date").attr(
`data-${attr}` `data-${attr}`
); );

View File

@ -13,22 +13,22 @@ function buildDateHelper(params = {}) {
hour: params.hour || 10, hour: params.hour || 10,
minute: params.minute || 5, minute: params.minute || 5,
timezone: params.timezone, timezone: params.timezone,
localTimezone: PARIS localTimezone: PARIS,
}); });
} }
QUnit.test("#format", assert => { QUnit.test("#format", (assert) => {
let date = buildDateHelper({ let date = buildDateHelper({
day: 15, day: 15,
month: 2, month: 2,
hour: 15, hour: 15,
minute: 36, minute: 36,
timezone: PARIS timezone: PARIS,
}); });
assert.equal(date.format(), "2020-03-15T15:36:00.000+01:00"); assert.equal(date.format(), "2020-03-15T15:36:00.000+01:00");
}); });
QUnit.test("#repetitionsBetweenDates", assert => { QUnit.test("#repetitionsBetweenDates", (assert) => {
let date; let date;
date = buildDateHelper({ date = buildDateHelper({
@ -36,7 +36,7 @@ QUnit.test("#repetitionsBetweenDates", assert => {
month: 1, month: 1,
hour: 15, hour: 15,
minute: 36, minute: 36,
timezone: PARIS timezone: PARIS,
}); });
assert.equal( assert.equal(
date.repetitionsBetweenDates( date.repetitionsBetweenDates(
@ -52,7 +52,7 @@ QUnit.test("#repetitionsBetweenDates", assert => {
month: 1, month: 1,
hour: 15, hour: 15,
minute: 36, minute: 36,
timezone: PARIS timezone: PARIS,
}); });
assert.equal( assert.equal(
date.repetitionsBetweenDates( date.repetitionsBetweenDates(
@ -68,7 +68,7 @@ QUnit.test("#repetitionsBetweenDates", assert => {
month: 1, month: 1,
hour: 15, hour: 15,
minute: 36, minute: 36,
timezone: PARIS timezone: PARIS,
}); });
assert.equal( assert.equal(
date.repetitionsBetweenDates( date.repetitionsBetweenDates(
@ -84,7 +84,7 @@ QUnit.test("#repetitionsBetweenDates", assert => {
month: 1, month: 1,
hour: 15, hour: 15,
minute: 36, minute: 36,
timezone: PARIS timezone: PARIS,
}); });
assert.equal( assert.equal(
date.repetitionsBetweenDates( date.repetitionsBetweenDates(
@ -96,7 +96,7 @@ QUnit.test("#repetitionsBetweenDates", assert => {
); );
}); });
QUnit.test("#add", assert => { QUnit.test("#add", (assert) => {
let date; let date;
let futureLocalDate; let futureLocalDate;
@ -105,7 +105,7 @@ QUnit.test("#add", assert => {
month: 2, month: 2,
hour: 15, hour: 15,
minute: 36, minute: 36,
timezone: PARIS timezone: PARIS,
}); });
assert.notOk(date.isDST()); assert.notOk(date.isDST());
@ -122,7 +122,7 @@ QUnit.test("#add", assert => {
month: 3, month: 3,
hour: 15, hour: 15,
minute: 36, minute: 36,
timezone: PARIS timezone: PARIS,
}); });
assert.ok(date.isDST()); assert.ok(date.isDST());
futureLocalDate = date.add(1, "year"); futureLocalDate = date.add(1, "year");
@ -138,7 +138,7 @@ QUnit.test("#add", assert => {
month: 2, month: 2,
hour: 15, hour: 15,
minute: 36, minute: 36,
timezone: PARIS timezone: PARIS,
}); });
assert.notOk(date.isDST()); assert.notOk(date.isDST());
futureLocalDate = date.add(1, "week"); futureLocalDate = date.add(1, "week");
@ -154,7 +154,7 @@ QUnit.test("#add", assert => {
month: 3, month: 3,
hour: 15, hour: 15,
minute: 36, minute: 36,
timezone: PARIS timezone: PARIS,
}); });
assert.ok(date.isDST()); assert.ok(date.isDST());

View File

@ -30,7 +30,7 @@ function freezeTime({ date, timezone }, cb) {
sandbox.restore(); sandbox.restore();
} }
QUnit.assert.buildsCorrectDate = function(options, expected, message) { QUnit.assert.buildsCorrectDate = function (options, expected, message) {
const localTimezone = options.localTimezone || PARIS; const localTimezone = options.localTimezone || PARIS;
delete options.localTimezone; delete options.localTimezone;
@ -38,7 +38,7 @@ QUnit.assert.buildsCorrectDate = function(options, expected, message) {
Object.assign( Object.assign(
{}, {},
{ {
date: "2020-03-22" date: "2020-03-22",
}, },
options options
), ),
@ -62,7 +62,7 @@ QUnit.assert.buildsCorrectDate = function(options, expected, message) {
} }
}; };
QUnit.test("date", assert => { QUnit.test("date", (assert) => {
freezeTime({ date: "2020-03-11" }, () => { freezeTime({ date: "2020-03-11" }, () => {
assert.buildsCorrectDate( assert.buildsCorrectDate(
{ date: "2020-03-22", timezone: PARIS }, { date: "2020-03-22", timezone: PARIS },
@ -72,7 +72,7 @@ QUnit.test("date", assert => {
}); });
}); });
QUnit.test("date and time", assert => { QUnit.test("date and time", (assert) => {
assert.buildsCorrectDate( assert.buildsCorrectDate(
{ date: "2020-04-11", time: "11:00" }, { date: "2020-04-11", time: "11:00" },
{ formated: "April 11, 2020 1:00 PM" }, { formated: "April 11, 2020 1:00 PM" },
@ -86,7 +86,7 @@ QUnit.test("date and time", assert => {
); );
}); });
QUnit.test("option[format]", assert => { QUnit.test("option[format]", (assert) => {
freezeTime({ date: "2020-03-11" }, () => { freezeTime({ date: "2020-03-11" }, () => {
assert.buildsCorrectDate( assert.buildsCorrectDate(
{ format: "YYYY" }, { format: "YYYY" },
@ -96,7 +96,7 @@ QUnit.test("option[format]", assert => {
}); });
}); });
QUnit.test("option[displayedTimezone]", assert => { QUnit.test("option[displayedTimezone]", (assert) => {
freezeTime({}, () => { freezeTime({}, () => {
assert.buildsCorrectDate( assert.buildsCorrectDate(
{ displayedTimezone: SYDNEY }, { displayedTimezone: SYDNEY },
@ -130,7 +130,7 @@ QUnit.test("option[displayedTimezone]", assert => {
}); });
}); });
QUnit.test("option[timezone]", assert => { QUnit.test("option[timezone]", (assert) => {
freezeTime({}, () => { freezeTime({}, () => {
assert.buildsCorrectDate( assert.buildsCorrectDate(
{ timezone: SYDNEY, displayedTimezone: PARIS }, { timezone: SYDNEY, displayedTimezone: PARIS },
@ -140,7 +140,7 @@ QUnit.test("option[timezone]", assert => {
}); });
}); });
QUnit.test("option[recurring]", assert => { QUnit.test("option[recurring]", (assert) => {
freezeTime({ date: "2020-04-06 06:00", timezone: LAGOS }, () => { freezeTime({ date: "2020-04-06 06:00", timezone: LAGOS }, () => {
assert.buildsCorrectDate( assert.buildsCorrectDate(
{ {
@ -148,10 +148,10 @@ QUnit.test("option[recurring]", assert => {
time: "11:00", time: "11:00",
timezone: PARIS, timezone: PARIS,
displayedTimezone: LAGOS, displayedTimezone: LAGOS,
recurring: "1.weeks" recurring: "1.weeks",
}, },
{ {
formated: "April 6, 2020 10:00 AM (Lagos)" formated: "April 6, 2020 10:00 AM (Lagos)",
}, },
"it correctly formats a recurring date starting from a !isDST timezone to a isDST timezone date when displayed to a user using a timezone with no DST" "it correctly formats a recurring date starting from a !isDST timezone to a isDST timezone date when displayed to a user using a timezone with no DST"
); );
@ -165,10 +165,10 @@ QUnit.test("option[recurring]", assert => {
timezone: UTC, timezone: UTC,
recurring: "1.weeks", recurring: "1.weeks",
calendar: false, calendar: false,
displayedTimezone: SYDNEY displayedTimezone: SYDNEY,
}, },
{ {
formated: "April 6, 2020 12:00 PM (Sydney)" formated: "April 6, 2020 12:00 PM (Sydney)",
}, },
"it correctly formats a recurring date spanning over weeks" "it correctly formats a recurring date spanning over weeks"
); );
@ -180,10 +180,10 @@ QUnit.test("option[recurring]", assert => {
date: "2019-11-25", date: "2019-11-25",
time: "11:00", time: "11:00",
recurring: "1.weeks", recurring: "1.weeks",
timezone: PARIS timezone: PARIS,
}, },
{ {
formated: "April 13, 2020 11:00 AM" formated: "April 13, 2020 11:00 AM",
}, },
"it correctly adds from a !isDST date to a isDST date" "it correctly adds from a !isDST date to a isDST date"
); );
@ -195,10 +195,10 @@ QUnit.test("option[recurring]", assert => {
date: "2020-03-30", date: "2020-03-30",
time: "11:00", time: "11:00",
recurring: "1.weeks", recurring: "1.weeks",
timezone: PARIS timezone: PARIS,
}, },
{ {
formated: "Today 11:00 AM" formated: "Today 11:00 AM",
}, },
"it works to the minute" "it works to the minute"
); );
@ -210,22 +210,22 @@ QUnit.test("option[recurring]", assert => {
date: "2020-03-30", date: "2020-03-30",
time: "11:00", time: "11:00",
recurring: "1.weeks", recurring: "1.weeks",
timezone: PARIS timezone: PARIS,
}, },
{ {
formated: "April 13, 2020 11:00 AM" formated: "April 13, 2020 11:00 AM",
}, },
"it works to the minute" "it works to the minute"
); );
}); });
}); });
QUnit.test("option[countown]", assert => { QUnit.test("option[countown]", (assert) => {
freezeTime({ date: "2020-03-21 23:59" }, () => { freezeTime({ date: "2020-03-21 23:59" }, () => {
assert.buildsCorrectDate( assert.buildsCorrectDate(
{ {
countdown: true, countdown: true,
timezone: PARIS timezone: PARIS,
}, },
{ formated: "a minute" }, { formated: "a minute" },
"it shows the time remaining" "it shows the time remaining"
@ -236,19 +236,19 @@ QUnit.test("option[countown]", assert => {
assert.buildsCorrectDate( assert.buildsCorrectDate(
{ {
countdown: true, countdown: true,
timezone: PARIS timezone: PARIS,
}, },
{ {
formated: I18n.t( formated: I18n.t(
"discourse_local_dates.relative_dates.countdown.passed" "discourse_local_dates.relative_dates.countdown.passed"
) ),
}, },
"it shows the date has passed" "it shows the date has passed"
); );
}); });
}); });
QUnit.test("option[calendar]", assert => { QUnit.test("option[calendar]", (assert) => {
freezeTime({ date: "2020-03-23 23:00" }, () => { freezeTime({ date: "2020-03-23 23:00" }, () => {
assert.buildsCorrectDate( assert.buildsCorrectDate(
{ date: "2020-03-22", time: "23:59", timezone: PARIS }, { date: "2020-03-22", time: "23:59", timezone: PARIS },
@ -313,7 +313,7 @@ QUnit.test("option[calendar]", assert => {
{ {
date: "2020-05-13", date: "2020-05-13",
time: "18:00", time: "18:00",
localTimezone: LOS_ANGELES localTimezone: LOS_ANGELES,
}, },
{ formated: "Tomorrow 11:00 AM" }, { formated: "Tomorrow 11:00 AM" },
"it correctly displays a different local timezone" "it correctly displays a different local timezone"
@ -321,7 +321,7 @@ QUnit.test("option[calendar]", assert => {
}); });
}); });
QUnit.test("previews", assert => { QUnit.test("previews", (assert) => {
freezeTime({ date: "2020-03-22" }, () => { freezeTime({ date: "2020-03-22" }, () => {
assert.buildsCorrectDate( assert.buildsCorrectDate(
{ timezone: PARIS }, { timezone: PARIS },
@ -331,9 +331,9 @@ QUnit.test("previews", assert => {
current: true, current: true,
formated: formated:
"Sunday, March 22, 2020 12:00 AM → Monday, March 23, 2020 12:00 AM", "Sunday, March 22, 2020 12:00 AM → Monday, March 23, 2020 12:00 AM",
timezone: "Paris" timezone: "Paris",
} },
] ],
} }
); );
}); });
@ -347,14 +347,14 @@ QUnit.test("previews", assert => {
current: true, current: true,
formated: formated:
"Sunday, March 22, 2020 12:00 AM → Monday, March 23, 2020 12:00 AM", "Sunday, March 22, 2020 12:00 AM → Monday, March 23, 2020 12:00 AM",
timezone: "Paris" timezone: "Paris",
}, },
{ {
formated: formated:
"Sunday, March 22, 2020 10:00 AM → Monday, March 23, 2020 10:00 AM", "Sunday, March 22, 2020 10:00 AM → Monday, March 23, 2020 10:00 AM",
timezone: "Sydney" timezone: "Sydney",
} },
] ],
} }
); );
}); });
@ -368,9 +368,9 @@ QUnit.test("previews", assert => {
current: true, current: true,
formated: formated:
"Sunday, March 22, 2020 12:00 AM → Monday, March 23, 2020 12:00 AM", "Sunday, March 22, 2020 12:00 AM → Monday, March 23, 2020 12:00 AM",
timezone: "Paris" timezone: "Paris",
} },
] ],
} }
); );
}); });
@ -384,9 +384,9 @@ QUnit.test("previews", assert => {
current: true, current: true,
formated: formated:
"Sunday, March 22, 2020 12:00 AM → Monday, March 23, 2020 12:00 AM", "Sunday, March 22, 2020 12:00 AM → Monday, March 23, 2020 12:00 AM",
timezone: "Paris" timezone: "Paris",
} },
] ],
} }
); );
}); });
@ -400,9 +400,9 @@ QUnit.test("previews", assert => {
current: true, current: true,
formated: formated:
"Sunday, March 22, 2020 12:00 AM → Monday, March 23, 2020 12:00 AM", "Sunday, March 22, 2020 12:00 AM → Monday, March 23, 2020 12:00 AM",
timezone: "Paris" timezone: "Paris",
} },
] ],
} }
); );
}); });
@ -415,9 +415,9 @@ QUnit.test("previews", assert => {
{ {
current: true, current: true,
formated: "March 22, 2020 11:34 AM", formated: "March 22, 2020 11:34 AM",
timezone: "Paris" timezone: "Paris",
} },
] ],
} }
); );
}); });
@ -427,7 +427,7 @@ QUnit.test("previews", assert => {
{ {
timezone: PARIS, timezone: PARIS,
date: "2020-04-07", date: "2020-04-07",
timezones: [LONDON, LAGOS, SYDNEY] timezones: [LONDON, LAGOS, SYDNEY],
}, },
{ {
previews: [ previews: [
@ -435,24 +435,24 @@ QUnit.test("previews", assert => {
current: true, current: true,
formated: formated:
"Tuesday, April 7, 2020 12:00 AM → Wednesday, April 8, 2020 12:00 AM", "Tuesday, April 7, 2020 12:00 AM → Wednesday, April 8, 2020 12:00 AM",
timezone: "Paris" timezone: "Paris",
}, },
{ {
formated: formated:
"Monday, April 6, 2020 11:00 PM → Tuesday, April 7, 2020 11:00 PM", "Monday, April 6, 2020 11:00 PM → Tuesday, April 7, 2020 11:00 PM",
timezone: "London" timezone: "London",
}, },
{ {
formated: formated:
"Monday, April 6, 2020 11:00 PM → Tuesday, April 7, 2020 11:00 PM", "Monday, April 6, 2020 11:00 PM → Tuesday, April 7, 2020 11:00 PM",
timezone: "Lagos" timezone: "Lagos",
}, },
{ {
formated: formated:
"Tuesday, April 7, 2020 8:00 AM → Wednesday, April 8, 2020 8:00 AM", "Tuesday, April 7, 2020 8:00 AM → Wednesday, April 8, 2020 8:00 AM",
timezone: "Sydney" timezone: "Sydney",
} },
] ],
} }
); );
}); });
@ -463,28 +463,28 @@ QUnit.test("previews", assert => {
timezone: PARIS, timezone: PARIS,
date: "2020-04-07", date: "2020-04-07",
time: "14:54", time: "14:54",
timezones: [LONDON, LAGOS, SYDNEY] timezones: [LONDON, LAGOS, SYDNEY],
}, },
{ {
previews: [ previews: [
{ {
current: true, current: true,
formated: "April 7, 2020 2:54 PM", formated: "April 7, 2020 2:54 PM",
timezone: "Paris" timezone: "Paris",
}, },
{ {
formated: "April 7, 2020 1:54 PM", formated: "April 7, 2020 1:54 PM",
timezone: "London" timezone: "London",
}, },
{ {
formated: "April 7, 2020 1:54 PM", formated: "April 7, 2020 1:54 PM",
timezone: "Lagos" timezone: "Lagos",
}, },
{ {
formated: "April 7, 2020 10:54 PM", formated: "April 7, 2020 10:54 PM",
timezone: "Sydney" timezone: "Sydney",
} },
] ],
} }
); );
}); });
@ -494,20 +494,20 @@ QUnit.test("previews", assert => {
{ {
date: "2020-05-13", date: "2020-05-13",
time: "18:00", time: "18:00",
localTimezone: LOS_ANGELES localTimezone: LOS_ANGELES,
}, },
{ {
previews: [ previews: [
{ {
current: true, current: true,
formated: "May 13, 2020 11:00 AM", formated: "May 13, 2020 11:00 AM",
timezone: "Los Angeles" timezone: "Los Angeles",
}, },
{ {
formated: "May 13, 2020 6:00 PM", formated: "May 13, 2020 6:00 PM",
timezone: "UTC" timezone: "UTC",
} },
] ],
} }
); );
}); });

View File

@ -10,7 +10,7 @@ acceptance("Poll breakdown", {
}, },
pretend(server, helper) { pretend(server, helper) {
server.get("/polls/grouped_poll_results.json", () => { server.get("/polls/grouped_poll_results.json", () => {
return new Promise(resolve => { return new Promise((resolve) => {
resolve( resolve(
helper.response({ helper.response({
grouped_results: [ grouped_results: [
@ -20,19 +20,19 @@ acceptance("Poll breakdown", {
{ {
digest: "687a1ccf3c6a260f9aeeb7f68a1d463c", digest: "687a1ccf3c6a260f9aeeb7f68a1d463c",
html: "This Is", html: "This Is",
votes: 1 votes: 1,
}, },
{ {
digest: "9377906763a1221d31d656ea0c4a4495", digest: "9377906763a1221d31d656ea0c4a4495",
html: "A test for sure", html: "A test for sure",
votes: 1 votes: 1,
}, },
{ {
digest: "ecf47c65a85a0bb20029072b1b721977", digest: "ecf47c65a85a0bb20029072b1b721977",
html: "Why not give it some more", html: "Why not give it some more",
votes: 1 votes: 1,
} },
] ],
}, },
{ {
group: "Marketing", group: "Marketing",
@ -40,29 +40,29 @@ acceptance("Poll breakdown", {
{ {
digest: "687a1ccf3c6a260f9aeeb7f68a1d463c", digest: "687a1ccf3c6a260f9aeeb7f68a1d463c",
html: "This Is", html: "This Is",
votes: 1 votes: 1,
}, },
{ {
digest: "9377906763a1221d31d656ea0c4a4495", digest: "9377906763a1221d31d656ea0c4a4495",
html: "A test for sure", html: "A test for sure",
votes: 1 votes: 1,
}, },
{ {
digest: "ecf47c65a85a0bb20029072b1b721977", digest: "ecf47c65a85a0bb20029072b1b721977",
html: "Why not give it some more", html: "Why not give it some more",
votes: 1 votes: 1,
} },
] ],
} },
] ],
}) })
); );
}); });
}); });
} },
}); });
test("Displaying the poll breakdown modal", async assert => { test("Displaying the poll breakdown modal", async (assert) => {
await visit("/t/-/topic_with_pie_chart_poll"); await visit("/t/-/topic_with_pie_chart_poll");
assert.equal( assert.equal(
@ -91,7 +91,7 @@ test("Displaying the poll breakdown modal", async assert => {
); );
}); });
test("Changing the display mode from percentage to count", async assert => { test("Changing the display mode from percentage to count", async (assert) => {
await visit("/t/-/topic_with_pie_chart_poll"); await visit("/t/-/topic_with_pie_chart_poll");
await click(".poll-show-breakdown:first"); await click(".poll-show-breakdown:first");

View File

@ -6,14 +6,14 @@ acceptance("Poll Builder - polls are disabled", {
loggedIn: true, loggedIn: true,
settings: { settings: {
poll_enabled: false, poll_enabled: false,
poll_minimum_trust_level_to_create: 2 poll_minimum_trust_level_to_create: 2,
}, },
beforeEach: function() { beforeEach: function () {
clearPopupMenuOptionsCallback(); clearPopupMenuOptionsCallback();
} },
}); });
test("regular user - sufficient trust level", async assert => { test("regular user - sufficient trust level", async (assert) => {
updateCurrentUser({ moderator: false, admin: false, trust_level: 3 }); updateCurrentUser({ moderator: false, admin: false, trust_level: 3 });
await displayPollBuilderButton(); await displayPollBuilderButton();
@ -24,7 +24,7 @@ test("regular user - sufficient trust level", async assert => {
); );
}); });
test("regular user - insufficient trust level", async assert => { test("regular user - insufficient trust level", async (assert) => {
updateCurrentUser({ moderator: false, admin: false, trust_level: 1 }); updateCurrentUser({ moderator: false, admin: false, trust_level: 1 });
await displayPollBuilderButton(); await displayPollBuilderButton();
@ -35,7 +35,7 @@ test("regular user - insufficient trust level", async assert => {
); );
}); });
test("staff", async assert => { test("staff", async (assert) => {
updateCurrentUser({ moderator: true }); updateCurrentUser({ moderator: true });
await displayPollBuilderButton(); await displayPollBuilderButton();

View File

@ -7,14 +7,14 @@ acceptance("Poll Builder - polls are enabled", {
loggedIn: true, loggedIn: true,
settings: { settings: {
poll_enabled: true, poll_enabled: true,
poll_minimum_trust_level_to_create: 1 poll_minimum_trust_level_to_create: 1,
}, },
beforeEach() { beforeEach() {
clearPopupMenuOptionsCallback(); clearPopupMenuOptionsCallback();
} },
}); });
test("regular user - sufficient trust level", async assert => { test("regular user - sufficient trust level", async (assert) => {
updateCurrentUser({ moderator: false, admin: false, trust_level: 1 }); updateCurrentUser({ moderator: false, admin: false, trust_level: 1 });
await displayPollBuilderButton(); await displayPollBuilderButton();
@ -25,7 +25,7 @@ test("regular user - sufficient trust level", async assert => {
); );
}); });
test("regular user - insufficient trust level", async assert => { test("regular user - insufficient trust level", async (assert) => {
updateCurrentUser({ moderator: false, admin: false, trust_level: 0 }); updateCurrentUser({ moderator: false, admin: false, trust_level: 0 });
await displayPollBuilderButton(); await displayPollBuilderButton();
@ -36,7 +36,7 @@ test("regular user - insufficient trust level", async assert => {
); );
}); });
test("staff - with insufficient trust level", async assert => { test("staff - with insufficient trust level", async (assert) => {
updateCurrentUser({ moderator: true, trust_level: 0 }); updateCurrentUser({ moderator: true, trust_level: 0 });
await displayPollBuilderButton(); await displayPollBuilderButton();
@ -47,7 +47,7 @@ test("staff - with insufficient trust level", async assert => {
); );
}); });
test("poll preview", async assert => { test("poll preview", async (assert) => {
await displayPollBuilderButton(); await displayPollBuilderButton();
const popupMenu = selectKit(".toolbar-popup-menu-options"); const popupMenu = selectKit(".toolbar-popup-menu-options");

View File

@ -2,10 +2,10 @@ import { acceptance } from "helpers/qunit-helpers";
acceptance("Rendering polls with pie charts - desktop", { acceptance("Rendering polls with pie charts - desktop", {
loggedIn: true, loggedIn: true,
settings: { poll_enabled: true, poll_groupable_user_fields: "something" } settings: { poll_enabled: true, poll_groupable_user_fields: "something" },
}); });
test("Displays the pie chart", async assert => { test("Displays the pie chart", async (assert) => {
await visit("/t/-/topic_with_pie_chart_poll"); await visit("/t/-/topic_with_pie_chart_poll");
const poll = find(".poll")[0]; const poll = find(".poll")[0];

View File

@ -10,7 +10,7 @@ acceptance("Poll quote", {
}, },
pretend(server, helper) { pretend(server, helper) {
server.get("/t/topic_with_two_polls.json", () => { server.get("/t/topic_with_two_polls.json", () => {
return new Promise(resolve => { return new Promise((resolve) => {
resolve( resolve(
helper.response({ helper.response({
post_stream: { post_stream: {
@ -54,8 +54,8 @@ acceptance("Poll quote", {
internal: true, internal: true,
reflection: true, reflection: true,
title: "Topic with two quoted polls", title: "Topic with two quoted polls",
clicks: 0 clicks: 0,
} },
], ],
read: true, read: true,
user_title: "Tester", user_title: "Tester",
@ -64,20 +64,20 @@ acceptance("Poll quote", {
actions_summary: [ actions_summary: [
{ {
id: 3, id: 3,
can_act: true can_act: true,
}, },
{ {
id: 4, id: 4,
can_act: true can_act: true,
}, },
{ {
id: 8, id: 8,
can_act: true can_act: true,
}, },
{ {
id: 7, id: 7,
can_act: true can_act: true,
} },
], ],
moderator: false, moderator: false,
admin: true, admin: true,
@ -104,16 +104,16 @@ acceptance("Poll quote", {
{ {
id: "bf48cd4958a17180e2a298e246988f94", id: "bf48cd4958a17180e2a298e246988f94",
html: "Alpha", html: "Alpha",
votes: 0 votes: 0,
}, },
{ {
id: "c19aa835729ab0413a84a2c9850c4005", id: "c19aa835729ab0413a84a2c9850c4005",
html: "Beta", html: "Beta",
votes: 0 votes: 0,
} },
], ],
voters: 0, voters: 0,
chart_type: "bar" chart_type: "bar",
}, },
{ {
name: "poll2", name: "poll2",
@ -124,21 +124,21 @@ acceptance("Poll quote", {
{ {
id: "def034c6770c6fd3754c054ef9ec4721", id: "def034c6770c6fd3754c054ef9ec4721",
html: "First", html: "First",
votes: 0 votes: 0,
}, },
{ {
id: "e0f55d1a981683789bec2a0b05eb70ef", id: "e0f55d1a981683789bec2a0b05eb70ef",
html: "Second", html: "Second",
votes: 0 votes: 0,
} },
], ],
voters: 0, voters: 0,
chart_type: "bar" chart_type: "bar",
} },
] ],
} },
], ],
stream: [133] stream: [133],
}, },
timeline_lookup: [[1, 0]], timeline_lookup: [[1, 0]],
suggested_topics: [], suggested_topics: [],
@ -184,20 +184,20 @@ acceptance("Poll quote", {
id: 4, id: 4,
count: 0, count: 0,
hidden: false, hidden: false,
can_act: true can_act: true,
}, },
{ {
id: 8, id: 8,
count: 0, count: 0,
hidden: false, hidden: false,
can_act: true can_act: true,
}, },
{ {
id: 7, id: 7,
count: 0, count: 0,
hidden: false, hidden: false,
can_act: true can_act: true,
} },
], ],
chunk_size: 20, chunk_size: 20,
bookmarked: false, bookmarked: false,
@ -241,32 +241,32 @@ acceptance("Poll quote", {
primary_group_name: null, primary_group_name: null,
primary_group_flair_url: null, primary_group_flair_url: null,
primary_group_flair_color: null, primary_group_flair_color: null,
primary_group_flair_bg_color: null primary_group_flair_bg_color: null,
} },
], ],
created_by: { created_by: {
id: 1, id: 1,
username: "bianca", username: "bianca",
name: null, name: null,
avatar_template: avatar_template:
"/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png" "/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png",
}, },
last_poster: { last_poster: {
id: 1, id: 1,
username: "bianca", username: "bianca",
name: null, name: null,
avatar_template: avatar_template:
"/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png" "/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png",
} },
}, },
pending_posts: [] pending_posts: [],
}) })
); );
}); });
}); });
server.get("/posts/by_number/130/1", () => { server.get("/posts/by_number/130/1", () => {
return new Promise(resolve => { return new Promise((resolve) => {
resolve( resolve(
helper.response({ helper.response({
id: 133, id: 133,
@ -308,20 +308,20 @@ acceptance("Poll quote", {
actions_summary: [ actions_summary: [
{ {
id: 3, id: 3,
can_act: true can_act: true,
}, },
{ {
id: 4, id: 4,
can_act: true can_act: true,
}, },
{ {
id: 8, id: 8,
can_act: true can_act: true,
}, },
{ {
id: 7, id: 7,
can_act: true can_act: true,
} },
], ],
moderator: false, moderator: false,
admin: true, admin: true,
@ -348,16 +348,16 @@ acceptance("Poll quote", {
{ {
id: "bf48cd4958a17180e2a298e246988f94", id: "bf48cd4958a17180e2a298e246988f94",
html: "Alpha", html: "Alpha",
votes: 0 votes: 0,
}, },
{ {
id: "c19aa835729ab0413a84a2c9850c4005", id: "c19aa835729ab0413a84a2c9850c4005",
html: "Beta", html: "Beta",
votes: 0 votes: 0,
} },
], ],
voters: 0, voters: 0,
chart_type: "bar" chart_type: "bar",
}, },
{ {
name: "poll2", name: "poll2",
@ -368,25 +368,25 @@ acceptance("Poll quote", {
{ {
id: "def034c6770c6fd3754c054ef9ec4721", id: "def034c6770c6fd3754c054ef9ec4721",
html: "First", html: "First",
votes: 0 votes: 0,
}, },
{ {
id: "e0f55d1a981683789bec2a0b05eb70ef", id: "e0f55d1a981683789bec2a0b05eb70ef",
html: "Second", html: "Second",
votes: 0 votes: 0,
} },
], ],
voters: 0, voters: 0,
chart_type: "bar" chart_type: "bar",
} },
] ],
}) })
); );
}); });
}); });
server.get("/t/topic_with_two_quoted_polls.json", () => { server.get("/t/topic_with_two_quoted_polls.json", () => {
return new Promise(resolve => { return new Promise((resolve) => {
resolve( resolve(
helper.response({ helper.response({
post_stream: { post_stream: {
@ -430,8 +430,8 @@ acceptance("Poll quote", {
internal: true, internal: true,
reflection: false, reflection: false,
title: "Topic with two polls", title: "Topic with two polls",
clicks: 0 clicks: 0,
} },
], ],
read: true, read: true,
user_title: "Tester", user_title: "Tester",
@ -440,20 +440,20 @@ acceptance("Poll quote", {
actions_summary: [ actions_summary: [
{ {
id: 3, id: 3,
can_act: true can_act: true,
}, },
{ {
id: 4, id: 4,
can_act: true can_act: true,
}, },
{ {
id: 8, id: 8,
can_act: true can_act: true,
}, },
{ {
id: 7, id: 7,
can_act: true can_act: true,
} },
], ],
moderator: false, moderator: false,
admin: true, admin: true,
@ -469,10 +469,10 @@ acceptance("Poll quote", {
reviewable_id: 0, reviewable_id: 0,
reviewable_score_count: 0, reviewable_score_count: 0,
reviewable_score_pending_count: 0, reviewable_score_pending_count: 0,
calendar_details: [] calendar_details: [],
} },
], ],
stream: [134] stream: [134],
}, },
timeline_lookup: [[1, 0]], timeline_lookup: [[1, 0]],
suggested_topics: [ suggested_topics: [
@ -516,10 +516,10 @@ acceptance("Poll quote", {
username: "foo2", username: "foo2",
name: null, name: null,
avatar_template: avatar_template:
"/letter_avatar_proxy/v4/letter/f/8edcca/{size}.png" "/letter_avatar_proxy/v4/letter/f/8edcca/{size}.png",
} },
} },
] ],
}, },
{ {
id: 130, id: 130,
@ -561,11 +561,11 @@ acceptance("Poll quote", {
username: "bianca", username: "bianca",
name: null, name: null,
avatar_template: avatar_template:
"/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png" "/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png",
} },
} },
] ],
} },
], ],
tags: [], tags: [],
id: 131, id: 131,
@ -609,20 +609,20 @@ acceptance("Poll quote", {
id: 4, id: 4,
count: 0, count: 0,
hidden: false, hidden: false,
can_act: true can_act: true,
}, },
{ {
id: 8, id: 8,
count: 0, count: 0,
hidden: false, hidden: false,
can_act: true can_act: true,
}, },
{ {
id: 7, id: 7,
count: 0, count: 0,
hidden: false, hidden: false,
can_act: true can_act: true,
} },
], ],
chunk_size: 20, chunk_size: 20,
bookmarked: false, bookmarked: false,
@ -666,33 +666,33 @@ acceptance("Poll quote", {
primary_group_name: null, primary_group_name: null,
primary_group_flair_url: null, primary_group_flair_url: null,
primary_group_flair_color: null, primary_group_flair_color: null,
primary_group_flair_bg_color: null primary_group_flair_bg_color: null,
} },
], ],
created_by: { created_by: {
id: 1, id: 1,
username: "bianca", username: "bianca",
name: null, name: null,
avatar_template: avatar_template:
"/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png" "/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png",
}, },
last_poster: { last_poster: {
id: 1, id: 1,
username: "bianca", username: "bianca",
name: null, name: null,
avatar_template: avatar_template:
"/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png" "/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png",
} },
}, },
pending_posts: [] pending_posts: [],
}) })
); );
}); });
}); });
} },
}); });
test("Quoted polls", async assert => { test("Quoted polls", async (assert) => {
await visit("/t/-/topic_with_two_quoted_polls"); await visit("/t/-/topic_with_two_quoted_polls");
await click(".quote-controls"); await click(".quote-controls");
assert.equal(find(".poll").length, 2); assert.equal(find(".poll").length, 2);

View File

@ -6,10 +6,10 @@ acceptance("Rendering polls with bar charts - desktop", {
settings: { poll_enabled: true }, settings: { poll_enabled: true },
beforeEach() { beforeEach() {
clearPopupMenuOptionsCallback(); clearPopupMenuOptionsCallback();
} },
}); });
test("Polls", async assert => { test("Polls", async (assert) => {
await visit("/t/-/15"); await visit("/t/-/15");
const polls = find(".poll"); const polls = find(".poll");
@ -29,7 +29,7 @@ test("Polls", async assert => {
); );
}); });
test("Public poll", async assert => { test("Public poll", async (assert) => {
await visit("/t/-/14"); await visit("/t/-/14");
const polls = find(".poll"); const polls = find(".poll");
@ -52,10 +52,10 @@ test("Public poll", async assert => {
id: 777, id: 777,
username: "bruce777", username: "bruce777",
avatar_template: "/images/avatar.png", avatar_template: "/images/avatar.png",
name: "Bruce Wayne" name: "Bruce Wayne",
} },
] ],
} },
}; };
return [200, { "Content-Type": "application/json" }, body]; return [200, { "Content-Type": "application/json" }, body];
@ -70,7 +70,7 @@ test("Public poll", async assert => {
); );
}); });
test("Public number poll", async assert => { test("Public number poll", async (assert) => {
await visit("/t/-/13"); await visit("/t/-/13");
const polls = find(".poll"); const polls = find(".poll");
@ -96,8 +96,8 @@ test("Public number poll", async assert => {
id: 600 + i, id: 600 + i,
username: `bruce${600 + i}`, username: `bruce${600 + i}`,
avatar_template: "/images/avatar.png", avatar_template: "/images/avatar.png",
name: "Bruce Wayne" name: "Bruce Wayne",
})) })),
}; };
return [200, { "Content-Type": "application/json" }, body]; return [200, { "Content-Type": "application/json" }, body];

View File

@ -7,10 +7,10 @@ acceptance("Rendering polls with bar charts - mobile", {
settings: { poll_enabled: true }, settings: { poll_enabled: true },
beforeEach() { beforeEach() {
clearPopupMenuOptionsCallback(); clearPopupMenuOptionsCallback();
} },
}); });
test("Public number poll", async assert => { test("Public number poll", async (assert) => {
await visit("/t/-/13"); await visit("/t/-/13");
const polls = find(".poll"); const polls = find(".poll");
@ -36,8 +36,8 @@ test("Public number poll", async assert => {
id: 500 + i, id: 500 + i,
username: `bruce${500 + i}`, username: `bruce${500 + i}`,
avatar_template: "/images/avatar.png", avatar_template: "/images/avatar.png",
name: "Bruce Wayne" name: "Bruce Wayne",
})) })),
}; };
return [200, { "Content-Type": "application/json" }, body]; return [200, { "Content-Type": "application/json" }, body];

View File

@ -3,18 +3,18 @@ import { controllerModule } from "helpers/qunit-helpers";
controllerModule("controller:poll-ui-builder", { controllerModule("controller:poll-ui-builder", {
setupController(controller) { setupController(controller) {
controller.set("toolbarEvent", { controller.set("toolbarEvent", {
getText: () => "" getText: () => "",
}); });
}, },
needs: ["controller:modal"] needs: ["controller:modal"],
}); });
test("isMultiple", function(assert) { test("isMultiple", function (assert) {
const controller = this.subject(); const controller = this.subject();
controller.setProperties({ controller.setProperties({
pollType: controller.multiplePollType, pollType: controller.multiplePollType,
pollOptions: "a" pollOptions: "a",
}); });
assert.equal(controller.isMultiple, true, "it should be true"); assert.equal(controller.isMultiple, true, "it should be true");
@ -28,7 +28,7 @@ test("isMultiple", function(assert) {
assert.equal(controller.isMultiple, false, "it should be false"); assert.equal(controller.isMultiple, false, "it should be false");
}); });
test("isNumber", function(assert) { test("isNumber", function (assert) {
const controller = this.subject(); const controller = this.subject();
controller.set("pollType", controller.regularPollType); controller.set("pollType", controller.regularPollType);
@ -40,7 +40,7 @@ test("isNumber", function(assert) {
assert.equal(controller.isNumber, true, "it should be true"); assert.equal(controller.isNumber, true, "it should be true");
}); });
test("showMinMax", function(assert) { test("showMinMax", function (assert) {
const controller = this.subject(); const controller = this.subject();
controller.set("pollType", controller.numberPollType); controller.set("pollType", controller.numberPollType);
@ -53,7 +53,7 @@ test("showMinMax", function(assert) {
assert.equal(controller.showMinMax, false, "it should be false"); assert.equal(controller.showMinMax, false, "it should be false");
}); });
test("pollOptionsCount", function(assert) { test("pollOptionsCount", function (assert) {
const controller = this.subject(); const controller = this.subject();
controller.set("pollOptions", "1\n2\n"); controller.set("pollOptions", "1\n2\n");
@ -65,12 +65,12 @@ test("pollOptionsCount", function(assert) {
assert.equal(controller.pollOptionsCount, 0, "it should equal 0"); assert.equal(controller.pollOptionsCount, 0, "it should equal 0");
}); });
test("pollMinOptions", function(assert) { test("pollMinOptions", function (assert) {
const controller = this.subject(); const controller = this.subject();
controller.setProperties({ controller.setProperties({
pollType: controller.multiplePollType, pollType: controller.multiplePollType,
pollOptions: "z" pollOptions: "z",
}); });
assert.deepEqual( assert.deepEqual(
@ -85,7 +85,7 @@ test("pollMinOptions", function(assert) {
controller.pollMinOptions, controller.pollMinOptions,
[ [
{ name: 1, value: 1 }, { name: 1, value: 1 },
{ name: 2, value: 2 } { name: 2, value: 2 },
], ],
"it should return the right options" "it should return the right options"
); );
@ -97,19 +97,19 @@ test("pollMinOptions", function(assert) {
controller.pollMinOptions, controller.pollMinOptions,
[ [
{ name: 1, value: 1 }, { name: 1, value: 1 },
{ name: 2, value: 2 } { name: 2, value: 2 },
], ],
"it should return the right options" "it should return the right options"
); );
}); });
test("pollMaxOptions", function(assert) { test("pollMaxOptions", function (assert) {
const controller = this.subject(); const controller = this.subject();
controller.setProperties({ controller.setProperties({
pollType: controller.multiplePollType, pollType: controller.multiplePollType,
pollOptions: "y", pollOptions: "y",
pollMin: 1 pollMin: 1,
}); });
assert.deepEqual( assert.deepEqual(
@ -130,7 +130,7 @@ test("pollMaxOptions", function(assert) {
controller.setProperties({ controller.setProperties({
pollType: controller.get("numberPollType"), pollType: controller.get("numberPollType"),
pollStep: 2, pollStep: 2,
pollMin: 1 pollMin: 1,
}); });
assert.deepEqual( assert.deepEqual(
@ -140,13 +140,13 @@ test("pollMaxOptions", function(assert) {
{ name: 3, value: 3 }, { name: 3, value: 3 },
{ name: 4, value: 4 }, { name: 4, value: 4 },
{ name: 5, value: 5 }, { name: 5, value: 5 },
{ name: 6, value: 6 } { name: 6, value: 6 },
], ],
"it should return the right options" "it should return the right options"
); );
}); });
test("pollStepOptions", function(assert) { test("pollStepOptions", function (assert) {
const controller = this.subject(); const controller = this.subject();
controller.siteSettings.poll_maximum_options = 3; controller.siteSettings.poll_maximum_options = 3;
@ -159,13 +159,13 @@ test("pollStepOptions", function(assert) {
[ [
{ name: 1, value: 1 }, { name: 1, value: 1 },
{ name: 2, value: 2 }, { name: 2, value: 2 },
{ name: 3, value: 3 } { name: 3, value: 3 },
], ],
"it should return the right options" "it should return the right options"
); );
}); });
test("disableInsert", function(assert) { test("disableInsert", function (assert) {
const controller = this.subject(); const controller = this.subject();
assert.equal(controller.disableInsert, true, "it should be true"); assert.equal(controller.disableInsert, true, "it should be true");
@ -180,33 +180,33 @@ test("disableInsert", function(assert) {
controller.setProperties({ controller.setProperties({
pollType: controller.regularPollType, pollType: controller.regularPollType,
pollOptions: "a\nb\nc" pollOptions: "a\nb\nc",
}); });
assert.equal(controller.disableInsert, false, "it should be false"); assert.equal(controller.disableInsert, false, "it should be false");
controller.setProperties({ controller.setProperties({
pollType: controller.regularPollType, pollType: controller.regularPollType,
pollOptions: "" pollOptions: "",
}); });
assert.equal(controller.disableInsert, true, "it should be true"); assert.equal(controller.disableInsert, true, "it should be true");
controller.setProperties({ controller.setProperties({
pollType: controller.regularPollType, pollType: controller.regularPollType,
pollOptions: "w" pollOptions: "w",
}); });
assert.equal(controller.disableInsert, false, "it should be false"); assert.equal(controller.disableInsert, false, "it should be false");
}); });
test("number pollOutput", function(assert) { test("number pollOutput", function (assert) {
const controller = this.subject(); const controller = this.subject();
controller.siteSettings.poll_maximum_options = 20; controller.siteSettings.poll_maximum_options = 20;
controller.setProperties({ controller.setProperties({
pollType: controller.numberPollType, pollType: controller.numberPollType,
pollMin: 1 pollMin: 1,
}); });
assert.equal( assert.equal(
@ -240,14 +240,14 @@ test("number pollOutput", function(assert) {
); );
}); });
test("regular pollOutput", function(assert) { test("regular pollOutput", function (assert) {
const controller = this.subject(); const controller = this.subject();
controller.siteSettings.poll_maximum_options = 20; controller.siteSettings.poll_maximum_options = 20;
controller.set("pollOptions", "1\n2"); controller.set("pollOptions", "1\n2");
controller.setProperties({ controller.setProperties({
pollOptions: "1\n2", pollOptions: "1\n2",
pollType: controller.regularPollType pollType: controller.regularPollType,
}); });
assert.equal( assert.equal(
@ -273,14 +273,14 @@ test("regular pollOutput", function(assert) {
); );
}); });
test("multiple pollOutput", function(assert) { test("multiple pollOutput", function (assert) {
const controller = this.subject(); const controller = this.subject();
controller.siteSettings.poll_maximum_options = 20; controller.siteSettings.poll_maximum_options = 20;
controller.setProperties({ controller.setProperties({
pollType: controller.multiplePollType, pollType: controller.multiplePollType,
pollMin: 1, pollMin: 1,
pollOptions: "\n\n1\n\n2" pollOptions: "\n\n1\n\n2",
}); });
assert.equal( assert.equal(
@ -298,7 +298,7 @@ test("multiple pollOutput", function(assert) {
); );
}); });
test("staff_only option is not present for non-staff", function(assert) { test("staff_only option is not present for non-staff", function (assert) {
const controller = this.subject(); const controller = this.subject();
controller.currentUser = { staff: false }; controller.currentUser = { staff: false };
@ -308,12 +308,12 @@ test("staff_only option is not present for non-staff", function(assert) {
); );
}); });
test("poll result is always by default", function(assert) { test("poll result is always by default", function (assert) {
const controller = this.subject(); const controller = this.subject();
assert.equal(controller.pollResult, "always"); assert.equal(controller.pollResult, "always");
}); });
test("staff_only option is present for staff", function(assert) { test("staff_only option is present for staff", function (assert) {
const controller = this.subject(); const controller = this.subject();
controller.currentUser = { staff: true }; controller.currentUser = { staff: true };

View File

@ -15,7 +15,7 @@ widgetTest("single, not selected", {
test(assert) { test(assert) {
assert.ok(find("li .d-icon-far-circle:eq(0)").length === 1); assert.ok(find("li .d-icon-far-circle:eq(0)").length === 1);
} },
}); });
widgetTest("single, selected", { widgetTest("single, selected", {
@ -28,7 +28,7 @@ widgetTest("single, selected", {
test(assert) { test(assert) {
assert.ok(find("li .d-icon-circle:eq(0)").length === 1); assert.ok(find("li .d-icon-circle:eq(0)").length === 1);
} },
}); });
widgetTest("multi, not selected", { widgetTest("multi, not selected", {
@ -38,13 +38,13 @@ widgetTest("multi, not selected", {
this.setProperties({ this.setProperties({
option: { id: "opt-id" }, option: { id: "opt-id" },
isMultiple: true, isMultiple: true,
vote: [] vote: [],
}); });
}, },
test(assert) { test(assert) {
assert.ok(find("li .d-icon-far-square:eq(0)").length === 1); assert.ok(find("li .d-icon-far-square:eq(0)").length === 1);
} },
}); });
widgetTest("multi, selected", { widgetTest("multi, selected", {
@ -54,11 +54,11 @@ widgetTest("multi, selected", {
this.setProperties({ this.setProperties({
option: { id: "opt-id" }, option: { id: "opt-id" },
isMultiple: true, isMultiple: true,
vote: ["opt-id"] vote: ["opt-id"],
}); });
}, },
test(assert) { test(assert) {
assert.ok(find("li .d-icon-far-check-square:eq(0)").length === 1); assert.ok(find("li .d-icon-far-check-square:eq(0)").length === 1);
} },
}); });

View File

@ -15,7 +15,7 @@ widgetTest("options in descending order", {
"poll", "poll",
EmberObject.create({ EmberObject.create({
options: [{ votes: 5 }, { votes: 4 }], options: [{ votes: 5 }, { votes: 4 }],
voters: 9 voters: 9,
}) })
); );
}, },
@ -23,7 +23,7 @@ widgetTest("options in descending order", {
test(assert) { test(assert) {
assert.equal(find(".option .percentage:eq(0)").text(), "56%"); assert.equal(find(".option .percentage:eq(0)").text(), "56%");
assert.equal(find(".option .percentage:eq(1)").text(), "44%"); assert.equal(find(".option .percentage:eq(1)").text(), "44%");
} },
}); });
widgetTest("options in ascending order", { widgetTest("options in ascending order", {
@ -34,7 +34,7 @@ widgetTest("options in ascending order", {
"poll", "poll",
EmberObject.create({ EmberObject.create({
options: [{ votes: 4 }, { votes: 5 }], options: [{ votes: 4 }, { votes: 5 }],
voters: 9 voters: 9,
}) })
); );
}, },
@ -42,7 +42,7 @@ widgetTest("options in ascending order", {
test(assert) { test(assert) {
assert.equal(find(".option .percentage:eq(0)").text(), "56%"); assert.equal(find(".option .percentage:eq(0)").text(), "56%");
assert.equal(find(".option .percentage:eq(1)").text(), "44%"); assert.equal(find(".option .percentage:eq(1)").text(), "44%");
} },
}); });
widgetTest("multiple options in descending order", { widgetTest("multiple options in descending order", {
@ -59,9 +59,9 @@ widgetTest("multiple options in descending order", {
{ votes: 2, html: "b" }, { votes: 2, html: "b" },
{ votes: 4, html: "c" }, { votes: 4, html: "c" },
{ votes: 1, html: "b" }, { votes: 1, html: "b" },
{ votes: 1, html: "a" } { votes: 1, html: "a" },
], ],
voters: 12 voters: 12,
}) })
); );
}, },
@ -74,5 +74,5 @@ widgetTest("multiple options in descending order", {
assert.equal(find(".option span:nth-child(2):eq(3)").text(), "a"); assert.equal(find(".option span:nth-child(2):eq(3)").text(), "a");
assert.equal(find(".option .percentage:eq(4)").text(), "8%"); assert.equal(find(".option .percentage:eq(4)").text(), "8%");
assert.equal(find(".option span:nth-child(2):eq(4)").text(), "b"); assert.equal(find(".option span:nth-child(2):eq(4)").text(), "b");
} },
}); });

View File

@ -1,3 +1,4 @@
import I18n from "I18n";
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
import { moduleForWidget, widgetTest } from "helpers/widget-test"; import { moduleForWidget, widgetTest } from "helpers/widget-test";
@ -19,8 +20,8 @@ widgetTest("can vote", {
post: EmberObject.create({ post: EmberObject.create({
id: 42, id: 42,
topic: { topic: {
archived: false archived: false,
} },
}), }),
poll: EmberObject.create({ poll: EmberObject.create({
name: "poll", name: "poll",
@ -29,13 +30,13 @@ widgetTest("can vote", {
results: "always", results: "always",
options: [ options: [
{ id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 0 }, { id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 0 },
{ id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 } { id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 },
], ],
voters: 0, voters: 0,
chart_type: "bar" chart_type: "bar",
}), }),
vote: [], vote: [],
groupableUserFields: [] groupableUserFields: [],
}); });
}, },
@ -56,13 +57,13 @@ widgetTest("can vote", {
results: "always", results: "always",
options: [ options: [
{ id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 1 }, { id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 1 },
{ id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 } { id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 },
], ],
voters: 1, voters: 1,
chart_type: "bar" chart_type: "bar",
}, },
vote: ["1f972d1df351de3ce35a787c89faad29"] vote: ["1f972d1df351de3ce35a787c89faad29"],
} },
]; ];
}); });
@ -70,7 +71,7 @@ widgetTest("can vote", {
assert.equal(requests, 1); assert.equal(requests, 1);
assert.equal(find(".chosen").length, 1); assert.equal(find(".chosen").length, 1);
assert.equal(find(".chosen").text(), "100%yes"); assert.equal(find(".chosen").text(), "100%yes");
} },
}); });
widgetTest("cannot vote if not member of the right group", { widgetTest("cannot vote if not member of the right group", {
@ -81,8 +82,8 @@ widgetTest("cannot vote if not member of the right group", {
post: EmberObject.create({ post: EmberObject.create({
id: 42, id: 42,
topic: { topic: {
archived: false archived: false,
} },
}), }),
poll: EmberObject.create({ poll: EmberObject.create({
name: "poll", name: "poll",
@ -91,14 +92,14 @@ widgetTest("cannot vote if not member of the right group", {
results: "always", results: "always",
options: [ options: [
{ id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 0 }, { id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 0 },
{ id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 } { id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 },
], ],
voters: 0, voters: 0,
chart_type: "bar", chart_type: "bar",
groups: "foo" groups: "foo",
}), }),
vote: [], vote: [],
groupableUserFields: [] groupableUserFields: [],
}); });
}, },
@ -119,14 +120,14 @@ widgetTest("cannot vote if not member of the right group", {
results: "always", results: "always",
options: [ options: [
{ id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 1 }, { id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 1 },
{ id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 } { id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 },
], ],
voters: 1, voters: 1,
chart_type: "bar", chart_type: "bar",
groups: "foo" groups: "foo",
}, },
vote: ["1f972d1df351de3ce35a787c89faad29"] vote: ["1f972d1df351de3ce35a787c89faad29"],
} },
]; ];
}); });
@ -137,5 +138,5 @@ widgetTest("cannot vote if not member of the right group", {
); );
assert.equal(requests, 0); assert.equal(requests, 0);
assert.equal(find(".chosen").length, 0); assert.equal(find(".chosen").length, 0);
} },
}); });