From 87f57158786b4f1344cadd8ff356a42ff8dc8b97 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Tue, 23 Aug 2022 21:09:37 +0200 Subject: [PATCH] DEV: Keep global state reset in a single place (#18049) --- .../tests/acceptance/plugin-outlet-multi-template-test.js | 3 --- .../discourse/tests/acceptance/sidebar-plugin-api-test.js | 3 --- .../javascripts/discourse/tests/helpers/qunit-helpers.js | 2 ++ .../discourse/tests/unit/lib/link-lookup-test.js | 6 ++++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-multi-template-test.js b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-multi-template-test.js index 8caa688682a..2c1ced058a9 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-multi-template-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-multi-template-test.js @@ -3,7 +3,6 @@ import { count, query, } from "discourse/tests/helpers/qunit-helpers"; -import { clearCache } from "discourse/lib/plugin-connectors"; import { hbs } from "ember-cli-htmlbars"; import { test } from "qunit"; import { visit } from "@ember/test-helpers"; @@ -14,7 +13,6 @@ const GOODBYE = acceptance("Plugin Outlet - Multi Template", function (needs) { needs.hooks.beforeEach(() => { - clearCache(); // eslint-disable-next-line no-undef Ember.TEMPLATES[HELLO] = hbs`Hello`; // eslint-disable-next-line no-undef @@ -26,7 +24,6 @@ acceptance("Plugin Outlet - Multi Template", function (needs) { delete Ember.TEMPLATES[HELLO]; // eslint-disable-next-line no-undef delete Ember.TEMPLATES[GOODBYE]; - clearCache(); }); test("Renders a template into the outlet", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-plugin-api-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-plugin-api-test.js index 1d7a2f79b2f..e83b1a05e49 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-plugin-api-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-plugin-api-test.js @@ -1,6 +1,5 @@ import { test } from "qunit"; import I18n from "I18n"; - import { click, visit } from "@ember/test-helpers"; import { acceptance, @@ -9,7 +8,6 @@ import { queryAll, } from "discourse/tests/helpers/qunit-helpers"; import { withPluginApi } from "discourse/lib/plugin-api"; -import { resetSidebarSection } from "discourse/lib/sidebar/user/custom-sections"; import { bind } from "discourse-common/utils/decorators"; acceptance("Sidebar - Plugin API", function (needs) { @@ -21,7 +19,6 @@ acceptance("Sidebar - Plugin API", function (needs) { }); needs.hooks.afterEach(() => { - resetSidebarSection(); linkDestroy = undefined; sectionDestroy = undefined; }); diff --git a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js index 00e8e1916f6..8e62285b85f 100644 --- a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js +++ b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js @@ -74,6 +74,7 @@ import { clearExtraHeaderIcons } from "discourse/widgets/header"; import { resetSidebarSection } from "discourse/lib/sidebar/user/custom-sections"; import { resetNotificationTypeRenderers } from "discourse/lib/notification-types-manager"; import { resetUserMenuTabs } from "discourse/lib/user-menu/tab"; +import { reset as resetLinkLookup } from "discourse/lib/link-lookup"; export function currentUser() { return User.create(sessionFixtures["/session/current.json"].current_user); @@ -204,6 +205,7 @@ export function testCleanup(container, app) { resetNotificationTypeRenderers(); clearExtraHeaderIcons(); resetUserMenuTabs(); + resetLinkLookup(); } export function discourseModule(name, options) { diff --git a/app/assets/javascripts/discourse/tests/unit/lib/link-lookup-test.js b/app/assets/javascripts/discourse/tests/unit/lib/link-lookup-test.js index ee3dd69a9c9..99473935751 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/link-lookup-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/link-lookup-test.js @@ -1,9 +1,8 @@ -import LinkLookup, { reset } from "discourse/lib/link-lookup"; +import LinkLookup from "discourse/lib/link-lookup"; import { module, test } from "qunit"; import Post from "discourse/models/post"; module("Unit | Utility | link-lookup", function (hooks) { - hooks.afterEach(() => reset()); hooks.beforeEach(function () { this.post = Post.create(); this.linkLookup = new LinkLookup({ @@ -21,6 +20,7 @@ module("Unit | Utility | link-lookup", function (hooks) { )[0] ); }); + test("works with http", function (assert) { assert.ok( this.linkLookup.check( @@ -29,6 +29,7 @@ module("Unit | Utility | link-lookup", function (hooks) { )[0] ); }); + test("works with trailing slash", function (assert) { assert.ok( this.linkLookup.check( @@ -37,6 +38,7 @@ module("Unit | Utility | link-lookup", function (hooks) { )[0] ); }); + test("works with uppercase characters", function (assert) { assert.ok( this.linkLookup.check(