From 0602e59d70065f1ebf20826b6fd1454ce194c18d Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Tue, 20 Jun 2023 09:10:53 +0200 Subject: [PATCH] DEV: frontend tests cleanup - Fix failing test - Handle deprecations - Fix typos --- .../components/custom-user-selector.js.es6 | 2 +- .../components/custom-wizard-text-field.js.es6 | 2 +- .../controllers/admin-wizards-api-show.js.es6 | 13 +++++++------ plugin.rb | 2 +- ....js => admin-custom-fields-unsubscribed-test.js} | 3 ++- test/javascripts/acceptance/admin-manager-test.js | 3 ++- .../admin-wizards-standard-subscription-test.js | 2 +- .../acceptance/admin-wizards-unsuscribed-test.js | 5 +++-- 8 files changed, 18 insertions(+), 14 deletions(-) rename test/javascripts/acceptance/{admin-custom-fields-unsuscribed-test.js => admin-custom-fields-unsubscribed-test.js} (99%) diff --git a/assets/javascripts/discourse/components/custom-user-selector.js.es6 b/assets/javascripts/discourse/components/custom-user-selector.js.es6 index 3bb1fb3d..59711ec2 100644 --- a/assets/javascripts/discourse/components/custom-user-selector.js.es6 +++ b/assets/javascripts/discourse/components/custom-user-selector.js.es6 @@ -7,7 +7,7 @@ import userSearch from "discourse/lib/user-search"; import I18n from "I18n"; import Handlebars from "handlebars"; import { isEmpty } from "@ember/utils"; -import TextField from "@ember/component/text-field"; +import TextField from "discourse/components/text-field"; const template = function (params) { const options = params.options; diff --git a/assets/javascripts/discourse/components/custom-wizard-text-field.js.es6 b/assets/javascripts/discourse/components/custom-wizard-text-field.js.es6 index e8c22e93..d2832282 100644 --- a/assets/javascripts/discourse/components/custom-wizard-text-field.js.es6 +++ b/assets/javascripts/discourse/components/custom-wizard-text-field.js.es6 @@ -1,7 +1,7 @@ import computed from "discourse-common/utils/decorators"; import { isLTR, isRTL, siteDir } from "discourse/lib/text-direction"; import I18n from "I18n"; -import TextField from "@ember/component/text-field"; +import TextField from "discourse/components/text-field"; export default TextField.extend({ attributeBindings: [ diff --git a/assets/javascripts/discourse/controllers/admin-wizards-api-show.js.es6 b/assets/javascripts/discourse/controllers/admin-wizards-api-show.js.es6 index b89cc447..11bf94d7 100644 --- a/assets/javascripts/discourse/controllers/admin-wizards-api-show.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizards-api-show.js.es6 @@ -4,6 +4,7 @@ import CustomWizardApi from "../models/custom-wizard-api"; import { default as discourseComputed } from "discourse-common/utils/decorators"; import { and, equal, not } from "@ember/object/computed"; import { selectKitContent } from "../lib/wizard"; +import { underscore } from "@ember/string"; import Controller from "@ember/controller"; import I18n from "I18n"; @@ -118,7 +119,7 @@ export default Controller.extend({ if (authType === "oauth_2") { this.set("authorizing", true); - ajax(`/admin/wizards/apis/${name.underscore()}/authorize`) + ajax(`/admin/wizards/apis/${underscore(name)}/authorize`) .catch(popupAjaxError) .then((result) => { if (result.success) { @@ -187,11 +188,11 @@ export default Controller.extend({ if (!api[rp]) { let key = rp.replace("auth", ""); error = `${I18n.t( - `admin.wizard.api.auth.${key.underscore()}` + `admin.wizard.api.auth.${underscore(key)}` )} is required for ${authType}`; break; } - data[rp.underscore()] = api[rp]; + data[underscore(rp)] = api[rp]; } } @@ -221,7 +222,7 @@ export default Controller.extend({ this.set("updating", true); - ajax(`/admin/wizards/api/${name.underscore()}`, { + ajax(`/admin/wizards/api/${underscore(name)}`, { type: "PUT", data, }) @@ -244,7 +245,7 @@ export default Controller.extend({ this.set("updating", true); - ajax(`/admin/wizards/api/${name.underscore()}`, { + ajax(`/admin/wizards/api/${underscore(name)}`, { type: "DELETE", }) .catch(popupAjaxError) @@ -262,7 +263,7 @@ export default Controller.extend({ return; } - ajax(`/admin/wizards/api/${name.underscore()}/logs`, { + ajax(`/admin/wizards/api/${underscore(name)}/logs`, { type: "DELETE", }) .catch(popupAjaxError) diff --git a/plugin.rb b/plugin.rb index 64d0dc6d..47edb07d 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,7 +1,7 @@ # 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.4.4 +# version: 2.4.5 # authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever # url: https://github.com/paviliondev/discourse-custom-wizard # contact_emails: development@pavilion.tech diff --git a/test/javascripts/acceptance/admin-custom-fields-unsuscribed-test.js b/test/javascripts/acceptance/admin-custom-fields-unsubscribed-test.js similarity index 99% rename from test/javascripts/acceptance/admin-custom-fields-unsuscribed-test.js rename to test/javascripts/acceptance/admin-custom-fields-unsubscribed-test.js index fa3b5f75..94708f3c 100644 --- a/test/javascripts/acceptance/admin-custom-fields-unsuscribed-test.js +++ b/test/javascripts/acceptance/admin-custom-fields-unsubscribed-test.js @@ -11,6 +11,7 @@ import { getUnsubscribedAdminWizards, getWizard, } from "../helpers/admin-wizard"; +import { Promise } from "rsvp"; acceptance("Admin | Custom Fields Unsuscribed", function (needs) { needs.user(); @@ -83,7 +84,7 @@ acceptance("Admin | Custom Fields Unsuscribed", function (needs) { "View, create, edit and destroy custom fields", { timeout: 15000 } ); - await new Ember.RSVP.Promise((resolve) => setTimeout(resolve, 1000)); + await new Promise((resolve) => setTimeout(resolve, 1000)); } test("Navigate to custom fields tab", async (assert) => { diff --git a/test/javascripts/acceptance/admin-manager-test.js b/test/javascripts/acceptance/admin-manager-test.js index afa1b006..4ce1c0bf 100644 --- a/test/javascripts/acceptance/admin-manager-test.js +++ b/test/javascripts/acceptance/admin-manager-test.js @@ -6,6 +6,7 @@ import { getWizard, getWizardTestingLog, } from "../helpers/admin-wizard"; +import { Promise } from "rsvp"; acceptance("Admin | Manager", function (needs) { needs.user(); @@ -52,7 +53,7 @@ acceptance("Admin | Manager", function (needs) { { timeout: 15000 } ); // Wait an additional second after the conditions are met - await new Ember.RSVP.Promise((resolve) => setTimeout(resolve, 1000)); + await new Promise((resolve) => setTimeout(resolve, 1000)); } test("viewing manager fields content", async (assert) => { diff --git a/test/javascripts/acceptance/admin-wizards-standard-subscription-test.js b/test/javascripts/acceptance/admin-wizards-standard-subscription-test.js index b3debf77..b28b3f9f 100644 --- a/test/javascripts/acceptance/admin-wizards-standard-subscription-test.js +++ b/test/javascripts/acceptance/admin-wizards-standard-subscription-test.js @@ -58,7 +58,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) { assert.equal(count, 5, "There should be 5 admin tabs"); }); - test("creting a new wizard", async (assert) => { + test("creating a new wizard", async (assert) => { await visit("/admin/wizards/wizard"); await click(".admin-wizard-controls button"); assert.ok( diff --git a/test/javascripts/acceptance/admin-wizards-unsuscribed-test.js b/test/javascripts/acceptance/admin-wizards-unsuscribed-test.js index cc2f8bdb..3eb80dfd 100644 --- a/test/javascripts/acceptance/admin-wizards-unsuscribed-test.js +++ b/test/javascripts/acceptance/admin-wizards-unsuscribed-test.js @@ -1,5 +1,6 @@ import { acceptance, + exists, query, visible, } from "discourse/tests/helpers/qunit-helpers"; @@ -71,7 +72,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) { assert.equal(count, 5, "There should be 5 admin tabs"); }); - test("creting a new wizard", async (assert) => { + test("creating a new wizard", async (assert) => { await visit("/admin/wizards/wizard"); await click(".admin-wizard-controls button"); assert.ok( @@ -441,7 +442,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) { assert.strictEqual(actualResultText, "Result text", "Text is correct"); } const fieldsContentSet = [ - [6, "howto", "10"], + [6, "bug", "1"], [7, "gazelle", "gazelle"], ]; for (let [