This repository was archived by the owner on Jul 14, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathlist-queries-test.js
More file actions
74 lines (64 loc) · 2.46 KB
/
list-queries-test.js
File metadata and controls
74 lines (64 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { i18n } from "discourse-i18n";
acceptance("Data Explorer Plugin | List Queries", function (needs) {
needs.user();
needs.settings({ data_explorer_enabled: true });
needs.pretender((server, helper) => {
server.get("/admin/plugins/explorer/groups.json", () => {
return helper.response([]);
});
server.get("/admin/plugins/explorer/queries", () => {
return helper.response({
queries: [
{
id: -5,
name: "Top 100 Active Topics",
description:
"based on the number of replies, it accepts a ‘months_ago’ parameter, defaults to 1 to give results for the last calendar month.",
username: "system",
group_ids: [],
last_run_at: "2021-02-08T15:37:49.188Z",
user_id: -1,
},
{
id: -6,
name: "Top 100 Likers",
description:
"returns the top 100 likers for a given monthly period ordered by like_count. It accepts a ‘months_ago’ parameter, defaults to 1 to give results for the last calendar month.",
username: "system",
group_ids: [],
last_run_at: "2021-02-11T08:29:59.337Z",
user_id: -1,
},
],
});
});
});
test("renders the page with the list of queries", async function (assert) {
await visit("/admin/plugins/explorer");
assert
.dom("div.query-list input.ember-text-field")
.hasAttribute(
"placeholder",
i18n("explorer.search_placeholder"),
"the search box was rendered"
);
assert
.dom("div.query-list button.btn-icon svg.d-icon-plus")
.exists("the add query button was rendered");
assert
.dom("div.query-list button.btn-icon-text span.d-button-label")
.hasText(i18n("explorer.import.label"), "the import button was rendered");
assert
.dom("div.container table.recent-queries tbody tr")
.exists({ count: 2 }, "the list of queries was rendered");
assert
.dom("div.container table.recent-queries tbody tr:nth-child(1) td a")
.hasText(/^\s*Top 100 Likers/, "The first query was rendered");
assert
.dom("div.container table.recent-queries tbody tr:nth-child(2) td a")
.hasText(/^\s*Top 100 Active Topics/, "The second query was rendered");
});
});