Skip to content

Commit

Permalink
Merge pull request #285 from paviliondev/ember_5
Browse files Browse the repository at this point in the history
COMPATIBILITY: Support Discourse 3.2
  • Loading branch information
jumagura authored Jan 26, 2024
2 parents 41e240d + f29d172 commit fbb7f4c
Show file tree
Hide file tree
Showing 14 changed files with 126 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@
{{#each wizards as |wizard|}}
<tr data-wizard-id={{dasherize wizard.id}}>
<td>
{{#link-to "adminWizardsWizardShow" (dasherize wizard.id)}}
<LinkTo
@route="adminWizardsWizardShow"
@model={{dasherize wizard.id}}
>
{{wizard.name}}
{{/link-to}}
</LinkTo>
</td>
<td class="control-column">
<Input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@
{{/if}}

{{#if isUser}}
{{#link-to "user" value.username}}
<LinkTo @route="user" @model={{value.username}}>
{{avatar value imageSize="tiny"}}
{{/link-to}}
</LinkTo>
{{/if}}

{{#if showUsername}}
Expand Down
10 changes: 10 additions & 0 deletions assets/stylesheets/common/wizard/wizard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ body.custom-wizard {
color: var(--primary);
font-size: 1.1em;

.sidebar-wrapper {
display: none;
}

#main-outlet-wrapper {
grid-template-areas: "sidebar content";
grid-template-columns: 0 minmax(0, 1fr);
gap: 0;
}

.wizard-column {
position: relative;
z-index: 11;
Expand Down
3 changes: 2 additions & 1 deletion plugin.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# frozen_string_literal: true
# name: discourse-custom-wizard
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
# version: 2.5.5
# version: 2.6.0
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Juan Marcos Gutierrez Ramos
# url: https://github.com/paviliondev/discourse-custom-wizard
# contact_emails: [email protected]
# subscription_url: https://coop.pavilion.tech
# meta_topic_id: 73345

gem 'liquid', '5.0.1', require: true
gem "discourse_subscription_client", "0.1.1", require_name: "discourse_subscription_client"
Expand Down
2 changes: 1 addition & 1 deletion spec/components/custom_wizard/action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def update_template(template)
action.perform

expect(action.result.success?).to eq(true)
expect(TopicCustomField.exists?(name: custom_field_name, value: custom_field_value)).to eq(true)
expect(TopicCustomField.exists?(name: custom_field_name)).to eq(true)
end
end

Expand Down
1 change: 1 addition & 0 deletions spec/requests/custom_wizard/admin/api_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
end

it "does not save if user does not have relevant subscription" do
disable_subscriptions
put "/admin/wizards/api/:name.json", params: api_json.to_h
expect(response.status).to eq(400)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {
acceptance,
query,
queryAll,
visible,
} from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
import { click, fillIn, findAll, visit, waitUntil } from "@ember/test-helpers";
import { click, fillIn, visit, waitUntil } from "@ember/test-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import {
getCustomFields,
Expand Down Expand Up @@ -93,9 +94,9 @@ acceptance("Admin | Custom Fields Unsubscribed", function (needs) {

test("Navigate to custom fields tab", async (assert) => {
await visit("/admin/wizards/custom-fields");
assert.ok(find("table"));
assert.ok(query("table"));
assert.ok(
findAll("table tbody tr").length === 4,
queryAll("table tbody tr").length === 4,
"Display loaded custom fields"
);
assert.ok(
Expand Down Expand Up @@ -124,10 +125,10 @@ acceptance("Admin | Custom Fields Unsubscribed", function (needs) {
'.admin-wizard-container details:has(summary[name="Filter by: Select a class"])'
);
await dropdown1.expand();
let enabledOptions1 = findAll(
let enabledOptions1 = queryAll(
'.admin-wizard-container details:has(summary[name="Filter by: Select a class"]) ul li:not(.disabled)'
);
let disabledOptions1 = findAll(
let disabledOptions1 = queryAll(
'.admin-wizard-container details:has(summary[name="Filter by: Select a class"]) ul li.disabled'
);
assert.equal(
Expand All @@ -144,10 +145,10 @@ acceptance("Admin | Custom Fields Unsubscribed", function (needs) {
'.admin-wizard-container details:has(summary[name="Filter by: Select a type"])'
);
await dropdown2.expand();
let enabledOptions2 = findAll(
let enabledOptions2 = queryAll(
'.admin-wizard-container details:has(summary[name="Filter by: Select a type"]) ul li:not(.disabled)'
);
let disabledOptions2 = findAll(
let disabledOptions2 = queryAll(
'.admin-wizard-container details:has(summary[name="Filter by: Select a type"]) ul li.disabled'
);
assert.equal(
Expand All @@ -174,7 +175,7 @@ acceptance("Admin | Custom Fields Unsubscribed", function (needs) {
".admin-wizard-container details.multi-select"
);
await serializerDropdown.expand();
let enabledOptions1 = findAll(
let enabledOptions1 = queryAll(
".admin-wizard-container details.multi-select ul li"
);
assert.equal(
Expand All @@ -189,7 +190,7 @@ acceptance("Admin | Custom Fields Unsubscribed", function (needs) {
await dropdown2.expand();
await click('.select-kit-collection li[data-value="post"]');
await serializerDropdown.expand();
let enabledOptions2 = findAll(
let enabledOptions2 = queryAll(
".admin-wizard-container details.multi-select ul li"
);
assert.equal(
Expand All @@ -202,7 +203,7 @@ acceptance("Admin | Custom Fields Unsubscribed", function (needs) {
test("Create Topic and Post custom fields", async (assert) => {
await visit("/admin/wizards/custom-fields");
assert.ok(
findAll("table tbody tr").length === 4,
queryAll("table tbody tr").length === 4,
"Display loaded custom fields"
);
await click(".admin-wizard-controls .btn-icon-text");
Expand Down Expand Up @@ -267,7 +268,7 @@ acceptance("Admin | Custom Fields Unsubscribed", function (needs) {
"Post custom field name is displayed"
);
assert.ok(
findAll("table tbody tr").length === 6,
queryAll("table tbody tr").length === 6,
"Display added custom fields"
);
});
Expand Down Expand Up @@ -330,7 +331,7 @@ acceptance("Admin | Custom Fields Unsubscribed", function (needs) {
test("Delete Topic custom field", async (assert) => {
await visit("/admin/wizards/custom-fields");
assert.ok(
findAll("table tbody tr").length === 4,
queryAll("table tbody tr").length === 4,
"Display loaded custom fields"
);
await click(".admin-wizard-controls .btn-icon-text");
Expand All @@ -349,13 +350,13 @@ acceptance("Admin | Custom Fields Unsubscribed", function (needs) {
await click(".actions .save");
await waitForSaveMessage();
assert.ok(
findAll("table tbody tr").length === 5,
queryAll("table tbody tr").length === 5,
"Display added custom fields"
);
await click(".admin-wizard-container tbody tr:first-child button");
await click(".actions .destroy");
assert.ok(
findAll("table tbody tr").length === 4,
queryAll("table tbody tr").length === 4,
"Display custom fields without deleted fields"
);
});
Expand Down
18 changes: 11 additions & 7 deletions test/javascripts/acceptance/admin-logs-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import {
acceptance,
query,
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
import { click, findAll, visit } from "@ember/test-helpers";
import { click, visit } from "@ember/test-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import {
getSuppliers,
Expand Down Expand Up @@ -55,19 +59,19 @@ acceptance("Admin | Logs", function (needs) {
),
"it displays logs for a selected wizard"
);
assert.ok(find("table"));
assert.ok(findAll("table tbody tr").length === 2, "Displays logs list");
assert.ok(queryAll("table"));
assert.ok(queryAll("table tbody tr").length === 2, "Displays logs list");

await click(".refresh.btn");
assert.ok(find("table"));
assert.ok(queryAll("table"));
assert.ok(
findAll("table tbody tr").length === 2,
queryAll("table tbody tr").length === 2,
"Refresh button works correctly"
);

await wizards.expand();
await click('[data-name="Select a wizard"]');
const wizardContainerDiv = find(".admin-wizard-container");
const wizardContainerDiv = queryAll(".admin-wizard-container");
assert.ok(wizardContainerDiv.children().length === 0, "the div is empty");
});
});
28 changes: 16 additions & 12 deletions test/javascripts/acceptance/admin-submissions-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import {
acceptance,
query,
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
import { click, findAll, visit } from "@ember/test-helpers";
import { click, visit } from "@ember/test-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import {
getAnotherWizardSubmission,
Expand Down Expand Up @@ -61,7 +65,7 @@ acceptance("Admin | Submissions", function (needs) {
"it displays submissions for a selected wizard"
);
const submissions = getWizardSubmissions.submissions; // Get submissions data from your JSON file
const rows = findAll("table tbody tr");
const rows = queryAll("table tbody tr");

for (let i = 0; i < submissions.length; i++) {
const dateCell = rows[i].querySelector("td:nth-child(1)");
Expand All @@ -88,14 +92,14 @@ acceptance("Admin | Submissions", function (needs) {
);
}
assert.ok(
findAll("table tbody tr").length >= 1,
queryAll("table tbody tr").length >= 1,
"Displays submissions list"
);

await wizards.expand();
await click('[data-name="Select a wizard"]');
const wizardContainerDiv = find(".admin-wizard-container");
assert.ok(wizardContainerDiv.children().length === 0, "the div is empty");
const wizardContainerDiv = query(".admin-wizard-container");
assert.ok(wizardContainerDiv.children.length === 0, "the div is empty");
});
test("View submissions tab for another wizard with more steps", async (assert) => {
await visit("/admin/wizards/submissions");
Expand All @@ -112,7 +116,7 @@ acceptance("Admin | Submissions", function (needs) {
);

const submissions = getAnotherWizardSubmission.submissions; // Get submissions data from your JSON file
const rows = findAll("table tbody tr");
const rows = queryAll("table tbody tr");

for (let i = 0; i < submissions.length; i++) {
const dateCell = rows[i].querySelector("td:nth-child(1)");
Expand Down Expand Up @@ -147,7 +151,7 @@ acceptance("Admin | Submissions", function (needs) {
}

assert.ok(
findAll("table tbody tr").length >= 1,
queryAll("table tbody tr").length >= 1,
"Displays submissions list for another wizard"
);
});
Expand All @@ -158,9 +162,9 @@ acceptance("Admin | Submissions", function (needs) {
await wizards.selectRowByValue("this_is_testing_wizard");

await click(".open-edit-columns-btn");
assert.dom(".modal-inner-container").exists("Modal is displayed");
assert.dom(".d-modal__body").exists("Modal is displayed");

const userCheckbox = find(
const userCheckbox = queryAll(
".edit-directory-columns-container .edit-directory-column:nth-child(2) .left-content .column-name input"
);
assert.ok(userCheckbox, "User checkbox is present");
Expand All @@ -177,7 +181,7 @@ acceptance("Admin | Submissions", function (needs) {
.doesNotIncludeText("User", "User column is not displayed");

await click(".open-edit-columns-btn");
const submittedAtCheckbox = find(
const submittedAtCheckbox = queryAll(
".edit-directory-columns-container .edit-directory-column:nth-child(1) .left-content .column-name input"
);
assert.ok(submittedAtCheckbox, "Submitted At checkbox is present");
Expand Down Expand Up @@ -215,7 +219,7 @@ acceptance("Admin | Submissions", function (needs) {
await wizards.expand();
await wizards.selectRowByValue("this_is_testing_wizard");

const downloadLinks = findAll(".download-link");
const downloadLinks = queryAll(".download-link");
assert.ok(downloadLinks.length > 1, "Download links are present");

const downloadLink = downloadLinks[1];
Expand Down
8 changes: 6 additions & 2 deletions test/javascripts/acceptance/admin-wizards-api-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import {
acceptance,
query,
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
Expand Down Expand Up @@ -53,7 +57,7 @@ acceptance("Admin | API tab", function (needs) {

test("Visit API tab and fill data", async function (assert) {
await visit("/admin/wizards/api");
const list = find(".admin-controls li");
const list = queryAll(".admin-controls li");
const count = list.length;
assert.equal(count, 6, "There should be 6 admin tabs");

Expand Down
Loading

0 comments on commit fbb7f4c

Please sign in to comment.