From e145735c1d542137f478fba62af3ea2266a32340 Mon Sep 17 00:00:00 2001
From: Robert <35533304+merefield@users.noreply.github.com>
Date: Tue, 6 Aug 2024 07:39:03 +0100
Subject: [PATCH] DEV: poll flakey spec
---
.../acceptance/poll-results-test.js | 48 ++++++++++---------
1 file changed, 25 insertions(+), 23 deletions(-)
diff --git a/plugins/poll/test/javascripts/acceptance/poll-results-test.js b/plugins/poll/test/javascripts/acceptance/poll-results-test.js
index 8bfc19aada0..b1f2a73f652 100644
--- a/plugins/poll/test/javascripts/acceptance/poll-results-test.js
+++ b/plugins/poll/test/javascripts/acceptance/poll-results-test.js
@@ -527,11 +527,11 @@ acceptance("Poll results", function (needs) {
server.get("/polls/voters.json", (request) => {
if (
- request.queryParams.option_id === "d8c22ff912e03740d9bc19e133e581e0"
+ request.queryParams.option_id === "db753fe0bc4e72869ac1ad8765341764"
) {
return helper.response({
voters: {
- d8c22ff912e03740d9bc19e133e581e0: [
+ db753fe0bc4e72869ac1ad8765341764: [
{
id: 1,
username: "bianca",
@@ -540,6 +540,14 @@ acceptance("Poll results", function (needs) {
"/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png",
title: null,
},
+ {
+ id: 7,
+ username: "foo",
+ name: null,
+ avatar_template:
+ "/letter_avatar_proxy/v4/letter/f/b19c9b/{size}.png",
+ title: null,
+ },
],
},
});
@@ -576,14 +584,15 @@ acceptance("Poll results", function (needs) {
test("can load more voters", async function (assert) {
await visit("/t/load-more-poll-voters/134");
-
assert.strictEqual(
count(".poll-container .results li:nth-child(1) .poll-voters li"),
- 1
+ 1,
+ "Initially, one voter shown on first option"
);
assert.strictEqual(
count(".poll-container .results li:nth-child(2) .poll-voters li"),
- 0
+ 0,
+ "Initially, no voter shown on second option"
);
await publishToMessageBus("/polls/134", {
@@ -599,15 +608,15 @@ acceptance("Poll results", function (needs) {
{
id: "db753fe0bc4e72869ac1ad8765341764",
html: 'Option #1',
- votes: 1,
+ votes: 2,
},
{
id: "d8c22ff912e03740d9bc19e133e581e0",
html: 'Option #2',
- votes: 2,
+ votes: 0,
},
],
- voters: 3,
+ voters: 2,
preloaded_voters: {
db753fe0bc4e72869ac1ad8765341764: [
{
@@ -618,16 +627,6 @@ acceptance("Poll results", function (needs) {
"/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png",
},
],
- d8c22ff912e03740d9bc19e133e581e0: [
- {
- id: 7,
- username: "foo",
- name: null,
- avatar_template:
- "/letter_avatar_proxy/v4/letter/f/b19c9b/{size}.png",
- title: null,
- },
- ],
},
chart_type: "bar",
title: null,
@@ -637,24 +636,27 @@ acceptance("Poll results", function (needs) {
assert.strictEqual(
count(".poll-container .results li:nth-child(1) .poll-voters li"),
- 1
+ 1,
+ "after incoming message, one voter shown on first option"
);
assert.strictEqual(
count(".poll-container .results li:nth-child(2) .poll-voters li"),
- 1
+ 0,
+ "after incoming message, no voter shown on second option"
);
await click(".poll-voters-toggle-expand");
- await visit("/t/load-more-poll-voters/134");
assert.strictEqual(
count(".poll-container .results li:nth-child(1) .poll-voters li"),
- 2
+ 2,
+ "after clicking fetch voters button, two voters shown on first option"
);
assert.strictEqual(
count(".poll-container .results li:nth-child(2) .poll-voters li"),
- 0
+ 0,
+ "after clicking fetch voters button, no voters shown on second option"
);
});