DEV: Increase tests' stability by avoiding testing tooltips (#23563)

Tooltips are generally hard to test, and we noticed that they make tests flaky. 
We may not test tooltips in these acceptance tests, since they are already 
tested in components/chat-channel-test.js. This PR deletes tooltip-related 
assertions and unskips tests that became flaky after adding them.
This commit is contained in:
Andrei Prigorshnev 2023-10-06 16:50:53 +04:00 committed by GitHub
parent bd52b1ec7b
commit 3ea55cff16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 52 deletions

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 } from "qunit"; import { skip, test } from "qunit";
import { click, triggerEvent, visit, waitFor } from "@ember/test-helpers"; import { click, triggerEvent, visit, waitFor } from "@ember/test-helpers";
import pretender, { response } from "discourse/tests/helpers/create-pretender"; import pretender, { response } from "discourse/tests/helpers/create-pretender";
@ -56,6 +56,7 @@ acceptance("Chat | User status on mentions", function (needs) {
id: channelId, id: channelId,
chatable_id: 1, chatable_id: 1,
chatable_type: "Category", chatable_type: "Category",
title: "A category channel",
meta: { message_bus_last_ids: {}, can_delete_self: true }, meta: { message_bus_last_ids: {}, can_delete_self: true },
current_user_membership: { following: true }, current_user_membership: { following: true },
chatable: { id: 1 }, chatable: { id: 1 },
@ -117,11 +118,6 @@ acceptance("Chat | User status on mentions", function (needs) {
statusSelector(mentionedUser2.username), statusSelector(mentionedUser2.username),
mentionedUser2.status mentionedUser2.status
); );
await assertStatusTooltipIsRendered(
assert,
statusSelector(mentionedUser2.username),
mentionedUser2.status
);
}); });
skip("just posted messages | it updates status on mentions", async function (assert) { skip("just posted messages | it updates status on mentions", async function (assert) {
@ -135,7 +131,6 @@ acceptance("Chat | User status on mentions", function (needs) {
const selector = statusSelector(mentionedUser2.username); const selector = statusSelector(mentionedUser2.username);
await waitFor(selector); await waitFor(selector);
assertStatusIsRendered(assert, selector, newStatus); assertStatusIsRendered(assert, selector, newStatus);
await assertStatusTooltipIsRendered(assert, selector, newStatus);
}); });
skip("just posted messages | it deletes status on mentions", async function (assert) { skip("just posted messages | it deletes status on mentions", async function (assert) {
@ -165,11 +160,6 @@ acceptance("Chat | User status on mentions", function (needs) {
statusSelector(mentionedUser3.username), statusSelector(mentionedUser3.username),
mentionedUser3.status mentionedUser3.status
); );
await assertStatusTooltipIsRendered(
assert,
statusSelector(mentionedUser3.username),
mentionedUser3.status
);
}); });
skip("edited messages | it updates status on mentions", async function (assert) { skip("edited messages | it updates status on mentions", async function (assert) {
@ -186,7 +176,6 @@ acceptance("Chat | User status on mentions", function (needs) {
const selector = statusSelector(mentionedUser3.username); const selector = statusSelector(mentionedUser3.username);
await waitFor(selector); await waitFor(selector);
assertStatusIsRendered(assert, selector, newStatus); assertStatusIsRendered(assert, selector, newStatus);
await assertStatusTooltipIsRendered(assert, selector, newStatus);
}); });
skip("edited messages | it deletes status on mentions", async function (assert) { skip("edited messages | it deletes status on mentions", async function (assert) {
@ -206,7 +195,7 @@ acceptance("Chat | User status on mentions", function (needs) {
assert.dom(selector).doesNotExist("status is deleted"); assert.dom(selector).doesNotExist("status is deleted");
}); });
skip("deleted messages | it shows status on mentions", async function (assert) { test("deleted messages | it shows status on mentions", async function (assert) {
await visit(`/chat/c/-/${channelId}`); await visit(`/chat/c/-/${channelId}`);
await deleteMessage(".chat-message-content"); await deleteMessage(".chat-message-content");
@ -217,14 +206,9 @@ acceptance("Chat | User status on mentions", function (needs) {
statusSelector(mentionedUser1.username), statusSelector(mentionedUser1.username),
mentionedUser1.status mentionedUser1.status
); );
await assertStatusTooltipIsRendered(
assert,
statusSelector(mentionedUser1.username),
mentionedUser1.status
);
}); });
skip("deleted messages | it updates status on mentions", async function (assert) { test("deleted messages | it updates status on mentions", async function (assert) {
await visit(`/chat/c/-/${channelId}`); await visit(`/chat/c/-/${channelId}`);
await deleteMessage(".chat-message-content"); await deleteMessage(".chat-message-content");
@ -237,10 +221,9 @@ acceptance("Chat | User status on mentions", function (needs) {
const selector = statusSelector(mentionedUser1.username); const selector = statusSelector(mentionedUser1.username);
await waitFor(selector); await waitFor(selector);
assertStatusIsRendered(assert, selector, newStatus); assertStatusIsRendered(assert, selector, newStatus);
await assertStatusTooltipIsRendered(assert, selector, newStatus);
}); });
skip("deleted messages | it deletes status on mentions", async function (assert) { test("deleted messages | it deletes status on mentions", async function (assert) {
await visit(`/chat/c/-/${channelId}`); await visit(`/chat/c/-/${channelId}`);
await deleteMessage(".chat-message-content"); await deleteMessage(".chat-message-content");
@ -255,7 +238,7 @@ acceptance("Chat | User status on mentions", function (needs) {
assert.dom(selector).doesNotExist("status is deleted"); assert.dom(selector).doesNotExist("status is deleted");
}); });
skip("restored messages | it shows status on mentions", async function (assert) { test("restored messages | it shows status on mentions", async function (assert) {
await visit(`/chat/c/-/${channelId}`); await visit(`/chat/c/-/${channelId}`);
await deleteMessage(".chat-message-content"); await deleteMessage(".chat-message-content");
@ -266,14 +249,9 @@ acceptance("Chat | User status on mentions", function (needs) {
statusSelector(mentionedUser1.username), statusSelector(mentionedUser1.username),
mentionedUser1.status mentionedUser1.status
); );
await assertStatusTooltipIsRendered(
assert,
statusSelector(mentionedUser1.username),
mentionedUser1.status
);
}); });
skip("restored messages | it updates status on mentions", async function (assert) { test("restored messages | it updates status on mentions", async function (assert) {
await visit(`/chat/c/-/${channelId}`); await visit(`/chat/c/-/${channelId}`);
await deleteMessage(".chat-message-content"); await deleteMessage(".chat-message-content");
@ -286,10 +264,9 @@ acceptance("Chat | User status on mentions", function (needs) {
const selector = statusSelector(mentionedUser1.username); const selector = statusSelector(mentionedUser1.username);
await waitFor(selector); await waitFor(selector);
assertStatusIsRendered(assert, selector, newStatus); assertStatusIsRendered(assert, selector, newStatus);
await assertStatusTooltipIsRendered(assert, selector, newStatus);
}); });
skip("restored messages | it deletes status on mentions", async function (assert) { test("restored messages | it deletes status on mentions", async function (assert) {
await visit(`/chat/c/-/${channelId}`); await visit(`/chat/c/-/${channelId}`);
await deleteMessage(".chat-message-content"); await deleteMessage(".chat-message-content");
@ -315,27 +292,6 @@ acceptance("Chat | User status on mentions", function (needs) {
); );
} }
async function assertStatusTooltipIsRendered(assert, selector, status) {
await triggerEvent(selector, "mouseenter");
assert.equal(
document
.querySelector(".user-status-tooltip-description")
.textContent.trim(),
status.description,
"status description is correct"
);
assert.ok(
document.querySelector(
`.user-status-message-tooltip img[alt='${status.emoji}']`
),
"status emoji is correct"
);
await triggerEvent(selector, "mouseleave");
}
async function deleteMessage(messageSelector) { async function deleteMessage(messageSelector) {
await triggerEvent(query(messageSelector), "mouseenter"); await triggerEvent(query(messageSelector), "mouseenter");
await click(".more-buttons .select-kit-header-wrapper"); await click(".more-buttons .select-kit-header-wrapper");