tests: Make puppeteer tests for drafts more robust.

I noticed that when you are in a group dm narrow
and open drafts, the overlay-message-row class
is inside different containers, and the nth last
child check does not apply for that case, which is
why the test failed.

More generally, last-child is just not a good selector for robust
testing.

Signed-off-by: apoorvapendse <apoorvavpendse@gmail.com>
This commit is contained in:
apoorvapendse
2025-08-14 22:17:14 +05:30
committed by Tim Abbott
parent 7391a2983f
commit 533f177175

View File

@@ -122,7 +122,7 @@ async function test_previously_created_drafts_rendered(page: Page): Promise<void
assert.strictEqual(
await common.get_text_from_selector(
page,
"#drafts_table .overlay-message-row:nth-last-child(2) .rendered_markdown.restore-overlay-message",
"#drafts_table .overlay-message-row .private-message .rendered_markdown.restore-overlay-message",
),
"Test direct message.",
);
@@ -136,7 +136,7 @@ async function test_previously_created_drafts_rendered(page: Page): Promise<void
assert.strictEqual(
await common.get_text_from_selector(
page,
"#drafts_table .overlay-message-row:last-child .rendered_markdown.restore-overlay-message",
"#drafts_table .overlay-message-row .message_row:not(.private-message) .rendered_markdown.restore-overlay-message",
),
"Test stream message.",
);