jam-cloud/jam-ui/cypress/integration/layout/navigation.spec.js

65 lines
1.8 KiB
JavaScript
Raw Normal View History

2021-08-11 08:12:32 +00:00
/// <reference types="cypress" />
describe("Top Navigation", () => {
const showSubscribeToUpdates = () => {
cy.contains('Keep JamKazam Improving').should('exist')
cy.contains('Subscribe').should('exist')
}
const showProfileDropdown = () => {
cy.get('[data-testid=navbarTopProfileDropdown]').should('exist')
cy.contains("Peter Pan").should('exist')
cy.contains("My Profile").should('exist')
cy.contains("Sign out").should('exist')
2021-08-11 08:12:32 +00:00
}
describe("when user has not logged in", () => {
beforeEach(() => {
cy.stubUnauthenticate()
cy.visit('/')
});
it("does not show user dropdown", () => {
cy.contains("Signin to begin")
2021-10-15 12:06:58 +00:00
cy.get('a.btn').should('have.text', 'Sign in')
2021-08-11 08:12:32 +00:00
cy.get('[data-testid=navbarTopProfileDropdown]').should('not.exist')
});
})
describe("when user has logged in", () => {
beforeEach(() => {
cy.stubAuthenticate()
cy.visit('/')
});
it("shows user dropdown", () => {
showSubscribeToUpdates()
showProfileDropdown()
2021-08-11 08:12:32 +00:00
})
})
2021-10-15 12:06:58 +00:00
describe('header notifications', () => {
beforeEach(() => {
cy.stubAuthenticate()
cy.intercept('GET', /\S+\/notifications/, { fixture: 'notifications'} )
cy.intercept('GET', /\S+\/profile\S+/, { fixture: 'person' });
cy.visit('/')
})
it('shows notifications', () => {
cy.get('[data-testid=notificationDropdown]').should('not.be.visible')
cy.get('.notification-indicator').trigger('mouseover')
cy.get('[data-testid=notificationDropdown]').should('be.visible')
cy.get('[data-testid=notificationDropdown] .list-group-item').should('have.length', 3)
cy.get('[data-testid=notificationDropdown]').contains('View all').click() //view all notifications
cy.url().should('include', '/notifications')
})
})
2021-08-11 08:12:32 +00:00
});