DEV: Fix some more flaky tests (#9384)

DEV: Fix some more flaky tests (#9384)

Includes:

  • DEV: Don’t overwrite a computed property in test
diff --git a/spec/helpers/emoji_helper_spec.rb b/spec/helpers/emoji_helper_spec.rb
index 7dec3b3..a8b13a9 100644
--- a/spec/helpers/emoji_helper_spec.rb
+++ b/spec/helpers/emoji_helper_spec.rb
@@ -4,6 +4,13 @@
 require 'rails_helper'
 
 describe EmojiHelper do
+  before do
+    Plugin::CustomEmoji.clear_cache
+  end
+
+  after do
+    Plugin::CustomEmoji.clear_cache
+  end
 
   describe "emoji_codes_to_img" do
     it "replaces emoji codes by images" do
@@ -13,8 +20,6 @@ describe EmojiHelper do
       replaced_str = helper.emoji_codes_to_img(str)
 
       expect(replaced_str).to eq("This is a good day <img src=\"/public/xxxxxx.png\" title=\"xxxxxx\" class=\"emoji\" alt=\"xxxxxx\"> <img src=\"/images/emoji/twitter/woman.png?v=#{Emoji::EMOJI_VERSION}\" title=\"woman\" class=\"emoji\" alt=\"woman\"> <img src=\"/images/emoji/twitter/man/4.png?v=#{Emoji::EMOJI_VERSION}\" title=\"man:t4\" class=\"emoji\" alt=\"man:t4\">")
-
-      Plugin::CustomEmoji.unregister("xxxxxx")
     end
 
     it "doesn't replace if code doesn't exist" do
@@ -24,5 +29,4 @@ describe EmojiHelper do
       expect(replaced_str).to eq("This is a good day <img src=\"/images/emoji/twitter/woman.png?v=#{Emoji::EMOJI_VERSION}\" title=\"woman\" class=\"emoji\" alt=\"woman\"> :foo: :bar:t4: :man:t8:")
     end
   end
-
 end
diff --git a/test/javascripts/acceptance/emoji-picker-test.js b/test/javascripts/acceptance/emoji-picker-test.js
index 71e06e1..fac3741 100644
--- a/test/javascripts/acceptance/emoji-picker-test.js
+++ b/test/javascripts/acceptance/emoji-picker-test.js
@@ -3,6 +3,10 @@ import { IMAGE_VERSION as v } from "pretty-text/emoji/version";
 
 acceptance("EmojiPicker", {
   loggedIn: true,
+  beforeEach() {
+    const store = Discourse.__container__.lookup("service:emoji-store");
+    store.reset();
+  },
   afterEach() {
     const store = Discourse.__container__.lookup("service:emoji-store");
     store.reset();
diff --git a/test/javascripts/controllers/preferences-account-test.js b/test/javascripts/controllers/preferences-account-test.js
index a0a8ae3..f953fb0 100644
--- a/test/javascripts/controllers/preferences-account-test.js
+++ b/test/javascripts/controllers/preferences-account-test.js
@@ -7,27 +7,26 @@ QUnit.test("updating of associated accounts", function(assert) {
       enable_google_oauth2_logins: true
     },
     model: EmberObject.create({
+      id: 70,
       second_factor_enabled: true,
       is_anonymous: true
     }),
+    currentUser: EmberObject.create({
+      id: 1234,
+    }),
     site: EmberObject.create({
       isMobileDevice: false
     })
   });
 
-  controller.set("canCheckEmails", false);
-
   assert.equal(controller.get("canUpdateAssociatedAccounts"), false);
 
   controller.set("model.second_factor_enabled", false);
-
   assert.equal(controller.get("canUpdateAssociatedAccounts"), false);
 
   controller.set("model.is_anonymous", false);
-
   assert.equal(controller.get("canUpdateAssociatedAccounts"), false);
 
-  controller.set("canCheckEmails", true);
-
+  controller.set("model.id", 1234);
   assert.equal(controller.get("canUpdateAssociatedAccounts"), true);
 });
diff --git a/test/javascripts/lib/emoji-store-test.js b/test/javascripts/lib/emoji-store-test.js
index f0c521a..3a137ed 100644
--- a/test/javascripts/lib/emoji-store-test.js
+++ b/test/javascripts/lib/emoji-store-test.js
@@ -1,4 +1,8 @@
 QUnit.module("lib:emoji-store", {
+  beforeEach() {
+    const store = Discourse.__container__.lookup("service:emoji-store");
+    store.reset();
+  },
   afterEach() {
     const store = Discourse.__container__.lookup("service:emoji-store");
     store.reset();

GitHub sha: 87499994

This commit appears in #9384 which was approved by davidtaylorhq. It was merged by CvX.