mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 09:12:45 +08:00
DEV: fixes eslint/prettier on github actions (#10601)
This commit is contained in:
parent
c5b8a47901
commit
110f6ec6dd
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
|
@ -146,19 +146,15 @@ jobs:
|
|||
|
||||
- name: ESLint (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)
|
||||
if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'CORE'
|
||||
run: |
|
||||
yarn eslint --ext .js plugins/**/assets/javascripts plugins/**/test/javascripts
|
||||
yarn eslint --ext .es6 plugins/**/assets/javascripts plugins/**/test/javascripts
|
||||
run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern plugins/**/{test,assets}/javascripts
|
||||
|
||||
- name: ESLint (all plugins)
|
||||
if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'PLUGINS'
|
||||
run: |
|
||||
yarn eslint --ext .js plugins/**/assets/javascripts plugins/**/test/javascripts
|
||||
yarn eslint --ext .es6 plugins/**/assets/javascripts plugins/**/test/javascripts
|
||||
run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern plugins/**/{test,assets}/javascripts
|
||||
|
||||
- name: Prettier (core and core plugins)
|
||||
if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'CORE'
|
||||
|
|
|
@ -50,6 +50,6 @@ module.exports = {
|
|||
"simple-unless": true,
|
||||
"style-concatenation": true,
|
||||
"table-groups": true,
|
||||
"link-href-attributes": false
|
||||
}
|
||||
"link-href-attributes": false,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
import I18n from "I18n";
|
||||
import { acceptance } from "helpers/qunit-helpers";
|
||||
import { clearPopupMenuOptionsCallback } from "discourse/controllers/composer";
|
||||
import selectKit from "helpers/select-kit-helper";
|
||||
|
||||
acceptance("Details Button", {
|
||||
loggedIn: true,
|
||||
beforeEach: function() {
|
||||
beforeEach: function () {
|
||||
clearPopupMenuOptionsCallback();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
test("details button", async assert => {
|
||||
test("details button", async (assert) => {
|
||||
const popupMenu = selectKit(".toolbar-popup-menu-options");
|
||||
|
||||
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 popupMenu = selectKit(".toolbar-popup-menu-options");
|
||||
|
||||
|
|
|
@ -7,13 +7,13 @@ const defaultOpts = buildOptions({
|
|||
enable_emoji: true,
|
||||
emoji_set: "emoji_one",
|
||||
highlighted_languages: "json|ruby|javascript",
|
||||
default_code_lang: "auto"
|
||||
default_code_lang: "auto",
|
||||
},
|
||||
censoredWords: "shucks|whiz|whizzer",
|
||||
getURL: url => url
|
||||
getURL: (url) => url,
|
||||
});
|
||||
|
||||
test("details", assert => {
|
||||
test("details", (assert) => {
|
||||
const cooked = (input, expected, text) => {
|
||||
assert.equal(
|
||||
new PrettyText(defaultOpts).cook(input),
|
||||
|
|
|
@ -2,11 +2,11 @@ import { acceptance } from "helpers/qunit-helpers";
|
|||
|
||||
acceptance("Local Dates - composer", {
|
||||
loggedIn: true,
|
||||
settings: { discourse_local_dates_enabled: true }
|
||||
settings: { discourse_local_dates_enabled: true },
|
||||
});
|
||||
|
||||
test("composer bbcode", async assert => {
|
||||
const getAttr = attr => {
|
||||
test("composer bbcode", async (assert) => {
|
||||
const getAttr = (attr) => {
|
||||
return find(".d-editor-preview .discourse-local-date.cooked-date").attr(
|
||||
`data-${attr}`
|
||||
);
|
||||
|
|
|
@ -13,22 +13,22 @@ function buildDateHelper(params = {}) {
|
|||
hour: params.hour || 10,
|
||||
minute: params.minute || 5,
|
||||
timezone: params.timezone,
|
||||
localTimezone: PARIS
|
||||
localTimezone: PARIS,
|
||||
});
|
||||
}
|
||||
|
||||
QUnit.test("#format", assert => {
|
||||
QUnit.test("#format", (assert) => {
|
||||
let date = buildDateHelper({
|
||||
day: 15,
|
||||
month: 2,
|
||||
hour: 15,
|
||||
minute: 36,
|
||||
timezone: PARIS
|
||||
timezone: PARIS,
|
||||
});
|
||||
assert.equal(date.format(), "2020-03-15T15:36:00.000+01:00");
|
||||
});
|
||||
|
||||
QUnit.test("#repetitionsBetweenDates", assert => {
|
||||
QUnit.test("#repetitionsBetweenDates", (assert) => {
|
||||
let date;
|
||||
|
||||
date = buildDateHelper({
|
||||
|
@ -36,7 +36,7 @@ QUnit.test("#repetitionsBetweenDates", assert => {
|
|||
month: 1,
|
||||
hour: 15,
|
||||
minute: 36,
|
||||
timezone: PARIS
|
||||
timezone: PARIS,
|
||||
});
|
||||
assert.equal(
|
||||
date.repetitionsBetweenDates(
|
||||
|
@ -52,7 +52,7 @@ QUnit.test("#repetitionsBetweenDates", assert => {
|
|||
month: 1,
|
||||
hour: 15,
|
||||
minute: 36,
|
||||
timezone: PARIS
|
||||
timezone: PARIS,
|
||||
});
|
||||
assert.equal(
|
||||
date.repetitionsBetweenDates(
|
||||
|
@ -68,7 +68,7 @@ QUnit.test("#repetitionsBetweenDates", assert => {
|
|||
month: 1,
|
||||
hour: 15,
|
||||
minute: 36,
|
||||
timezone: PARIS
|
||||
timezone: PARIS,
|
||||
});
|
||||
assert.equal(
|
||||
date.repetitionsBetweenDates(
|
||||
|
@ -84,7 +84,7 @@ QUnit.test("#repetitionsBetweenDates", assert => {
|
|||
month: 1,
|
||||
hour: 15,
|
||||
minute: 36,
|
||||
timezone: PARIS
|
||||
timezone: PARIS,
|
||||
});
|
||||
assert.equal(
|
||||
date.repetitionsBetweenDates(
|
||||
|
@ -96,7 +96,7 @@ QUnit.test("#repetitionsBetweenDates", assert => {
|
|||
);
|
||||
});
|
||||
|
||||
QUnit.test("#add", assert => {
|
||||
QUnit.test("#add", (assert) => {
|
||||
let date;
|
||||
let futureLocalDate;
|
||||
|
||||
|
@ -105,7 +105,7 @@ QUnit.test("#add", assert => {
|
|||
month: 2,
|
||||
hour: 15,
|
||||
minute: 36,
|
||||
timezone: PARIS
|
||||
timezone: PARIS,
|
||||
});
|
||||
|
||||
assert.notOk(date.isDST());
|
||||
|
@ -122,7 +122,7 @@ QUnit.test("#add", assert => {
|
|||
month: 3,
|
||||
hour: 15,
|
||||
minute: 36,
|
||||
timezone: PARIS
|
||||
timezone: PARIS,
|
||||
});
|
||||
assert.ok(date.isDST());
|
||||
futureLocalDate = date.add(1, "year");
|
||||
|
@ -138,7 +138,7 @@ QUnit.test("#add", assert => {
|
|||
month: 2,
|
||||
hour: 15,
|
||||
minute: 36,
|
||||
timezone: PARIS
|
||||
timezone: PARIS,
|
||||
});
|
||||
assert.notOk(date.isDST());
|
||||
futureLocalDate = date.add(1, "week");
|
||||
|
@ -154,7 +154,7 @@ QUnit.test("#add", assert => {
|
|||
month: 3,
|
||||
hour: 15,
|
||||
minute: 36,
|
||||
timezone: PARIS
|
||||
timezone: PARIS,
|
||||
});
|
||||
|
||||
assert.ok(date.isDST());
|
||||
|
|
|
@ -30,7 +30,7 @@ function freezeTime({ date, timezone }, cb) {
|
|||
sandbox.restore();
|
||||
}
|
||||
|
||||
QUnit.assert.buildsCorrectDate = function(options, expected, message) {
|
||||
QUnit.assert.buildsCorrectDate = function (options, expected, message) {
|
||||
const localTimezone = options.localTimezone || PARIS;
|
||||
delete options.localTimezone;
|
||||
|
||||
|
@ -38,7 +38,7 @@ QUnit.assert.buildsCorrectDate = function(options, expected, message) {
|
|||
Object.assign(
|
||||
{},
|
||||
{
|
||||
date: "2020-03-22"
|
||||
date: "2020-03-22",
|
||||
},
|
||||
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" }, () => {
|
||||
assert.buildsCorrectDate(
|
||||
{ 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(
|
||||
{ date: "2020-04-11", time: "11:00" },
|
||||
{ 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" }, () => {
|
||||
assert.buildsCorrectDate(
|
||||
{ format: "YYYY" },
|
||||
|
@ -96,7 +96,7 @@ QUnit.test("option[format]", assert => {
|
|||
});
|
||||
});
|
||||
|
||||
QUnit.test("option[displayedTimezone]", assert => {
|
||||
QUnit.test("option[displayedTimezone]", (assert) => {
|
||||
freezeTime({}, () => {
|
||||
assert.buildsCorrectDate(
|
||||
{ displayedTimezone: SYDNEY },
|
||||
|
@ -130,7 +130,7 @@ QUnit.test("option[displayedTimezone]", assert => {
|
|||
});
|
||||
});
|
||||
|
||||
QUnit.test("option[timezone]", assert => {
|
||||
QUnit.test("option[timezone]", (assert) => {
|
||||
freezeTime({}, () => {
|
||||
assert.buildsCorrectDate(
|
||||
{ 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 }, () => {
|
||||
assert.buildsCorrectDate(
|
||||
{
|
||||
|
@ -148,10 +148,10 @@ QUnit.test("option[recurring]", assert => {
|
|||
time: "11:00",
|
||||
timezone: PARIS,
|
||||
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"
|
||||
);
|
||||
|
@ -165,10 +165,10 @@ QUnit.test("option[recurring]", assert => {
|
|||
timezone: UTC,
|
||||
recurring: "1.weeks",
|
||||
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"
|
||||
);
|
||||
|
@ -180,10 +180,10 @@ QUnit.test("option[recurring]", assert => {
|
|||
date: "2019-11-25",
|
||||
time: "11:00",
|
||||
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"
|
||||
);
|
||||
|
@ -195,10 +195,10 @@ QUnit.test("option[recurring]", assert => {
|
|||
date: "2020-03-30",
|
||||
time: "11:00",
|
||||
recurring: "1.weeks",
|
||||
timezone: PARIS
|
||||
timezone: PARIS,
|
||||
},
|
||||
{
|
||||
formated: "Today 11:00 AM"
|
||||
formated: "Today 11:00 AM",
|
||||
},
|
||||
"it works to the minute"
|
||||
);
|
||||
|
@ -210,22 +210,22 @@ QUnit.test("option[recurring]", assert => {
|
|||
date: "2020-03-30",
|
||||
time: "11:00",
|
||||
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"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test("option[countown]", assert => {
|
||||
QUnit.test("option[countown]", (assert) => {
|
||||
freezeTime({ date: "2020-03-21 23:59" }, () => {
|
||||
assert.buildsCorrectDate(
|
||||
{
|
||||
countdown: true,
|
||||
timezone: PARIS
|
||||
timezone: PARIS,
|
||||
},
|
||||
{ formated: "a minute" },
|
||||
"it shows the time remaining"
|
||||
|
@ -236,19 +236,19 @@ QUnit.test("option[countown]", assert => {
|
|||
assert.buildsCorrectDate(
|
||||
{
|
||||
countdown: true,
|
||||
timezone: PARIS
|
||||
timezone: PARIS,
|
||||
},
|
||||
{
|
||||
formated: I18n.t(
|
||||
"discourse_local_dates.relative_dates.countdown.passed"
|
||||
)
|
||||
),
|
||||
},
|
||||
"it shows the date has passed"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test("option[calendar]", assert => {
|
||||
QUnit.test("option[calendar]", (assert) => {
|
||||
freezeTime({ date: "2020-03-23 23:00" }, () => {
|
||||
assert.buildsCorrectDate(
|
||||
{ date: "2020-03-22", time: "23:59", timezone: PARIS },
|
||||
|
@ -313,7 +313,7 @@ QUnit.test("option[calendar]", assert => {
|
|||
{
|
||||
date: "2020-05-13",
|
||||
time: "18:00",
|
||||
localTimezone: LOS_ANGELES
|
||||
localTimezone: LOS_ANGELES,
|
||||
},
|
||||
{ formated: "Tomorrow 11:00 AM" },
|
||||
"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" }, () => {
|
||||
assert.buildsCorrectDate(
|
||||
{ timezone: PARIS },
|
||||
|
@ -331,9 +331,9 @@ QUnit.test("previews", assert => {
|
|||
current: true,
|
||||
formated:
|
||||
"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,
|
||||
formated:
|
||||
"Sunday, March 22, 2020 12:00 AM → Monday, March 23, 2020 12:00 AM",
|
||||
timezone: "Paris"
|
||||
timezone: "Paris",
|
||||
},
|
||||
{
|
||||
formated:
|
||||
"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,
|
||||
formated:
|
||||
"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,
|
||||
formated:
|
||||
"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,
|
||||
formated:
|
||||
"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,
|
||||
formated: "March 22, 2020 11:34 AM",
|
||||
timezone: "Paris"
|
||||
}
|
||||
]
|
||||
timezone: "Paris",
|
||||
},
|
||||
],
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -427,7 +427,7 @@ QUnit.test("previews", assert => {
|
|||
{
|
||||
timezone: PARIS,
|
||||
date: "2020-04-07",
|
||||
timezones: [LONDON, LAGOS, SYDNEY]
|
||||
timezones: [LONDON, LAGOS, SYDNEY],
|
||||
},
|
||||
{
|
||||
previews: [
|
||||
|
@ -435,24 +435,24 @@ QUnit.test("previews", assert => {
|
|||
current: true,
|
||||
formated:
|
||||
"Tuesday, April 7, 2020 12:00 AM → Wednesday, April 8, 2020 12:00 AM",
|
||||
timezone: "Paris"
|
||||
timezone: "Paris",
|
||||
},
|
||||
{
|
||||
formated:
|
||||
"Monday, April 6, 2020 11:00 PM → Tuesday, April 7, 2020 11:00 PM",
|
||||
timezone: "London"
|
||||
timezone: "London",
|
||||
},
|
||||
{
|
||||
formated:
|
||||
"Monday, April 6, 2020 11:00 PM → Tuesday, April 7, 2020 11:00 PM",
|
||||
timezone: "Lagos"
|
||||
timezone: "Lagos",
|
||||
},
|
||||
{
|
||||
formated:
|
||||
"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,
|
||||
date: "2020-04-07",
|
||||
time: "14:54",
|
||||
timezones: [LONDON, LAGOS, SYDNEY]
|
||||
timezones: [LONDON, LAGOS, SYDNEY],
|
||||
},
|
||||
{
|
||||
previews: [
|
||||
{
|
||||
current: true,
|
||||
formated: "April 7, 2020 2:54 PM",
|
||||
timezone: "Paris"
|
||||
timezone: "Paris",
|
||||
},
|
||||
{
|
||||
formated: "April 7, 2020 1:54 PM",
|
||||
timezone: "London"
|
||||
timezone: "London",
|
||||
},
|
||||
{
|
||||
formated: "April 7, 2020 1:54 PM",
|
||||
timezone: "Lagos"
|
||||
timezone: "Lagos",
|
||||
},
|
||||
{
|
||||
formated: "April 7, 2020 10:54 PM",
|
||||
timezone: "Sydney"
|
||||
}
|
||||
]
|
||||
timezone: "Sydney",
|
||||
},
|
||||
],
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -494,20 +494,20 @@ QUnit.test("previews", assert => {
|
|||
{
|
||||
date: "2020-05-13",
|
||||
time: "18:00",
|
||||
localTimezone: LOS_ANGELES
|
||||
localTimezone: LOS_ANGELES,
|
||||
},
|
||||
{
|
||||
previews: [
|
||||
{
|
||||
current: true,
|
||||
formated: "May 13, 2020 11:00 AM",
|
||||
timezone: "Los Angeles"
|
||||
timezone: "Los Angeles",
|
||||
},
|
||||
{
|
||||
formated: "May 13, 2020 6:00 PM",
|
||||
timezone: "UTC"
|
||||
}
|
||||
]
|
||||
timezone: "UTC",
|
||||
},
|
||||
],
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -10,7 +10,7 @@ acceptance("Poll breakdown", {
|
|||
},
|
||||
pretend(server, helper) {
|
||||
server.get("/polls/grouped_poll_results.json", () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve) => {
|
||||
resolve(
|
||||
helper.response({
|
||||
grouped_results: [
|
||||
|
@ -20,19 +20,19 @@ acceptance("Poll breakdown", {
|
|||
{
|
||||
digest: "687a1ccf3c6a260f9aeeb7f68a1d463c",
|
||||
html: "This Is",
|
||||
votes: 1
|
||||
votes: 1,
|
||||
},
|
||||
{
|
||||
digest: "9377906763a1221d31d656ea0c4a4495",
|
||||
html: "A test for sure",
|
||||
votes: 1
|
||||
votes: 1,
|
||||
},
|
||||
{
|
||||
digest: "ecf47c65a85a0bb20029072b1b721977",
|
||||
html: "Why not give it some more",
|
||||
votes: 1
|
||||
}
|
||||
]
|
||||
votes: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
group: "Marketing",
|
||||
|
@ -40,29 +40,29 @@ acceptance("Poll breakdown", {
|
|||
{
|
||||
digest: "687a1ccf3c6a260f9aeeb7f68a1d463c",
|
||||
html: "This Is",
|
||||
votes: 1
|
||||
votes: 1,
|
||||
},
|
||||
{
|
||||
digest: "9377906763a1221d31d656ea0c4a4495",
|
||||
html: "A test for sure",
|
||||
votes: 1
|
||||
votes: 1,
|
||||
},
|
||||
{
|
||||
digest: "ecf47c65a85a0bb20029072b1b721977",
|
||||
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");
|
||||
|
||||
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 click(".poll-show-breakdown:first");
|
||||
|
||||
|
|
|
@ -6,14 +6,14 @@ acceptance("Poll Builder - polls are disabled", {
|
|||
loggedIn: true,
|
||||
settings: {
|
||||
poll_enabled: false,
|
||||
poll_minimum_trust_level_to_create: 2
|
||||
poll_minimum_trust_level_to_create: 2,
|
||||
},
|
||||
beforeEach: function() {
|
||||
beforeEach: function () {
|
||||
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 });
|
||||
|
||||
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 });
|
||||
|
||||
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 });
|
||||
|
||||
await displayPollBuilderButton();
|
||||
|
|
|
@ -7,14 +7,14 @@ acceptance("Poll Builder - polls are enabled", {
|
|||
loggedIn: true,
|
||||
settings: {
|
||||
poll_enabled: true,
|
||||
poll_minimum_trust_level_to_create: 1
|
||||
poll_minimum_trust_level_to_create: 1,
|
||||
},
|
||||
beforeEach() {
|
||||
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 });
|
||||
|
||||
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 });
|
||||
|
||||
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 });
|
||||
|
||||
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();
|
||||
|
||||
const popupMenu = selectKit(".toolbar-popup-menu-options");
|
||||
|
|
|
@ -2,10 +2,10 @@ import { acceptance } from "helpers/qunit-helpers";
|
|||
|
||||
acceptance("Rendering polls with pie charts - desktop", {
|
||||
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");
|
||||
|
||||
const poll = find(".poll")[0];
|
||||
|
|
|
@ -10,7 +10,7 @@ acceptance("Poll quote", {
|
|||
},
|
||||
pretend(server, helper) {
|
||||
server.get("/t/topic_with_two_polls.json", () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve) => {
|
||||
resolve(
|
||||
helper.response({
|
||||
post_stream: {
|
||||
|
@ -54,8 +54,8 @@ acceptance("Poll quote", {
|
|||
internal: true,
|
||||
reflection: true,
|
||||
title: "Topic with two quoted polls",
|
||||
clicks: 0
|
||||
}
|
||||
clicks: 0,
|
||||
},
|
||||
],
|
||||
read: true,
|
||||
user_title: "Tester",
|
||||
|
@ -64,20 +64,20 @@ acceptance("Poll quote", {
|
|||
actions_summary: [
|
||||
{
|
||||
id: 3,
|
||||
can_act: true
|
||||
can_act: true,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
can_act: true
|
||||
can_act: true,
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
can_act: true
|
||||
can_act: true,
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
can_act: true
|
||||
}
|
||||
can_act: true,
|
||||
},
|
||||
],
|
||||
moderator: false,
|
||||
admin: true,
|
||||
|
@ -104,16 +104,16 @@ acceptance("Poll quote", {
|
|||
{
|
||||
id: "bf48cd4958a17180e2a298e246988f94",
|
||||
html: "Alpha",
|
||||
votes: 0
|
||||
votes: 0,
|
||||
},
|
||||
{
|
||||
id: "c19aa835729ab0413a84a2c9850c4005",
|
||||
html: "Beta",
|
||||
votes: 0
|
||||
}
|
||||
votes: 0,
|
||||
},
|
||||
],
|
||||
voters: 0,
|
||||
chart_type: "bar"
|
||||
chart_type: "bar",
|
||||
},
|
||||
{
|
||||
name: "poll2",
|
||||
|
@ -124,21 +124,21 @@ acceptance("Poll quote", {
|
|||
{
|
||||
id: "def034c6770c6fd3754c054ef9ec4721",
|
||||
html: "First",
|
||||
votes: 0
|
||||
votes: 0,
|
||||
},
|
||||
{
|
||||
id: "e0f55d1a981683789bec2a0b05eb70ef",
|
||||
html: "Second",
|
||||
votes: 0
|
||||
}
|
||||
votes: 0,
|
||||
},
|
||||
],
|
||||
voters: 0,
|
||||
chart_type: "bar"
|
||||
}
|
||||
]
|
||||
}
|
||||
chart_type: "bar",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
stream: [133]
|
||||
stream: [133],
|
||||
},
|
||||
timeline_lookup: [[1, 0]],
|
||||
suggested_topics: [],
|
||||
|
@ -184,20 +184,20 @@ acceptance("Poll quote", {
|
|||
id: 4,
|
||||
count: 0,
|
||||
hidden: false,
|
||||
can_act: true
|
||||
can_act: true,
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
count: 0,
|
||||
hidden: false,
|
||||
can_act: true
|
||||
can_act: true,
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
count: 0,
|
||||
hidden: false,
|
||||
can_act: true
|
||||
}
|
||||
can_act: true,
|
||||
},
|
||||
],
|
||||
chunk_size: 20,
|
||||
bookmarked: false,
|
||||
|
@ -241,32 +241,32 @@ acceptance("Poll quote", {
|
|||
primary_group_name: null,
|
||||
primary_group_flair_url: null,
|
||||
primary_group_flair_color: null,
|
||||
primary_group_flair_bg_color: null
|
||||
}
|
||||
primary_group_flair_bg_color: null,
|
||||
},
|
||||
],
|
||||
created_by: {
|
||||
id: 1,
|
||||
username: "bianca",
|
||||
name: null,
|
||||
avatar_template:
|
||||
"/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png"
|
||||
"/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png",
|
||||
},
|
||||
last_poster: {
|
||||
id: 1,
|
||||
username: "bianca",
|
||||
name: null,
|
||||
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", () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve) => {
|
||||
resolve(
|
||||
helper.response({
|
||||
id: 133,
|
||||
|
@ -308,20 +308,20 @@ acceptance("Poll quote", {
|
|||
actions_summary: [
|
||||
{
|
||||
id: 3,
|
||||
can_act: true
|
||||
can_act: true,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
can_act: true
|
||||
can_act: true,
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
can_act: true
|
||||
can_act: true,
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
can_act: true
|
||||
}
|
||||
can_act: true,
|
||||
},
|
||||
],
|
||||
moderator: false,
|
||||
admin: true,
|
||||
|
@ -348,16 +348,16 @@ acceptance("Poll quote", {
|
|||
{
|
||||
id: "bf48cd4958a17180e2a298e246988f94",
|
||||
html: "Alpha",
|
||||
votes: 0
|
||||
votes: 0,
|
||||
},
|
||||
{
|
||||
id: "c19aa835729ab0413a84a2c9850c4005",
|
||||
html: "Beta",
|
||||
votes: 0
|
||||
}
|
||||
votes: 0,
|
||||
},
|
||||
],
|
||||
voters: 0,
|
||||
chart_type: "bar"
|
||||
chart_type: "bar",
|
||||
},
|
||||
{
|
||||
name: "poll2",
|
||||
|
@ -368,25 +368,25 @@ acceptance("Poll quote", {
|
|||
{
|
||||
id: "def034c6770c6fd3754c054ef9ec4721",
|
||||
html: "First",
|
||||
votes: 0
|
||||
votes: 0,
|
||||
},
|
||||
{
|
||||
id: "e0f55d1a981683789bec2a0b05eb70ef",
|
||||
html: "Second",
|
||||
votes: 0
|
||||
}
|
||||
votes: 0,
|
||||
},
|
||||
],
|
||||
voters: 0,
|
||||
chart_type: "bar"
|
||||
}
|
||||
]
|
||||
chart_type: "bar",
|
||||
},
|
||||
],
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
server.get("/t/topic_with_two_quoted_polls.json", () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve) => {
|
||||
resolve(
|
||||
helper.response({
|
||||
post_stream: {
|
||||
|
@ -430,8 +430,8 @@ acceptance("Poll quote", {
|
|||
internal: true,
|
||||
reflection: false,
|
||||
title: "Topic with two polls",
|
||||
clicks: 0
|
||||
}
|
||||
clicks: 0,
|
||||
},
|
||||
],
|
||||
read: true,
|
||||
user_title: "Tester",
|
||||
|
@ -440,20 +440,20 @@ acceptance("Poll quote", {
|
|||
actions_summary: [
|
||||
{
|
||||
id: 3,
|
||||
can_act: true
|
||||
can_act: true,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
can_act: true
|
||||
can_act: true,
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
can_act: true
|
||||
can_act: true,
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
can_act: true
|
||||
}
|
||||
can_act: true,
|
||||
},
|
||||
],
|
||||
moderator: false,
|
||||
admin: true,
|
||||
|
@ -469,10 +469,10 @@ acceptance("Poll quote", {
|
|||
reviewable_id: 0,
|
||||
reviewable_score_count: 0,
|
||||
reviewable_score_pending_count: 0,
|
||||
calendar_details: []
|
||||
}
|
||||
calendar_details: [],
|
||||
},
|
||||
],
|
||||
stream: [134]
|
||||
stream: [134],
|
||||
},
|
||||
timeline_lookup: [[1, 0]],
|
||||
suggested_topics: [
|
||||
|
@ -516,10 +516,10 @@ acceptance("Poll quote", {
|
|||
username: "foo2",
|
||||
name: null,
|
||||
avatar_template:
|
||||
"/letter_avatar_proxy/v4/letter/f/8edcca/{size}.png"
|
||||
}
|
||||
}
|
||||
]
|
||||
"/letter_avatar_proxy/v4/letter/f/8edcca/{size}.png",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 130,
|
||||
|
@ -561,11 +561,11 @@ acceptance("Poll quote", {
|
|||
username: "bianca",
|
||||
name: null,
|
||||
avatar_template:
|
||||
"/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
"/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
tags: [],
|
||||
id: 131,
|
||||
|
@ -609,20 +609,20 @@ acceptance("Poll quote", {
|
|||
id: 4,
|
||||
count: 0,
|
||||
hidden: false,
|
||||
can_act: true
|
||||
can_act: true,
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
count: 0,
|
||||
hidden: false,
|
||||
can_act: true
|
||||
can_act: true,
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
count: 0,
|
||||
hidden: false,
|
||||
can_act: true
|
||||
}
|
||||
can_act: true,
|
||||
},
|
||||
],
|
||||
chunk_size: 20,
|
||||
bookmarked: false,
|
||||
|
@ -666,33 +666,33 @@ acceptance("Poll quote", {
|
|||
primary_group_name: null,
|
||||
primary_group_flair_url: null,
|
||||
primary_group_flair_color: null,
|
||||
primary_group_flair_bg_color: null
|
||||
}
|
||||
primary_group_flair_bg_color: null,
|
||||
},
|
||||
],
|
||||
created_by: {
|
||||
id: 1,
|
||||
username: "bianca",
|
||||
name: null,
|
||||
avatar_template:
|
||||
"/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png"
|
||||
"/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png",
|
||||
},
|
||||
last_poster: {
|
||||
id: 1,
|
||||
username: "bianca",
|
||||
name: null,
|
||||
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 click(".quote-controls");
|
||||
assert.equal(find(".poll").length, 2);
|
||||
|
|
|
@ -6,10 +6,10 @@ acceptance("Rendering polls with bar charts - desktop", {
|
|||
settings: { poll_enabled: true },
|
||||
beforeEach() {
|
||||
clearPopupMenuOptionsCallback();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
test("Polls", async assert => {
|
||||
test("Polls", async (assert) => {
|
||||
await visit("/t/-/15");
|
||||
|
||||
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");
|
||||
|
||||
const polls = find(".poll");
|
||||
|
@ -52,10 +52,10 @@ test("Public poll", async assert => {
|
|||
id: 777,
|
||||
username: "bruce777",
|
||||
avatar_template: "/images/avatar.png",
|
||||
name: "Bruce Wayne"
|
||||
}
|
||||
]
|
||||
}
|
||||
name: "Bruce Wayne",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
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");
|
||||
|
||||
const polls = find(".poll");
|
||||
|
@ -96,8 +96,8 @@ test("Public number poll", async assert => {
|
|||
id: 600 + i,
|
||||
username: `bruce${600 + i}`,
|
||||
avatar_template: "/images/avatar.png",
|
||||
name: "Bruce Wayne"
|
||||
}))
|
||||
name: "Bruce Wayne",
|
||||
})),
|
||||
};
|
||||
|
||||
return [200, { "Content-Type": "application/json" }, body];
|
||||
|
|
|
@ -7,10 +7,10 @@ acceptance("Rendering polls with bar charts - mobile", {
|
|||
settings: { poll_enabled: true },
|
||||
beforeEach() {
|
||||
clearPopupMenuOptionsCallback();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
test("Public number poll", async assert => {
|
||||
test("Public number poll", async (assert) => {
|
||||
await visit("/t/-/13");
|
||||
|
||||
const polls = find(".poll");
|
||||
|
@ -36,8 +36,8 @@ test("Public number poll", async assert => {
|
|||
id: 500 + i,
|
||||
username: `bruce${500 + i}`,
|
||||
avatar_template: "/images/avatar.png",
|
||||
name: "Bruce Wayne"
|
||||
}))
|
||||
name: "Bruce Wayne",
|
||||
})),
|
||||
};
|
||||
|
||||
return [200, { "Content-Type": "application/json" }, body];
|
||||
|
|
|
@ -3,18 +3,18 @@ import { controllerModule } from "helpers/qunit-helpers";
|
|||
controllerModule("controller:poll-ui-builder", {
|
||||
setupController(controller) {
|
||||
controller.set("toolbarEvent", {
|
||||
getText: () => ""
|
||||
getText: () => "",
|
||||
});
|
||||
},
|
||||
needs: ["controller:modal"]
|
||||
needs: ["controller:modal"],
|
||||
});
|
||||
|
||||
test("isMultiple", function(assert) {
|
||||
test("isMultiple", function (assert) {
|
||||
const controller = this.subject();
|
||||
|
||||
controller.setProperties({
|
||||
pollType: controller.multiplePollType,
|
||||
pollOptions: "a"
|
||||
pollOptions: "a",
|
||||
});
|
||||
|
||||
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");
|
||||
});
|
||||
|
||||
test("isNumber", function(assert) {
|
||||
test("isNumber", function (assert) {
|
||||
const controller = this.subject();
|
||||
|
||||
controller.set("pollType", controller.regularPollType);
|
||||
|
@ -40,7 +40,7 @@ test("isNumber", function(assert) {
|
|||
assert.equal(controller.isNumber, true, "it should be true");
|
||||
});
|
||||
|
||||
test("showMinMax", function(assert) {
|
||||
test("showMinMax", function (assert) {
|
||||
const controller = this.subject();
|
||||
|
||||
controller.set("pollType", controller.numberPollType);
|
||||
|
@ -53,7 +53,7 @@ test("showMinMax", function(assert) {
|
|||
assert.equal(controller.showMinMax, false, "it should be false");
|
||||
});
|
||||
|
||||
test("pollOptionsCount", function(assert) {
|
||||
test("pollOptionsCount", function (assert) {
|
||||
const controller = this.subject();
|
||||
|
||||
controller.set("pollOptions", "1\n2\n");
|
||||
|
@ -65,12 +65,12 @@ test("pollOptionsCount", function(assert) {
|
|||
assert.equal(controller.pollOptionsCount, 0, "it should equal 0");
|
||||
});
|
||||
|
||||
test("pollMinOptions", function(assert) {
|
||||
test("pollMinOptions", function (assert) {
|
||||
const controller = this.subject();
|
||||
|
||||
controller.setProperties({
|
||||
pollType: controller.multiplePollType,
|
||||
pollOptions: "z"
|
||||
pollOptions: "z",
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
|
@ -85,7 +85,7 @@ test("pollMinOptions", function(assert) {
|
|||
controller.pollMinOptions,
|
||||
[
|
||||
{ name: 1, value: 1 },
|
||||
{ name: 2, value: 2 }
|
||||
{ name: 2, value: 2 },
|
||||
],
|
||||
"it should return the right options"
|
||||
);
|
||||
|
@ -97,19 +97,19 @@ test("pollMinOptions", function(assert) {
|
|||
controller.pollMinOptions,
|
||||
[
|
||||
{ name: 1, value: 1 },
|
||||
{ name: 2, value: 2 }
|
||||
{ name: 2, value: 2 },
|
||||
],
|
||||
"it should return the right options"
|
||||
);
|
||||
});
|
||||
|
||||
test("pollMaxOptions", function(assert) {
|
||||
test("pollMaxOptions", function (assert) {
|
||||
const controller = this.subject();
|
||||
|
||||
controller.setProperties({
|
||||
pollType: controller.multiplePollType,
|
||||
pollOptions: "y",
|
||||
pollMin: 1
|
||||
pollMin: 1,
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
|
@ -130,7 +130,7 @@ test("pollMaxOptions", function(assert) {
|
|||
controller.setProperties({
|
||||
pollType: controller.get("numberPollType"),
|
||||
pollStep: 2,
|
||||
pollMin: 1
|
||||
pollMin: 1,
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
|
@ -140,13 +140,13 @@ test("pollMaxOptions", function(assert) {
|
|||
{ name: 3, value: 3 },
|
||||
{ name: 4, value: 4 },
|
||||
{ name: 5, value: 5 },
|
||||
{ name: 6, value: 6 }
|
||||
{ name: 6, value: 6 },
|
||||
],
|
||||
"it should return the right options"
|
||||
);
|
||||
});
|
||||
|
||||
test("pollStepOptions", function(assert) {
|
||||
test("pollStepOptions", function (assert) {
|
||||
const controller = this.subject();
|
||||
controller.siteSettings.poll_maximum_options = 3;
|
||||
|
||||
|
@ -159,13 +159,13 @@ test("pollStepOptions", function(assert) {
|
|||
[
|
||||
{ name: 1, value: 1 },
|
||||
{ name: 2, value: 2 },
|
||||
{ name: 3, value: 3 }
|
||||
{ name: 3, value: 3 },
|
||||
],
|
||||
"it should return the right options"
|
||||
);
|
||||
});
|
||||
|
||||
test("disableInsert", function(assert) {
|
||||
test("disableInsert", function (assert) {
|
||||
const controller = this.subject();
|
||||
|
||||
assert.equal(controller.disableInsert, true, "it should be true");
|
||||
|
@ -180,33 +180,33 @@ test("disableInsert", function(assert) {
|
|||
|
||||
controller.setProperties({
|
||||
pollType: controller.regularPollType,
|
||||
pollOptions: "a\nb\nc"
|
||||
pollOptions: "a\nb\nc",
|
||||
});
|
||||
|
||||
assert.equal(controller.disableInsert, false, "it should be false");
|
||||
|
||||
controller.setProperties({
|
||||
pollType: controller.regularPollType,
|
||||
pollOptions: ""
|
||||
pollOptions: "",
|
||||
});
|
||||
|
||||
assert.equal(controller.disableInsert, true, "it should be true");
|
||||
|
||||
controller.setProperties({
|
||||
pollType: controller.regularPollType,
|
||||
pollOptions: "w"
|
||||
pollOptions: "w",
|
||||
});
|
||||
|
||||
assert.equal(controller.disableInsert, false, "it should be false");
|
||||
});
|
||||
|
||||
test("number pollOutput", function(assert) {
|
||||
test("number pollOutput", function (assert) {
|
||||
const controller = this.subject();
|
||||
controller.siteSettings.poll_maximum_options = 20;
|
||||
|
||||
controller.setProperties({
|
||||
pollType: controller.numberPollType,
|
||||
pollMin: 1
|
||||
pollMin: 1,
|
||||
});
|
||||
|
||||
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();
|
||||
controller.siteSettings.poll_maximum_options = 20;
|
||||
|
||||
controller.set("pollOptions", "1\n2");
|
||||
controller.setProperties({
|
||||
pollOptions: "1\n2",
|
||||
pollType: controller.regularPollType
|
||||
pollType: controller.regularPollType,
|
||||
});
|
||||
|
||||
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();
|
||||
controller.siteSettings.poll_maximum_options = 20;
|
||||
|
||||
controller.setProperties({
|
||||
pollType: controller.multiplePollType,
|
||||
pollMin: 1,
|
||||
pollOptions: "\n\n1\n\n2"
|
||||
pollOptions: "\n\n1\n\n2",
|
||||
});
|
||||
|
||||
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();
|
||||
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();
|
||||
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();
|
||||
controller.currentUser = { staff: true };
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ widgetTest("single, not selected", {
|
|||
|
||||
test(assert) {
|
||||
assert.ok(find("li .d-icon-far-circle:eq(0)").length === 1);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
widgetTest("single, selected", {
|
||||
|
@ -28,7 +28,7 @@ widgetTest("single, selected", {
|
|||
|
||||
test(assert) {
|
||||
assert.ok(find("li .d-icon-circle:eq(0)").length === 1);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
widgetTest("multi, not selected", {
|
||||
|
@ -38,13 +38,13 @@ widgetTest("multi, not selected", {
|
|||
this.setProperties({
|
||||
option: { id: "opt-id" },
|
||||
isMultiple: true,
|
||||
vote: []
|
||||
vote: [],
|
||||
});
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(find("li .d-icon-far-square:eq(0)").length === 1);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
widgetTest("multi, selected", {
|
||||
|
@ -54,11 +54,11 @@ widgetTest("multi, selected", {
|
|||
this.setProperties({
|
||||
option: { id: "opt-id" },
|
||||
isMultiple: true,
|
||||
vote: ["opt-id"]
|
||||
vote: ["opt-id"],
|
||||
});
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(find("li .d-icon-far-check-square:eq(0)").length === 1);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -15,7 +15,7 @@ widgetTest("options in descending order", {
|
|||
"poll",
|
||||
EmberObject.create({
|
||||
options: [{ votes: 5 }, { votes: 4 }],
|
||||
voters: 9
|
||||
voters: 9,
|
||||
})
|
||||
);
|
||||
},
|
||||
|
@ -23,7 +23,7 @@ widgetTest("options in descending order", {
|
|||
test(assert) {
|
||||
assert.equal(find(".option .percentage:eq(0)").text(), "56%");
|
||||
assert.equal(find(".option .percentage:eq(1)").text(), "44%");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
widgetTest("options in ascending order", {
|
||||
|
@ -34,7 +34,7 @@ widgetTest("options in ascending order", {
|
|||
"poll",
|
||||
EmberObject.create({
|
||||
options: [{ votes: 4 }, { votes: 5 }],
|
||||
voters: 9
|
||||
voters: 9,
|
||||
})
|
||||
);
|
||||
},
|
||||
|
@ -42,7 +42,7 @@ widgetTest("options in ascending order", {
|
|||
test(assert) {
|
||||
assert.equal(find(".option .percentage:eq(0)").text(), "56%");
|
||||
assert.equal(find(".option .percentage:eq(1)").text(), "44%");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
widgetTest("multiple options in descending order", {
|
||||
|
@ -59,9 +59,9 @@ widgetTest("multiple options in descending order", {
|
|||
{ votes: 2, html: "b" },
|
||||
{ votes: 4, html: "c" },
|
||||
{ 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 .percentage:eq(4)").text(), "8%");
|
||||
assert.equal(find(".option span:nth-child(2):eq(4)").text(), "b");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import I18n from "I18n";
|
||||
import EmberObject from "@ember/object";
|
||||
import { moduleForWidget, widgetTest } from "helpers/widget-test";
|
||||
|
||||
|
@ -19,8 +20,8 @@ widgetTest("can vote", {
|
|||
post: EmberObject.create({
|
||||
id: 42,
|
||||
topic: {
|
||||
archived: false
|
||||
}
|
||||
archived: false,
|
||||
},
|
||||
}),
|
||||
poll: EmberObject.create({
|
||||
name: "poll",
|
||||
|
@ -29,13 +30,13 @@ widgetTest("can vote", {
|
|||
results: "always",
|
||||
options: [
|
||||
{ id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 0 },
|
||||
{ id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 }
|
||||
{ id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 },
|
||||
],
|
||||
voters: 0,
|
||||
chart_type: "bar"
|
||||
chart_type: "bar",
|
||||
}),
|
||||
vote: [],
|
||||
groupableUserFields: []
|
||||
groupableUserFields: [],
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -56,13 +57,13 @@ widgetTest("can vote", {
|
|||
results: "always",
|
||||
options: [
|
||||
{ id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 1 },
|
||||
{ id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 }
|
||||
{ id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 },
|
||||
],
|
||||
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(find(".chosen").length, 1);
|
||||
assert.equal(find(".chosen").text(), "100%yes");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
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({
|
||||
id: 42,
|
||||
topic: {
|
||||
archived: false
|
||||
}
|
||||
archived: false,
|
||||
},
|
||||
}),
|
||||
poll: EmberObject.create({
|
||||
name: "poll",
|
||||
|
@ -91,14 +92,14 @@ widgetTest("cannot vote if not member of the right group", {
|
|||
results: "always",
|
||||
options: [
|
||||
{ id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 0 },
|
||||
{ id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 }
|
||||
{ id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 },
|
||||
],
|
||||
voters: 0,
|
||||
chart_type: "bar",
|
||||
groups: "foo"
|
||||
groups: "foo",
|
||||
}),
|
||||
vote: [],
|
||||
groupableUserFields: []
|
||||
groupableUserFields: [],
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -119,14 +120,14 @@ widgetTest("cannot vote if not member of the right group", {
|
|||
results: "always",
|
||||
options: [
|
||||
{ id: "1f972d1df351de3ce35a787c89faad29", html: "yes", votes: 1 },
|
||||
{ id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 }
|
||||
{ id: "d7ebc3a9beea2e680815a1e4f57d6db6", html: "no", votes: 0 },
|
||||
],
|
||||
voters: 1,
|
||||
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(find(".chosen").length, 0);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user