/// 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') } describe("when user has not logged in", () => { beforeEach(() => { cy.stubUnauthenticate() cy.visit('/') }); it("does not show user dropdown", () => { cy.contains("Signin to begin") cy.get('a.btn').should('have.text', 'Sign in') 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() }) }) 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') }) }) });