improve timelines test

This commit is contained in:
Nolan Lawson 2018-02-19 09:01:02 -08:00
parent 8a1cc02c75
commit c133c25c67
4 changed files with 50 additions and 5 deletions

View File

@ -8,6 +8,10 @@ describe('Basic timeline spec', () => {
})
const homeTimeline = [
{content: 'pinned toot 1'},
{content: 'notification of unlisted message'},
{content: 'notification of followers-only message'},
{content: 'notification of direct message'},
{content: 'this is unlisted'},
{content: 'this is followers-only'},
{content: 'direct'},
@ -25,23 +29,48 @@ describe('Basic timeline spec', () => {
{content: 'hello world'}
].concat(times(30, i => ({content: (30 - i).toString()})))
const localTimeline = homeTimeline.slice()
localTimeline.splice(0, 3)
localTimeline.splice(9, 2)
const localTimeline = [
{spoiler: 'kitten CW'},
{content: 'secret video'},
{content: "here's a video"},
{spoiler: 'CW'},
{content: "here's a secret animated kitten gif"},
{content: "here's an animated kitten gif"},
{content: "here's 2 kitten photos"},
{content: "here's a secret kitten"},
{content: "here's a kitten"},
{content: 'hello world'}
].concat(times(30, i => ({content: (30 - i).toString()})))
const notifications = [
{favoritedBy: 'admin'},
{rebloggedBy: 'admin'},
{content: 'notification of unlisted message'},
{content: 'notification of followers-only message'},
{content: 'notification of direct message'},
{followedBy: 'quux'},
{content: 'hello foobar'},
{followedBy: 'admin'}
]
const favorites = [
{content: 'notification of direct message'},
{content: 'notification of followers-only message'},
{content: 'notification of unlisted message'},
{content: 'pinned toot 1'}
]
const pinnedStatuses = [
{content: 'this is unlisted'}
]
it('Shows the home timeline', () => {
cy.get('.virtual-list-item[aria-hidden=false] .status-article:first').should('have.attr', 'aria-setsize')
cy.get('.virtual-list-item[aria-hidden=false] .status-article:first').should('have.attr', 'aria-posinset', '0')
cy.validateTimeline(homeTimeline)
cy.get('.virtual-list-item[aria-hidden=false] .status-article:first').should('have.attr', 'aria-setsize', (30 + 15).toString())
cy.get('.virtual-list-item[aria-hidden=false] .status-article:first').should('have.attr', 'aria-setsize', '49')
})
it('Shows notifications', () => {
@ -49,7 +78,6 @@ describe('Basic timeline spec', () => {
cy.url().should('contain', '/notifications')
cy.validateTimeline(notifications)
})
it('Shows the local timeline', () => {
@ -67,4 +95,13 @@ describe('Basic timeline spec', () => {
cy.validateTimeline(localTimeline) // local is same as federated in this case
})
it('Shows favorites', () => {
cy.get('nav a[aria-label=Community]').click()
cy.url().should('contain', '/community')
cy.get('a').contains('Favorites').click()
cy.url().should('contain', '/favorites')
cy.validateTimeline(favorites)
})
})

View File

@ -65,6 +65,14 @@ Cypress.Commands.add('validateTimeline', (timeline) => {
cy.getNthVirtualArticle(i).get('.status-header span').should('contain', status.followedBy)
cy.getNthVirtualArticle(i).get('.status-header span').should('contain', 'followed you')
}
if (status.rebloggedBy) {
cy.getNthVirtualArticle(i).get('.status-header span').should('contain', status.rebloggedBy)
cy.getNthVirtualArticle(i).get('.status-header span').should('contain', 'boosted')
}
if (status.favoritedBy) {
cy.getNthVirtualArticle(i).get('.status-header span').should('contain', status.favoritedBy)
cy.getNthVirtualArticle(i).get('.status-header span').should('contain', 'favorited')
}
cy.wait(50)
cy.getNthVirtualArticle(i).scrollIntoView()
cy.get('.loading-footer').should('not.exist')

Binary file not shown.

Binary file not shown.