Skip to content

Commit

Permalink
DEV: Fix some more flaky tests (#9384)
Browse files Browse the repository at this point in the history
Includes:
* DEV: Don't overwrite a computed property in test
  • Loading branch information
CvX committed Apr 8, 2020
1 parent 6171141 commit 8749999
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
10 changes: 7 additions & 3 deletions spec/helpers/emoji_helper_spec.rb
Expand Up @@ -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
Expand All @@ -13,8 +20,6 @@
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
Expand All @@ -24,5 +29,4 @@
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
4 changes: 4 additions & 0 deletions test/javascripts/acceptance/emoji-picker-test.js
Expand Up @@ -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();
Expand Down
11 changes: 5 additions & 6 deletions test/javascripts/controllers/preferences-account-test.js
Expand Up @@ -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);
});
4 changes: 4 additions & 0 deletions 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();
Expand Down

0 comments on commit 8749999

Please sign in to comment.