add tabindex tests

This commit is contained in:
Nolan Lawson 2018-02-19 10:46:30 -08:00
parent 88c10d0321
commit dc1a42ed29
2 changed files with 46 additions and 1 deletions

View file

@ -0,0 +1,45 @@
describe('06-tabindex.js', () => {
beforeEach(() => {
cy.login('foobar@localhost:3000', 'foobarfoobar')
cy.wait(500)
})
it('shows correct tabindex in home timeline', () => {
cy.getNthVirtualArticle(0).should('have.attr', 'tabindex', '0')
cy.getNthVirtualArticle(2).should('have.attr', 'tabindex', '0')
cy.getNthVirtualArticle(3).should('have.attr', 'tabindex', '0')
})
it('shows correct tabindex in notifications', () => {
cy.visit('/notifications')
cy.wait(500)
cy.getNthVirtualArticle(0).should('have.attr', 'tabindex', '0')
.and('have.class', 'status-article')
cy.getNthVirtualArticle(1).should('have.attr', 'tabindex', '0')
.and('have.class', 'status-article')
cy.getNthVirtualArticle(2).should('have.attr', 'tabindex', '0')
.and('have.class', 'status-article')
cy.getNthVirtualArticle(3).should('have.attr', 'tabindex', '0')
.and('have.class', 'status-article')
cy.getNthVirtualArticle(4).should('have.attr', 'tabindex', '0')
cy.getNthVirtualArticle(4).scrollIntoView()
cy.wait(500)
cy.getNthVirtualArticle(5).should('have.attr', 'tabindex', '0')
.and('have.class', 'notification-article')
cy.getNthVirtualArticle(6).should('have.attr', 'tabindex', '0')
.and('have.class', 'status-article')
cy.getNthVirtualArticle(6).scrollIntoView()
cy.wait(500)
cy.getNthVirtualArticle(7).should('have.attr', 'tabindex', '0')
.and('have.attr', 'aria-setsize', '8')
.and('have.class', 'notification-article')
})
it('shows correct tabindex in pinned statuses', () => {
cy.visit('/pinned')
cy.wait(500)
cy.get('.status-article').should('have.attr', 'tabindex', '0')
.and('have.attr', 'aria-posinset', '0')
.and('have.attr', 'aria-setsize', '1')
})
})

View file

@ -1,5 +1,5 @@
<article class="status-article {{getClasses(originalStatus, timelineType, isStatusInOwnThread)}}" <article class="status-article {{getClasses(originalStatus, timelineType, isStatusInOwnThread)}}"
tabindex="{{ !isStatusInNotification || notification.type === 'follow' ? '0' : '' }}" tabindex="0"
delegate-click-key="{{elementKey}}" delegate-click-key="{{elementKey}}"
delegate-keydown-key="{{elementKey}}" delegate-keydown-key="{{elementKey}}"
focus-key="{{elementKey}}" focus-key="{{elementKey}}"