docbrown/cypress/e2e/seededFlows/notificationsFlows/notificationNavigation.spec.js
dependabot[bot] deb86efb0d
Bump cypress and @knapsack-pro/cypress (#18025)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-07-06 17:53:13 -04:00

58 lines
1.9 KiB
JavaScript

describe('Notification navigation', () => {
describe('mobile screens', () => {
beforeEach(() => {
cy.testSetup();
cy.fixture('users/adminUser.json').as('user');
cy.get('@user').then((user) => {
cy.loginUser(user).then(() => {
cy.viewport('iphone-6');
cy.visit('/notifications');
});
});
});
it('should show All by default', () => {
cy.findByRole('navigation', { name: 'Notifications' }).within(() => {
cy.findByRole('link', { name: 'All' }).as('all');
cy.findByRole('link', { name: 'Comments' }).as('comments');
cy.findByRole('link', { name: 'Posts' }).as('posts');
cy.get('@all').should('have.attr', 'aria-current', 'page');
cy.get('@comments').should('have.attr', 'aria-current', '');
cy.get('@posts').should('have.attr', 'aria-current', '');
});
});
it('should switch to Comments tab', () => {
cy.findByRole('navigation', { name: 'Notifications' }).within(() => {
cy.findByRole('link', { name: 'Comments' }).as('comments');
cy.get('@comments').should('have.attr', 'aria-current', '');
cy.get('@comments').click();
});
cy.url().should('contain', '/comments');
// Get a fresh handle as we're on a new page
cy.findByRole('link', { name: 'Comments' }).should(
'have.attr',
'aria-current',
'page',
);
});
it('should switch to Posts tab', () => {
cy.findByRole('navigation', { name: 'Notifications' }).within(() => {
cy.findByRole('link', { name: 'Posts' }).as('posts');
cy.get('@posts').should('have.attr', 'aria-current', '');
cy.get('@posts').click();
});
cy.url().should('contain', '/posts');
// Get a fresh handle as we're on a new page
cy.findByRole('link', { name: 'Posts' }).should(
'have.attr',
'aria-current',
'page',
);
});
});
});