2018-05-17 16:44:33 -04:00
|
|
|
import Report from "admin/models/report";
|
2015-08-11 12:27:07 -04:00
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.module("Report");
|
2013-06-19 15:06:23 -04:00
|
|
|
|
|
|
|
function reportWithData(data) {
|
2015-11-20 20:27:06 -05:00
|
|
|
return Report.create({
|
2018-05-17 16:44:33 -04:00
|
|
|
type: "topics",
|
2018-11-19 04:46:46 -05:00
|
|
|
data: data.map((val, index) => {
|
2018-06-15 11:03:24 -04:00
|
|
|
return {
|
|
|
|
x: moment()
|
|
|
|
.subtract(index, "days")
|
|
|
|
.format("YYYY-MM-DD"),
|
|
|
|
y: val
|
|
|
|
};
|
2013-06-19 15:06:23 -04:00
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("counts", assert => {
|
2018-05-17 16:44:33 -04:00
|
|
|
const report = reportWithData([5, 4, 3, 2, 1, 100, 99, 98, 1000]);
|
2013-06-19 15:06:23 -04:00
|
|
|
|
2018-05-17 16:44:33 -04:00
|
|
|
assert.equal(report.get("todayCount"), 5);
|
|
|
|
assert.equal(report.get("yesterdayCount"), 4);
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.equal(
|
|
|
|
report.valueFor(2, 4),
|
|
|
|
6,
|
|
|
|
"adds the values for the given range of days, inclusive"
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
report.get("lastSevenDaysCount"),
|
|
|
|
307,
|
|
|
|
"sums 7 days excluding today"
|
|
|
|
);
|
2015-08-04 12:23:56 -04:00
|
|
|
|
|
|
|
report.set("method", "average");
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.equal(
|
|
|
|
report.valueFor(2, 4),
|
|
|
|
2,
|
|
|
|
"averages the values for the given range of days"
|
|
|
|
);
|
2013-06-19 15:06:23 -04:00
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("percentChangeString", assert => {
|
2018-05-17 16:44:33 -04:00
|
|
|
const report = reportWithData([]);
|
2013-06-19 15:06:23 -04:00
|
|
|
|
2018-05-17 16:44:33 -04:00
|
|
|
assert.equal(report.percentChangeString(5, 8), "+60%", "value increased");
|
|
|
|
assert.equal(report.percentChangeString(8, 2), "-75%", "value decreased");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(report.percentChangeString(8, 8), "0%", "value unchanged");
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.blank(
|
|
|
|
report.percentChangeString(0, 8),
|
|
|
|
"returns blank when previous value was 0"
|
|
|
|
);
|
2018-05-17 16:44:33 -04:00
|
|
|
assert.equal(report.percentChangeString(8, 0), "-100%", "yesterday was 0");
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.blank(
|
|
|
|
report.percentChangeString(0, 0),
|
|
|
|
"returns blank when both were 0"
|
|
|
|
);
|
2013-06-19 15:06:23 -04:00
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("yesterdayCountTitle with valid values", assert => {
|
2018-06-15 11:03:24 -04:00
|
|
|
const title = reportWithData([6, 8, 5, 2, 1]).get("yesterdayCountTitle");
|
2018-05-17 16:44:33 -04:00
|
|
|
assert.ok(title.indexOf("+60%") !== -1);
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(title.match(/Was 5/));
|
2013-06-19 15:06:23 -04:00
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("yesterdayCountTitle when two days ago was 0", assert => {
|
2018-06-15 11:03:24 -04:00
|
|
|
const title = reportWithData([6, 8, 0, 2, 1]).get("yesterdayCountTitle");
|
2018-05-17 16:44:33 -04:00
|
|
|
assert.equal(title.indexOf("%"), -1);
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(title.match(/Was 0/));
|
2013-06-19 15:06:23 -04:00
|
|
|
});
|
|
|
|
|
2018-05-17 16:44:33 -04:00
|
|
|
QUnit.test("sevenDaysCountTitle", assert => {
|
2018-06-15 11:03:24 -04:00
|
|
|
const title = reportWithData([
|
|
|
|
100,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
2,
|
|
|
|
2,
|
|
|
|
2,
|
|
|
|
2,
|
|
|
|
2,
|
|
|
|
2,
|
|
|
|
2,
|
|
|
|
100,
|
|
|
|
100
|
|
|
|
]).get("sevenDaysCountTitle");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(title.match(/-50%/));
|
|
|
|
assert.ok(title.match(/Was 14/));
|
2013-06-19 15:06:23 -04:00
|
|
|
});
|
|
|
|
|
2018-05-17 16:44:33 -04:00
|
|
|
QUnit.test("thirtyDaysCountTitle", assert => {
|
2018-06-15 11:03:24 -04:00
|
|
|
const report = reportWithData([5, 5, 5, 5]);
|
2018-05-17 16:44:33 -04:00
|
|
|
report.set("prev30Days", 10);
|
|
|
|
const title = report.get("thirtyDaysCountTitle");
|
2013-06-19 15:06:23 -04:00
|
|
|
|
2018-05-17 16:44:33 -04:00
|
|
|
assert.ok(title.indexOf("+50%") !== -1);
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(title.match(/Was 10/));
|
2018-05-10 23:30:21 -04:00
|
|
|
});
|
2018-05-17 16:44:33 -04:00
|
|
|
|
|
|
|
QUnit.test("sevenDaysTrend", assert => {
|
|
|
|
let report;
|
|
|
|
let trend;
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
report = reportWithData([0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]);
|
2018-05-17 16:44:33 -04:00
|
|
|
trend = report.get("sevenDaysTrend");
|
|
|
|
assert.ok(trend === "no-change");
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
report = reportWithData([0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0]);
|
2018-05-17 16:44:33 -04:00
|
|
|
trend = report.get("sevenDaysTrend");
|
|
|
|
assert.ok(trend === "high-trending-up");
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
report = reportWithData([0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]);
|
2018-05-17 16:44:33 -04:00
|
|
|
trend = report.get("sevenDaysTrend");
|
|
|
|
assert.ok(trend === "trending-up");
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
report = reportWithData([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1]);
|
2018-05-17 16:44:33 -04:00
|
|
|
trend = report.get("sevenDaysTrend");
|
|
|
|
assert.ok(trend === "high-trending-down");
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
report = reportWithData([0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]);
|
2018-05-17 16:44:33 -04:00
|
|
|
trend = report.get("sevenDaysTrend");
|
2018-05-28 04:55:42 -04:00
|
|
|
assert.ok(trend === "trending-down");
|
2018-05-17 16:44:33 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("yesterdayTrend", assert => {
|
|
|
|
let report;
|
|
|
|
let trend;
|
|
|
|
|
|
|
|
report = reportWithData([0, 1, 1]);
|
|
|
|
trend = report.get("yesterdayTrend");
|
|
|
|
assert.ok(trend === "no-change");
|
|
|
|
|
|
|
|
report = reportWithData([0, 1, 0]);
|
|
|
|
trend = report.get("yesterdayTrend");
|
|
|
|
assert.ok(trend === "high-trending-up");
|
|
|
|
|
|
|
|
report = reportWithData([0, 1.1, 1]);
|
|
|
|
trend = report.get("yesterdayTrend");
|
|
|
|
assert.ok(trend === "trending-up");
|
|
|
|
|
|
|
|
report = reportWithData([0, 0, 1]);
|
|
|
|
trend = report.get("yesterdayTrend");
|
|
|
|
assert.ok(trend === "high-trending-down");
|
|
|
|
|
|
|
|
report = reportWithData([0, 1, 1.1]);
|
|
|
|
trend = report.get("yesterdayTrend");
|
2018-05-28 04:55:42 -04:00
|
|
|
assert.ok(trend === "trending-down");
|
2018-05-17 16:44:33 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("thirtyDaysTrend", assert => {
|
|
|
|
let report;
|
|
|
|
let trend;
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
report = reportWithData([
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1
|
|
|
|
]);
|
2018-05-17 16:44:33 -04:00
|
|
|
report.set("prev30Days", 30);
|
|
|
|
trend = report.get("thirtyDaysTrend");
|
|
|
|
assert.ok(trend === "no-change");
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
report = reportWithData([
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1
|
|
|
|
]);
|
2018-05-17 16:44:33 -04:00
|
|
|
report.set("prev30Days", 0);
|
|
|
|
trend = report.get("thirtyDaysTrend");
|
|
|
|
assert.ok(trend === "high-trending-up");
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
report = reportWithData([
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1
|
|
|
|
]);
|
2018-05-17 16:44:33 -04:00
|
|
|
report.set("prev30Days", 25);
|
|
|
|
trend = report.get("thirtyDaysTrend");
|
|
|
|
assert.ok(trend === "trending-up");
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
report = reportWithData([
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0
|
|
|
|
]);
|
2018-05-17 16:44:33 -04:00
|
|
|
report.set("prev30Days", 60);
|
|
|
|
trend = report.get("thirtyDaysTrend");
|
|
|
|
assert.ok(trend === "high-trending-down");
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
report = reportWithData([
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
0
|
|
|
|
]);
|
2018-05-17 16:44:33 -04:00
|
|
|
report.set("prev30Days", 35);
|
|
|
|
trend = report.get("thirtyDaysTrend");
|
2018-05-28 04:55:42 -04:00
|
|
|
assert.ok(trend === "trending-down");
|
2018-05-17 16:44:33 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("higher is better false", assert => {
|
|
|
|
let report;
|
|
|
|
let trend;
|
|
|
|
|
|
|
|
report = reportWithData([0, 1, 0]);
|
|
|
|
report.set("higher_is_better", false);
|
|
|
|
trend = report.get("yesterdayTrend");
|
|
|
|
assert.ok(trend === "high-trending-down");
|
|
|
|
|
|
|
|
report = reportWithData([0, 1.1, 1]);
|
|
|
|
report.set("higher_is_better", false);
|
|
|
|
trend = report.get("yesterdayTrend");
|
|
|
|
assert.ok(trend === "trending-down");
|
|
|
|
|
|
|
|
report = reportWithData([0, 0, 1]);
|
|
|
|
report.set("higher_is_better", false);
|
|
|
|
trend = report.get("yesterdayTrend");
|
|
|
|
assert.ok(trend === "high-trending-up");
|
|
|
|
|
|
|
|
report = reportWithData([0, 1, 1.1]);
|
|
|
|
report.set("higher_is_better", false);
|
|
|
|
trend = report.get("yesterdayTrend");
|
2018-05-28 04:55:42 -04:00
|
|
|
assert.ok(trend === "trending-up");
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("small variation (-2/+2% change) is no-change", assert => {
|
|
|
|
let report;
|
|
|
|
let trend;
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
report = reportWithData([0, 1, 1, 1, 1, 1, 1, 0.9, 1, 1, 1, 1, 1, 1, 1]);
|
2018-05-28 04:55:42 -04:00
|
|
|
trend = report.get("sevenDaysTrend");
|
|
|
|
assert.ok(trend === "no-change");
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
report = reportWithData([0, 1, 1, 1, 1, 1, 1, 1.1, 1, 1, 1, 1, 1, 1, 1]);
|
2018-05-28 04:55:42 -04:00
|
|
|
trend = report.get("sevenDaysTrend");
|
|
|
|
assert.ok(trend === "no-change");
|
2018-05-17 16:44:33 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("average", assert => {
|
|
|
|
let report;
|
|
|
|
|
|
|
|
report = reportWithData([5, 5, 5, 5, 5, 5, 5, 5]);
|
|
|
|
|
|
|
|
report.set("average", true);
|
|
|
|
assert.ok(report.get("lastSevenDaysCount") === 5);
|
|
|
|
|
|
|
|
report.set("average", false);
|
|
|
|
assert.ok(report.get("lastSevenDaysCount") === 35);
|
|
|
|
});
|
2018-07-19 14:33:11 -04:00
|
|
|
|
|
|
|
QUnit.test("computed labels", assert => {
|
|
|
|
const data = [
|
|
|
|
{
|
|
|
|
username: "joffrey",
|
2018-07-31 17:35:13 -04:00
|
|
|
user_id: 1,
|
|
|
|
user_avatar: "/",
|
2018-07-19 14:33:11 -04:00
|
|
|
flag_count: 1876,
|
|
|
|
time_read: 287362,
|
2018-07-31 17:35:13 -04:00
|
|
|
note: "This is a long note",
|
|
|
|
topic_id: 2,
|
|
|
|
topic_title: "Test topic",
|
|
|
|
post_number: 3,
|
|
|
|
post_raw: "This is the beginning of"
|
2018-07-19 14:33:11 -04:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const labels = [
|
|
|
|
{
|
2018-07-31 17:35:13 -04:00
|
|
|
type: "user",
|
|
|
|
properties: {
|
|
|
|
username: "username",
|
|
|
|
id: "user_id",
|
|
|
|
avatar: "user_avatar"
|
|
|
|
},
|
|
|
|
title: "Moderator"
|
2018-07-19 14:33:11 -04:00
|
|
|
},
|
2018-08-01 18:40:59 -04:00
|
|
|
{ type: "number", property: "flag_count", title: "Flag count" },
|
2018-07-31 17:35:13 -04:00
|
|
|
{ type: "seconds", property: "time_read", title: "Time read" },
|
|
|
|
{ type: "text", property: "note", title: "Note" },
|
|
|
|
{
|
|
|
|
type: "topic",
|
|
|
|
properties: {
|
|
|
|
title: "topic_title",
|
|
|
|
id: "topic_id"
|
|
|
|
},
|
|
|
|
title: "Topic"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "post",
|
|
|
|
properties: {
|
|
|
|
topic_id: "topic_id",
|
|
|
|
number: "post_number",
|
|
|
|
truncated_raw: "post_raw"
|
|
|
|
},
|
|
|
|
title: "Post"
|
|
|
|
}
|
2018-07-19 14:33:11 -04:00
|
|
|
];
|
|
|
|
|
|
|
|
const report = Report.create({
|
|
|
|
type: "topics",
|
|
|
|
labels,
|
|
|
|
data
|
|
|
|
});
|
|
|
|
|
|
|
|
const row = report.get("data.0");
|
|
|
|
const computedLabels = report.get("computedLabels");
|
|
|
|
|
|
|
|
const usernameLabel = computedLabels[0];
|
2018-07-31 17:35:13 -04:00
|
|
|
assert.equal(usernameLabel.mainProperty, "username");
|
|
|
|
assert.equal(usernameLabel.sortProperty, "username");
|
|
|
|
assert.equal(usernameLabel.title, "Moderator");
|
2018-08-01 18:40:59 -04:00
|
|
|
assert.equal(usernameLabel.type, "user");
|
2018-07-19 14:33:11 -04:00
|
|
|
const computedUsernameLabel = usernameLabel.compute(row);
|
|
|
|
assert.equal(
|
|
|
|
computedUsernameLabel.formatedValue,
|
2018-07-31 18:57:00 -04:00
|
|
|
"<a href='/admin/users/1/joffrey'><img alt='' width='20' height='20' src='/' class='avatar' title='joffrey'><span class='username'>joffrey</span></a>"
|
2018-07-19 14:33:11 -04:00
|
|
|
);
|
|
|
|
assert.equal(computedUsernameLabel.value, "joffrey");
|
|
|
|
|
|
|
|
const flagCountLabel = computedLabels[1];
|
2018-07-31 17:35:13 -04:00
|
|
|
assert.equal(flagCountLabel.mainProperty, "flag_count");
|
|
|
|
assert.equal(flagCountLabel.sortProperty, "flag_count");
|
2018-07-19 14:33:11 -04:00
|
|
|
assert.equal(flagCountLabel.title, "Flag count");
|
2018-08-01 18:40:59 -04:00
|
|
|
assert.equal(flagCountLabel.type, "number");
|
|
|
|
let computedFlagCountLabel = flagCountLabel.compute(row);
|
2018-07-19 14:33:11 -04:00
|
|
|
assert.equal(computedFlagCountLabel.formatedValue, "1.9k");
|
|
|
|
assert.equal(computedFlagCountLabel.value, 1876);
|
2018-08-01 18:40:59 -04:00
|
|
|
computedFlagCountLabel = flagCountLabel.compute(row, {
|
|
|
|
formatNumbers: false
|
|
|
|
});
|
|
|
|
assert.equal(computedFlagCountLabel.formatedValue, 1876);
|
2018-07-19 14:33:11 -04:00
|
|
|
|
|
|
|
const timeReadLabel = computedLabels[2];
|
2018-07-31 17:35:13 -04:00
|
|
|
assert.equal(timeReadLabel.mainProperty, "time_read");
|
|
|
|
assert.equal(timeReadLabel.sortProperty, "time_read");
|
2018-07-19 14:33:11 -04:00
|
|
|
assert.equal(timeReadLabel.title, "Time read");
|
2018-08-01 18:40:59 -04:00
|
|
|
assert.equal(timeReadLabel.type, "seconds");
|
2018-07-19 14:33:11 -04:00
|
|
|
const computedTimeReadLabel = timeReadLabel.compute(row);
|
|
|
|
assert.equal(computedTimeReadLabel.formatedValue, "3d");
|
|
|
|
assert.equal(computedTimeReadLabel.value, 287362);
|
|
|
|
|
|
|
|
const noteLabel = computedLabels[3];
|
2018-07-31 17:35:13 -04:00
|
|
|
assert.equal(noteLabel.mainProperty, "note");
|
|
|
|
assert.equal(noteLabel.sortProperty, "note");
|
2018-07-19 14:33:11 -04:00
|
|
|
assert.equal(noteLabel.title, "Note");
|
2018-08-01 18:40:59 -04:00
|
|
|
assert.equal(noteLabel.type, "text");
|
2018-07-19 14:33:11 -04:00
|
|
|
const computedNoteLabel = noteLabel.compute(row);
|
|
|
|
assert.equal(computedNoteLabel.formatedValue, "This is a long note");
|
|
|
|
assert.equal(computedNoteLabel.value, "This is a long note");
|
2018-07-31 17:35:13 -04:00
|
|
|
|
|
|
|
const topicLabel = computedLabels[4];
|
|
|
|
assert.equal(topicLabel.mainProperty, "topic_title");
|
|
|
|
assert.equal(topicLabel.sortProperty, "topic_title");
|
|
|
|
assert.equal(topicLabel.title, "Topic");
|
2018-08-01 18:40:59 -04:00
|
|
|
assert.equal(topicLabel.type, "topic");
|
2018-07-31 17:35:13 -04:00
|
|
|
const computedTopicLabel = topicLabel.compute(row);
|
|
|
|
assert.equal(
|
|
|
|
computedTopicLabel.formatedValue,
|
|
|
|
"<a href='/t/-/2'>Test topic</a>"
|
|
|
|
);
|
|
|
|
assert.equal(computedTopicLabel.value, "Test topic");
|
|
|
|
|
|
|
|
const postLabel = computedLabels[5];
|
|
|
|
assert.equal(postLabel.mainProperty, "post_raw");
|
|
|
|
assert.equal(postLabel.sortProperty, "post_raw");
|
|
|
|
assert.equal(postLabel.title, "Post");
|
2018-08-01 18:40:59 -04:00
|
|
|
assert.equal(postLabel.type, "post");
|
2018-07-31 17:35:13 -04:00
|
|
|
const computedPostLabel = postLabel.compute(row);
|
|
|
|
assert.equal(
|
|
|
|
computedPostLabel.formatedValue,
|
|
|
|
"<a href='/t/-/2/3'>This is the beginning of</a>"
|
|
|
|
);
|
|
|
|
assert.equal(computedPostLabel.value, "This is the beginning of");
|
2018-10-26 06:32:02 -04:00
|
|
|
|
|
|
|
// subfolder support
|
|
|
|
Discourse.BaseUri = "/forum";
|
|
|
|
|
|
|
|
const postLink = computedLabels[5].compute(row).formatedValue;
|
|
|
|
assert.equal(
|
|
|
|
postLink,
|
|
|
|
"<a href='/forum/t/-/2/3'>This is the beginning of</a>"
|
|
|
|
);
|
|
|
|
|
|
|
|
const topicLink = computedLabels[4].compute(row).formatedValue;
|
|
|
|
assert.equal(topicLink, "<a href='/forum/t/-/2'>Test topic</a>");
|
|
|
|
|
|
|
|
const userLink = computedLabels[0].compute(row).formatedValue;
|
|
|
|
assert.equal(
|
|
|
|
userLink,
|
|
|
|
"<a href='/forum/admin/users/1/joffrey'><img alt='' width='20' height='20' src='/forum/' class='avatar' title='joffrey'><span class='username'>joffrey</span></a>"
|
|
|
|
);
|
2018-07-19 14:33:11 -04:00
|
|
|
});
|