From 631603b0b7fb48a37188b691d1720f359fb3b0ab Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Wed, 12 Dec 2018 23:45:42 -0800 Subject: [PATCH] fix: fix flaky test by clicking relative date (#790) * fix: fix flaky test by clicking relative date * fix test and add new one --- tests/spec/017-compose-reply.js | 30 ++++++++++++++++++++++++------ tests/utils.js | 4 ++++ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/tests/spec/017-compose-reply.js b/tests/spec/017-compose-reply.js index 43222bab..eb301733 100644 --- a/tests/spec/017-compose-reply.js +++ b/tests/spec/017-compose-reply.js @@ -3,7 +3,7 @@ import { getNthComposeReplyInput, getNthPostPrivacyButton, getNthPostPrivacyOptionInDialog, getNthReplyButton, getNthReplyContentWarningButton, getNthReplyContentWarningInput, getNthReplyPostPrivacyButton, - getNthStatus, getUrl, homeNavButton, notificationsNavButton, scrollToStatus + getNthStatus, getNthStatusRelativeDate, getUrl, homeNavButton, notificationsNavButton, scrollToStatus } from '../utils' import { loginAsFoobar } from '../roles' import { homeTimeline } from '../fixtures' @@ -67,7 +67,8 @@ test('replies have same CW as replied-to status', async t => { await scrollToStatus(t, kittenIdx) await t.click(getNthReplyButton(kittenIdx)) .expect(getNthReplyContentWarningInput(kittenIdx).value).eql('kitten CW') - .click(getNthStatus(kittenIdx)) + .click(getNthStatusRelativeDate(kittenIdx)) + .expect(getUrl()).contains('/statuses') .click(getNthReplyButton(0)) .expect(getNthReplyContentWarningInput(0).value).eql('kitten CW') }) @@ -80,7 +81,8 @@ test('replies save deletions of CW', async t => { .expect(getNthReplyContentWarningInput(kittenIdx).value).eql('kitten CW') .click(getNthReplyContentWarningButton(kittenIdx)) .expect(getNthReplyContentWarningInput(kittenIdx).exists).notOk() - .click(getNthStatus(kittenIdx)) + .click(getNthStatusRelativeDate(kittenIdx)) + .expect(getUrl()).contains('/statuses') .click(getNthReplyButton(0)) .expect(getNthReplyContentWarningInput(0).exists).notOk() }) @@ -93,7 +95,8 @@ test('replies save changes to CW', async t => { .expect(getNthReplyContentWarningInput(kittenIdx).value).eql('kitten CW') .typeText(getNthReplyContentWarningInput(kittenIdx), ' yolo', { paste: true }) .expect(getNthReplyContentWarningInput(kittenIdx).value).eql('kitten CW yolo') - .click(getNthStatus(kittenIdx)) + .click(getNthStatusRelativeDate(kittenIdx)) + .expect(getUrl()).contains('/statuses') .click(getNthReplyButton(0)) .expect(getNthReplyContentWarningInput(0).value).eql('kitten CW yolo') }) @@ -108,7 +111,22 @@ test('replies save changes to post privacy', async t => { .click(getNthReplyPostPrivacyButton(1)) .click(getNthPostPrivacyOptionInDialog(1)) .expect(getNthPostPrivacyButton(1).getAttribute('aria-label')).eql('Adjust privacy (currently Public)') - .click(getNthStatus(1)) + .click(getNthStatusRelativeDate(1)) + .expect(getUrl()).contains('/statuses') .click(getNthReplyButton(0)) - .expect(getNthPostPrivacyButton(0).getAttribute('aria-label')).eql('Adjust privacy (currently Unlisted)') + .expect(getNthPostPrivacyButton(0).getAttribute('aria-label')).eql('Adjust privacy (currently Public)') +}) + +test('replies are the same whatever thread they are in', async t => { + await loginAsFoobar(t) + await t + .hover(getNthStatus(0)) + .hover(getNthStatus(1)) + .click(getNthReplyButton(1)) + .typeText(getNthComposeReplyInput(1), 'this is a reply', { paste: true }) + .expect(getNthComposeReplyInput(1).value).eql('@admin this is a reply') + .click(getNthStatusRelativeDate(1)) + .expect(getUrl()).contains('/statuses') + .click(getNthReplyButton(0)) + .expect(getNthComposeReplyInput(0).value).eql('@admin this is a reply') }) diff --git a/tests/utils.js b/tests/utils.js index 45153a24..a9b23ede 100644 --- a/tests/utils.js +++ b/tests/utils.js @@ -211,6 +211,10 @@ export function getNthStatusMedia (n) { return $(`${getNthStatusSelector(n)} .status-media`) } +export function getNthStatusRelativeDate (n) { + return $(`${getNthStatusSelector(n)} .status-relative-date`) +} + export function getNthStatusMediaImg (n) { return $(`${getNthStatusSelector(n)} .status-media img`) }