fix: fix flaky test by clicking relative date (#790)

* fix: fix flaky test by clicking relative date

* fix test and add new one
This commit is contained in:
Nolan Lawson 2018-12-12 23:45:42 -08:00 committed by GitHub
parent 30705da19d
commit 631603b0b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 6 deletions

View file

@ -3,7 +3,7 @@ import {
getNthComposeReplyInput, getNthPostPrivacyButton, getNthPostPrivacyOptionInDialog, getNthReplyButton, getNthComposeReplyInput, getNthPostPrivacyButton, getNthPostPrivacyOptionInDialog, getNthReplyButton,
getNthReplyContentWarningButton, getNthReplyContentWarningButton,
getNthReplyContentWarningInput, getNthReplyPostPrivacyButton, getNthReplyContentWarningInput, getNthReplyPostPrivacyButton,
getNthStatus, getUrl, homeNavButton, notificationsNavButton, scrollToStatus getNthStatus, getNthStatusRelativeDate, getUrl, homeNavButton, notificationsNavButton, scrollToStatus
} from '../utils' } from '../utils'
import { loginAsFoobar } from '../roles' import { loginAsFoobar } from '../roles'
import { homeTimeline } from '../fixtures' import { homeTimeline } from '../fixtures'
@ -67,7 +67,8 @@ test('replies have same CW as replied-to status', async t => {
await scrollToStatus(t, kittenIdx) await scrollToStatus(t, kittenIdx)
await t.click(getNthReplyButton(kittenIdx)) await t.click(getNthReplyButton(kittenIdx))
.expect(getNthReplyContentWarningInput(kittenIdx).value).eql('kitten CW') .expect(getNthReplyContentWarningInput(kittenIdx).value).eql('kitten CW')
.click(getNthStatus(kittenIdx)) .click(getNthStatusRelativeDate(kittenIdx))
.expect(getUrl()).contains('/statuses')
.click(getNthReplyButton(0)) .click(getNthReplyButton(0))
.expect(getNthReplyContentWarningInput(0).value).eql('kitten CW') .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') .expect(getNthReplyContentWarningInput(kittenIdx).value).eql('kitten CW')
.click(getNthReplyContentWarningButton(kittenIdx)) .click(getNthReplyContentWarningButton(kittenIdx))
.expect(getNthReplyContentWarningInput(kittenIdx).exists).notOk() .expect(getNthReplyContentWarningInput(kittenIdx).exists).notOk()
.click(getNthStatus(kittenIdx)) .click(getNthStatusRelativeDate(kittenIdx))
.expect(getUrl()).contains('/statuses')
.click(getNthReplyButton(0)) .click(getNthReplyButton(0))
.expect(getNthReplyContentWarningInput(0).exists).notOk() .expect(getNthReplyContentWarningInput(0).exists).notOk()
}) })
@ -93,7 +95,8 @@ test('replies save changes to CW', async t => {
.expect(getNthReplyContentWarningInput(kittenIdx).value).eql('kitten CW') .expect(getNthReplyContentWarningInput(kittenIdx).value).eql('kitten CW')
.typeText(getNthReplyContentWarningInput(kittenIdx), ' yolo', { paste: true }) .typeText(getNthReplyContentWarningInput(kittenIdx), ' yolo', { paste: true })
.expect(getNthReplyContentWarningInput(kittenIdx).value).eql('kitten CW yolo') .expect(getNthReplyContentWarningInput(kittenIdx).value).eql('kitten CW yolo')
.click(getNthStatus(kittenIdx)) .click(getNthStatusRelativeDate(kittenIdx))
.expect(getUrl()).contains('/statuses')
.click(getNthReplyButton(0)) .click(getNthReplyButton(0))
.expect(getNthReplyContentWarningInput(0).value).eql('kitten CW yolo') .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(getNthReplyPostPrivacyButton(1))
.click(getNthPostPrivacyOptionInDialog(1)) .click(getNthPostPrivacyOptionInDialog(1))
.expect(getNthPostPrivacyButton(1).getAttribute('aria-label')).eql('Adjust privacy (currently Public)') .expect(getNthPostPrivacyButton(1).getAttribute('aria-label')).eql('Adjust privacy (currently Public)')
.click(getNthStatus(1)) .click(getNthStatusRelativeDate(1))
.expect(getUrl()).contains('/statuses')
.click(getNthReplyButton(0)) .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')
}) })

View file

@ -211,6 +211,10 @@ export function getNthStatusMedia (n) {
return $(`${getNthStatusSelector(n)} .status-media`) return $(`${getNthStatusSelector(n)} .status-media`)
} }
export function getNthStatusRelativeDate (n) {
return $(`${getNthStatusSelector(n)} .status-relative-date`)
}
export function getNthStatusMediaImg (n) { export function getNthStatusMediaImg (n) {
return $(`${getNthStatusSelector(n)} .status-media img`) return $(`${getNthStatusSelector(n)} .status-media img`)
} }