missing prettified files
This commit is contained in:
@@ -13,32 +13,41 @@ acceptance("Poll Builder - polls are disabled", {
|
||||
}
|
||||
});
|
||||
|
||||
test("regular user - sufficient trust level", (assert) => {
|
||||
test("regular user - sufficient trust level", assert => {
|
||||
replaceCurrentUser({ staff: false, trust_level: 3 });
|
||||
|
||||
displayPollBuilderButton();
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(!exists(".select-kit-row[title='Build Poll']"), "it hides the builder button");
|
||||
assert.ok(
|
||||
!exists(".select-kit-row[title='Build Poll']"),
|
||||
"it hides the builder button"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test("regular user - insufficient trust level", (assert) => {
|
||||
test("regular user - insufficient trust level", assert => {
|
||||
replaceCurrentUser({ staff: false, trust_level: 1 });
|
||||
|
||||
displayPollBuilderButton();
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(!exists(".select-kit-row[title='Build Poll']"), "it hides the builder button");
|
||||
assert.ok(
|
||||
!exists(".select-kit-row[title='Build Poll']"),
|
||||
"it hides the builder button"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test("staff", (assert) => {
|
||||
test("staff", assert => {
|
||||
replaceCurrentUser({ staff: true });
|
||||
|
||||
displayPollBuilderButton();
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(!exists(".select-kit-row[title='Build Poll']"), "it hides the builder button");
|
||||
assert.ok(
|
||||
!exists(".select-kit-row[title='Build Poll']"),
|
||||
"it hides the builder button"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,32 +13,41 @@ acceptance("Poll Builder - polls are enabled", {
|
||||
}
|
||||
});
|
||||
|
||||
test("regular user - sufficient trust level", (assert) => {
|
||||
test("regular user - sufficient trust level", assert => {
|
||||
replaceCurrentUser({ staff: false, trust_level: 1 });
|
||||
|
||||
displayPollBuilderButton();
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists(".select-kit-row[title='Build Poll']"), "it shows the builder button");
|
||||
assert.ok(
|
||||
exists(".select-kit-row[title='Build Poll']"),
|
||||
"it shows the builder button"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test("regular user - insufficient trust level", (assert) => {
|
||||
test("regular user - insufficient trust level", assert => {
|
||||
replaceCurrentUser({ staff: false, trust_level: 0 });
|
||||
|
||||
displayPollBuilderButton();
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(!exists(".select-kit-row[title='Build Poll']"), "it hides the builder button");
|
||||
assert.ok(
|
||||
!exists(".select-kit-row[title='Build Poll']"),
|
||||
"it hides the builder button"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test("staff - with insufficient trust level", (assert) => {
|
||||
test("staff - with insufficient trust level", assert => {
|
||||
replaceCurrentUser({ staff: true, trust_level: 0 });
|
||||
|
||||
displayPollBuilderButton();
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists(".select-kit-row[title='Build Poll']"), "it shows the builder button");
|
||||
assert.ok(
|
||||
exists(".select-kit-row[title='Build Poll']"),
|
||||
"it shows the builder button"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,13 +1,13 @@
|
||||
import { mapRoutes } from 'discourse/mapping-router';
|
||||
import { mapRoutes } from "discourse/mapping-router";
|
||||
|
||||
moduleFor("controller:poll-ui-builder", "controller:poll-ui-builder", {
|
||||
setup() {
|
||||
this.registry.register('router:main', mapRoutes());
|
||||
this.subject().set('toolbarEvent', {
|
||||
this.registry.register("router:main", mapRoutes());
|
||||
this.subject().set("toolbarEvent", {
|
||||
getText: () => ""
|
||||
});
|
||||
},
|
||||
needs: ['controller:modal']
|
||||
needs: ["controller:modal"]
|
||||
});
|
||||
|
||||
test("isMultiple", function(assert) {
|
||||
@@ -91,46 +91,73 @@ test("pollMinOptions", function(assert) {
|
||||
pollOptionsCount: 1
|
||||
});
|
||||
|
||||
assert.deepEqual(controller.get("pollMinOptions"), [{ name: 1, value: 1 }], "it should return the right options");
|
||||
assert.deepEqual(
|
||||
controller.get("pollMinOptions"),
|
||||
[{ name: 1, value: 1 }],
|
||||
"it should return the right options"
|
||||
);
|
||||
|
||||
controller.set("pollOptionsCount", 2);
|
||||
|
||||
assert.deepEqual(controller.get("pollMinOptions"), [
|
||||
{ name: 1, value: 1 }, { name: 2, value: 2 }
|
||||
], "it should return the right options");
|
||||
assert.deepEqual(
|
||||
controller.get("pollMinOptions"),
|
||||
[{ name: 1, value: 1 }, { name: 2, value: 2 }],
|
||||
"it should return the right options"
|
||||
);
|
||||
|
||||
controller.set("isNumber", true);
|
||||
controller.siteSettings.poll_maximum_options = 2;
|
||||
|
||||
assert.deepEqual(controller.get("pollMinOptions"), [
|
||||
{ name: 1, value: 1 }, { name: 2, value: 2 }
|
||||
], "it should return the right options");
|
||||
assert.deepEqual(
|
||||
controller.get("pollMinOptions"),
|
||||
[{ name: 1, value: 1 }, { name: 2, value: 2 }],
|
||||
"it should return the right options"
|
||||
);
|
||||
});
|
||||
|
||||
test("pollMaxOptions", function(assert) {
|
||||
const controller = this.subject();
|
||||
controller.siteSettings = Discourse.SiteSettings;
|
||||
|
||||
controller.setProperties({ isMultiple: true, pollOptionsCount: 1, pollMin: 1 });
|
||||
controller.setProperties({
|
||||
isMultiple: true,
|
||||
pollOptionsCount: 1,
|
||||
pollMin: 1
|
||||
});
|
||||
|
||||
assert.deepEqual(controller.get("pollMaxOptions"), [], "it should return the right options");
|
||||
assert.deepEqual(
|
||||
controller.get("pollMaxOptions"),
|
||||
[],
|
||||
"it should return the right options"
|
||||
);
|
||||
|
||||
controller.set("pollOptionsCount", 2);
|
||||
|
||||
assert.deepEqual(controller.get("pollMaxOptions"), [
|
||||
{ name: 2, value: 2 }
|
||||
], "it should return the right options");
|
||||
assert.deepEqual(
|
||||
controller.get("pollMaxOptions"),
|
||||
[{ name: 2, value: 2 }],
|
||||
"it should return the right options"
|
||||
);
|
||||
|
||||
controller.siteSettings.poll_maximum_options = 3;
|
||||
controller.setProperties({ isMultiple: false, isNumber: true, pollStep: 2, pollMin: 1 });
|
||||
controller.setProperties({
|
||||
isMultiple: false,
|
||||
isNumber: true,
|
||||
pollStep: 2,
|
||||
pollMin: 1
|
||||
});
|
||||
|
||||
assert.deepEqual(controller.get("pollMaxOptions"), [
|
||||
{ name: 2, value: 2 },
|
||||
{ name: 3, value: 3 },
|
||||
{ name: 4, value: 4 },
|
||||
{ name: 5, value: 5 },
|
||||
{ name: 6, value: 6 }
|
||||
], "it should return the right options");
|
||||
assert.deepEqual(
|
||||
controller.get("pollMaxOptions"),
|
||||
[
|
||||
{ name: 2, value: 2 },
|
||||
{ name: 3, value: 3 },
|
||||
{ name: 4, value: 4 },
|
||||
{ name: 5, value: 5 },
|
||||
{ name: 6, value: 6 }
|
||||
],
|
||||
"it should return the right options"
|
||||
);
|
||||
});
|
||||
|
||||
test("pollStepOptions", function(assert) {
|
||||
@@ -140,15 +167,19 @@ test("pollStepOptions", function(assert) {
|
||||
|
||||
controller.set("isNumber", false);
|
||||
|
||||
assert.equal(controller.get("pollStepOptions"), null, "is should return null");
|
||||
assert.equal(
|
||||
controller.get("pollStepOptions"),
|
||||
null,
|
||||
"is should return null"
|
||||
);
|
||||
|
||||
controller.setProperties({ isNumber: true });
|
||||
|
||||
assert.deepEqual(controller.get("pollStepOptions"), [
|
||||
{ name: 1, value: 1 },
|
||||
{ name: 2, value: 2 },
|
||||
{ name: 3, value: 3 }
|
||||
], "it should return the right options");
|
||||
assert.deepEqual(
|
||||
controller.get("pollStepOptions"),
|
||||
[{ name: 1, value: 1 }, { name: 2, value: 2 }, { name: 3, value: 3 }],
|
||||
"it should return the right options"
|
||||
);
|
||||
});
|
||||
|
||||
test("disableInsert", function(assert) {
|
||||
@@ -187,19 +218,35 @@ test("number pollOutput", function(assert) {
|
||||
pollMin: 1
|
||||
});
|
||||
|
||||
assert.equal(controller.get("pollOutput"), "[poll type=number min=1 max=20 step=1]\n[/poll]", "it should return the right output");
|
||||
assert.equal(
|
||||
controller.get("pollOutput"),
|
||||
"[poll type=number min=1 max=20 step=1]\n[/poll]",
|
||||
"it should return the right output"
|
||||
);
|
||||
|
||||
controller.set("pollStep", 2);
|
||||
|
||||
assert.equal(controller.get("pollOutput"), "[poll type=number min=1 max=20 step=2]\n[/poll]", "it should return the right output");
|
||||
assert.equal(
|
||||
controller.get("pollOutput"),
|
||||
"[poll type=number min=1 max=20 step=2]\n[/poll]",
|
||||
"it should return the right output"
|
||||
);
|
||||
|
||||
controller.set("publicPoll", true);
|
||||
|
||||
assert.equal(controller.get("pollOutput"), "[poll type=number min=1 max=20 step=2 public=true]\n[/poll]", "it should return the right output");
|
||||
assert.equal(
|
||||
controller.get("pollOutput"),
|
||||
"[poll type=number min=1 max=20 step=2 public=true]\n[/poll]",
|
||||
"it should return the right output"
|
||||
);
|
||||
|
||||
controller.set("pollStep", 0);
|
||||
|
||||
assert.equal(controller.get("pollOutput"), "[poll type=number min=1 max=20 step=1 public=true]\n[/poll]", "it should return the right output");
|
||||
assert.equal(
|
||||
controller.get("pollOutput"),
|
||||
"[poll type=number min=1 max=20 step=1 public=true]\n[/poll]",
|
||||
"it should return the right output"
|
||||
);
|
||||
});
|
||||
|
||||
test("regular pollOutput", function(assert) {
|
||||
@@ -213,14 +260,21 @@ test("regular pollOutput", function(assert) {
|
||||
pollType: controller.get("regularPollType")
|
||||
});
|
||||
|
||||
assert.equal(controller.get("pollOutput"), "[poll type=regular]\n* 1\n* 2\n[/poll]", "it should return the right output");
|
||||
assert.equal(
|
||||
controller.get("pollOutput"),
|
||||
"[poll type=regular]\n* 1\n* 2\n[/poll]",
|
||||
"it should return the right output"
|
||||
);
|
||||
|
||||
controller.set("publicPoll", "true");
|
||||
|
||||
assert.equal(controller.get("pollOutput"), "[poll type=regular public=true]\n* 1\n* 2\n[/poll]", "it should return the right output");
|
||||
assert.equal(
|
||||
controller.get("pollOutput"),
|
||||
"[poll type=regular public=true]\n* 1\n* 2\n[/poll]",
|
||||
"it should return the right output"
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
test("multiple pollOutput", function(assert) {
|
||||
const controller = this.subject();
|
||||
controller.siteSettings = Discourse.SiteSettings;
|
||||
@@ -233,9 +287,17 @@ test("multiple pollOutput", function(assert) {
|
||||
pollOptions: "\n\n1\n\n2"
|
||||
});
|
||||
|
||||
assert.equal(controller.get("pollOutput"), "[poll type=multiple min=1 max=2]\n* 1\n* 2\n[/poll]", "it should return the right output");
|
||||
assert.equal(
|
||||
controller.get("pollOutput"),
|
||||
"[poll type=multiple min=1 max=2]\n* 1\n* 2\n[/poll]",
|
||||
"it should return the right output"
|
||||
);
|
||||
|
||||
controller.set("publicPoll", "true");
|
||||
|
||||
assert.equal(controller.get("pollOutput"), "[poll type=multiple min=1 max=2 public=true]\n* 1\n* 2\n[/poll]", "it should return the right output");
|
||||
assert.equal(
|
||||
controller.get("pollOutput"),
|
||||
"[poll type=multiple min=1 max=2 public=true]\n* 1\n* 2\n[/poll]",
|
||||
"it should return the right output"
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,64 +1,64 @@
|
||||
import { moduleForWidget, widgetTest } from 'helpers/widget-test';
|
||||
moduleForWidget('discourse-poll-option');
|
||||
import { moduleForWidget, widgetTest } from "helpers/widget-test";
|
||||
moduleForWidget("discourse-poll-option");
|
||||
|
||||
const template = `{{mount-widget
|
||||
widget="discourse-poll-option"
|
||||
args=(hash option=option isMultiple=isMultiple vote=vote)}}`;
|
||||
|
||||
widgetTest('single, not selected', {
|
||||
widgetTest("single, not selected", {
|
||||
template,
|
||||
|
||||
beforeEach() {
|
||||
this.set('option', { id: 'opt-id' });
|
||||
this.set('vote', []);
|
||||
this.set("option", { id: "opt-id" });
|
||||
this.set("vote", []);
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(find('li .d-icon-circle-o:eq(0)').length === 1);
|
||||
assert.ok(find("li .d-icon-circle-o:eq(0)").length === 1);
|
||||
}
|
||||
});
|
||||
|
||||
widgetTest('single, selected', {
|
||||
widgetTest("single, selected", {
|
||||
template,
|
||||
|
||||
beforeEach() {
|
||||
this.set('option', { id: 'opt-id' });
|
||||
this.set('vote', ['opt-id']);
|
||||
this.set("option", { id: "opt-id" });
|
||||
this.set("vote", ["opt-id"]);
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(find('li .d-icon-dot-circle-o:eq(0)').length === 1);
|
||||
assert.ok(find("li .d-icon-dot-circle-o:eq(0)").length === 1);
|
||||
}
|
||||
});
|
||||
|
||||
widgetTest('multi, not selected', {
|
||||
widgetTest("multi, not selected", {
|
||||
template,
|
||||
|
||||
beforeEach() {
|
||||
this.setProperties({
|
||||
option: { id: 'opt-id' },
|
||||
option: { id: "opt-id" },
|
||||
isMultiple: true,
|
||||
vote: []
|
||||
});
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(find('li .d-icon-square-o:eq(0)').length === 1);
|
||||
assert.ok(find("li .d-icon-square-o:eq(0)").length === 1);
|
||||
}
|
||||
});
|
||||
|
||||
widgetTest('multi, selected', {
|
||||
widgetTest("multi, selected", {
|
||||
template,
|
||||
|
||||
beforeEach() {
|
||||
this.setProperties({
|
||||
option: { id: 'opt-id' },
|
||||
option: { id: "opt-id" },
|
||||
isMultiple: true,
|
||||
vote: ['opt-id']
|
||||
vote: ["opt-id"]
|
||||
});
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(find('li .d-icon-check-square-o:eq(0)').length === 1);
|
||||
assert.ok(find("li .d-icon-check-square-o:eq(0)").length === 1);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,67 +1,76 @@
|
||||
import { moduleForWidget, widgetTest } from 'helpers/widget-test';
|
||||
moduleForWidget('discourse-poll-standard-results');
|
||||
import { moduleForWidget, widgetTest } from "helpers/widget-test";
|
||||
moduleForWidget("discourse-poll-standard-results");
|
||||
|
||||
const template = `{{mount-widget
|
||||
widget="discourse-poll-standard-results"
|
||||
args=(hash poll=poll isMultiple=isMultiple)}}`;
|
||||
|
||||
widgetTest('options in descending order', {
|
||||
widgetTest("options in descending order", {
|
||||
template,
|
||||
|
||||
beforeEach() {
|
||||
this.set('poll', Ember.Object.create({
|
||||
options: [{ votes: 5 }, { votes: 4 }],
|
||||
voters: 9
|
||||
}));
|
||||
this.set(
|
||||
"poll",
|
||||
Ember.Object.create({
|
||||
options: [{ votes: 5 }, { votes: 4 }],
|
||||
voters: 9
|
||||
})
|
||||
);
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(this.$('.option .percentage:eq(0)').text(), '56%');
|
||||
assert.equal(this.$('.option .percentage:eq(1)').text(), '44%');
|
||||
assert.equal(this.$(".option .percentage:eq(0)").text(), "56%");
|
||||
assert.equal(this.$(".option .percentage:eq(1)").text(), "44%");
|
||||
}
|
||||
});
|
||||
|
||||
widgetTest('options in ascending order', {
|
||||
widgetTest("options in ascending order", {
|
||||
template,
|
||||
|
||||
beforeEach() {
|
||||
this.set('poll', Ember.Object.create({
|
||||
options: [{ votes: 4 }, { votes: 5 }],
|
||||
voters: 9
|
||||
}));
|
||||
this.set(
|
||||
"poll",
|
||||
Ember.Object.create({
|
||||
options: [{ votes: 4 }, { votes: 5 }],
|
||||
voters: 9
|
||||
})
|
||||
);
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(this.$('.option .percentage:eq(0)').text(), '56%');
|
||||
assert.equal(this.$('.option .percentage:eq(1)').text(), '44%');
|
||||
assert.equal(this.$(".option .percentage:eq(0)").text(), "56%");
|
||||
assert.equal(this.$(".option .percentage:eq(1)").text(), "44%");
|
||||
}
|
||||
});
|
||||
|
||||
widgetTest('multiple options in descending order', {
|
||||
widgetTest("multiple options in descending order", {
|
||||
template,
|
||||
|
||||
beforeEach() {
|
||||
this.set('isMultiple', true);
|
||||
this.set('poll', Ember.Object.create({
|
||||
type: 'multiple',
|
||||
options: [
|
||||
{ votes: 5, html: 'a' },
|
||||
{ votes: 2, html: 'b' },
|
||||
{ votes: 4, html: 'c' },
|
||||
{ votes: 1, html: 'b' },
|
||||
{ votes: 1, html: 'a' }
|
||||
],
|
||||
voters: 12
|
||||
}));
|
||||
this.set("isMultiple", true);
|
||||
this.set(
|
||||
"poll",
|
||||
Ember.Object.create({
|
||||
type: "multiple",
|
||||
options: [
|
||||
{ votes: 5, html: "a" },
|
||||
{ votes: 2, html: "b" },
|
||||
{ votes: 4, html: "c" },
|
||||
{ votes: 1, html: "b" },
|
||||
{ votes: 1, html: "a" }
|
||||
],
|
||||
voters: 12
|
||||
})
|
||||
);
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(this.$('.option .percentage:eq(0)').text(), '41%');
|
||||
assert.equal(this.$('.option .percentage:eq(1)').text(), '33%');
|
||||
assert.equal(this.$('.option .percentage:eq(2)').text(), '16%');
|
||||
assert.equal(this.$('.option .percentage:eq(3)').text(), '8%');
|
||||
assert.equal(this.$('.option span:nth-child(2):eq(3)').text(), 'a');
|
||||
assert.equal(this.$('.option .percentage:eq(4)').text(), '8%');
|
||||
assert.equal(this.$('.option span:nth-child(2):eq(4)').text(), 'b');
|
||||
assert.equal(this.$(".option .percentage:eq(0)").text(), "41%");
|
||||
assert.equal(this.$(".option .percentage:eq(1)").text(), "33%");
|
||||
assert.equal(this.$(".option .percentage:eq(2)").text(), "16%");
|
||||
assert.equal(this.$(".option .percentage:eq(3)").text(), "8%");
|
||||
assert.equal(this.$(".option span:nth-child(2):eq(3)").text(), "a");
|
||||
assert.equal(this.$(".option .percentage:eq(4)").text(), "8%");
|
||||
assert.equal(this.$(".option span:nth-child(2):eq(4)").text(), "b");
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user