DEV: fix flaky specs (#22011)

These spec are flaky only in CI, not locally and not in GitHub actions.

The previous attempt was in 44eabde, but actually the failure happens 
a bit earlier. This is another attempt to fix these specs. Quite a lot of 
async logic is happening in emulateAutocomplete(), a call to settled() 
in the end should help make it more reliable.
This commit is contained in:
Andrei Prigorshnev 2023-06-08 22:34:47 +04:00 committed by GitHub
parent c45eb8a618
commit 1ae91fe95f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -594,6 +594,7 @@ export async function emulateAutocomplete(inputSelector, text) {
await triggerKeyEvent(inputSelector, "keydown", "Backspace"); await triggerKeyEvent(inputSelector, "keydown", "Backspace");
await fillIn(inputSelector, text); await fillIn(inputSelector, text);
await triggerKeyEvent(inputSelector, "keyup", "Backspace"); await triggerKeyEvent(inputSelector, "keyup", "Backspace");
await settled();
} }
// The order of attributes can vary in different browsers. When comparing // The order of attributes can vary in different browsers. When comparing

View File

@ -5,7 +5,7 @@ import {
publishToMessageBus, publishToMessageBus,
query, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { skip, test } from "qunit"; import { test } from "qunit";
import { click, triggerEvent, visit, waitFor } from "@ember/test-helpers"; import { click, triggerEvent, visit, waitFor } from "@ember/test-helpers";
import pretender, { OK } from "discourse/tests/helpers/create-pretender"; import pretender, { OK } from "discourse/tests/helpers/create-pretender";
@ -94,7 +94,7 @@ acceptance("Chat | User status on mentions", function (needs) {
setupAutocompleteResponses([mentionedUser2, mentionedUser3]); setupAutocompleteResponses([mentionedUser2, mentionedUser3]);
}); });
skip("just posted messages | it shows status on mentions ", async function (assert) { test("just posted messages | it shows status on mentions ", async function (assert) {
await visit(`/chat/c/-/${channelId}`); await visit(`/chat/c/-/${channelId}`);
await typeWithAutocompleteAndSend(`mentioning @${mentionedUser2.username}`); await typeWithAutocompleteAndSend(`mentioning @${mentionedUser2.username}`);
assertStatusIsRendered( assertStatusIsRendered(
@ -104,7 +104,7 @@ acceptance("Chat | User status on mentions", function (needs) {
); );
}); });
skip("just posted messages | it updates status on mentions", async function (assert) { test("just posted messages | it updates status on mentions", async function (assert) {
await visit(`/chat/c/-/${channelId}`); await visit(`/chat/c/-/${channelId}`);
await typeWithAutocompleteAndSend(`mentioning @${mentionedUser2.username}`); await typeWithAutocompleteAndSend(`mentioning @${mentionedUser2.username}`);
@ -117,7 +117,7 @@ acceptance("Chat | User status on mentions", function (needs) {
assertStatusIsRendered(assert, selector, newStatus); assertStatusIsRendered(assert, selector, newStatus);
}); });
skip("just posted messages | it deletes status on mentions", async function (assert) { test("just posted messages | it deletes status on mentions", async function (assert) {
await visit(`/chat/c/-/${channelId}`); await visit(`/chat/c/-/${channelId}`);
await typeWithAutocompleteAndSend(`mentioning @${mentionedUser2.username}`); await typeWithAutocompleteAndSend(`mentioning @${mentionedUser2.username}`);
@ -131,7 +131,7 @@ acceptance("Chat | User status on mentions", function (needs) {
assert.dom(selector).doesNotExist("status is deleted"); assert.dom(selector).doesNotExist("status is deleted");
}); });
skip("edited messages | it shows status on mentions", async function (assert) { test("edited messages | it shows status on mentions", async function (assert) {
await visit(`/chat/c/-/${channelId}`); await visit(`/chat/c/-/${channelId}`);
await editMessage( await editMessage(
@ -146,7 +146,7 @@ acceptance("Chat | User status on mentions", function (needs) {
); );
}); });
skip("edited messages | it updates status on mentions", async function (assert) { test("edited messages | it updates status on mentions", async function (assert) {
await visit(`/chat/c/-/${channelId}`); await visit(`/chat/c/-/${channelId}`);
await editMessage( await editMessage(
".chat-message-content", ".chat-message-content",
@ -162,7 +162,7 @@ acceptance("Chat | User status on mentions", function (needs) {
assertStatusIsRendered(assert, selector, newStatus); assertStatusIsRendered(assert, selector, newStatus);
}); });
skip("edited messages | it deletes status on mentions", async function (assert) { test("edited messages | it deletes status on mentions", async function (assert) {
await visit(`/chat/c/-/${channelId}`); await visit(`/chat/c/-/${channelId}`);
await editMessage( await editMessage(