FIX: Flaky JS tests (#12331)

If you were unlucky and tested a mobile raw template before a desktop
raw template, it would keep using the mobile one resulting in failures.
This commit is contained in:
Robin Ward 2021-03-10 08:27:42 -05:00 committed by GitHub
parent c0421e4586
commit 55007c0621
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 15 deletions

View File

@ -3,7 +3,7 @@ import deprecated from "discourse-common/lib/deprecated";
import { findHelper } from "discourse-common/lib/helpers";
import { get } from "@ember/object";
const _options = {};
let _options = {};
export function setResolverOption(name, value) {
_options[name] = value;
@ -13,6 +13,10 @@ export function getResolverOption(name) {
return _options[name];
}
export function clearResolverOptions() {
_options = {};
}
function parseName(fullName) {
const nameParts = fullName.split(":");
const type = nameParts[0];

View File

@ -1,4 +1,4 @@
import { and, equal, notEmpty, or } from "@ember/object/computed";
import { alias, and, equal, notEmpty, or } from "@ember/object/computed";
import { fmt, propertyEqual } from "discourse/lib/computed";
import ActionSummary from "discourse/models/action-summary";
import Category from "discourse/models/category";
@ -58,25 +58,16 @@ const Topic = RestModel.extend({
@discourseComputed("posters.[]")
lastPoster(posters) {
let user;
if (posters && posters.length > 0) {
const latest = posters.filter(
(p) => p.extras && p.extras.indexOf("latest") >= 0
)[0];
user = latest;
return latest || posters.firstObject;
}
return user || posters.firstObject;
},
@discourseComputed("lastPoster")
lastPosterUser(poster) {
return poster.user;
},
@discourseComputed("lastPoster")
lastPosterGroup(poster) {
return poster.primary_group;
},
lastPosterUser: alias("lastPoster.user"),
lastPosterGroup: alias("lastPoster.primary_group"),
@discourseComputed("posters.[]", "participants.[]", "allowed_user_count")
featuredUsers(posters, participants, allowedUserCount) {

View File

@ -37,6 +37,7 @@ import sessionFixtures from "discourse/tests/fixtures/session-fixtures";
import { setTopicList } from "discourse/lib/topic-list-tracker";
import sinon from "sinon";
import siteFixtures from "discourse/tests/fixtures/site-fixtures";
import { clearResolverOptions } from "discourse-common/resolver";
const LEGACY_ENV = !setupApplicationTest;
@ -109,9 +110,9 @@ export function discourseModule(name, options) {
hooks.beforeEach(function () {
this.container = getOwner(this);
this.registry = this.container.registry;
this.owner = this.container;
this.siteSettings = currentSettings();
clearResolverOptions();
});
this.getController = function (controllerName, properties) {

View File

@ -40,6 +40,7 @@ discourseModule("Integration | Component | topic-list", function (hooks) {
},
async test(assert) {
assert.equal(this.selected.length, 0, "defaults to 0");
await click("button.bulk-select");
assert.ok(this.bulkSelectEnabled, "bulk select is enabled");