From a6a22178cb39444d59d74ac84052324108badd68 Mon Sep 17 00:00:00 2001 From: Lemmy Adams Date: Fri, 6 Oct 2023 13:20:28 +0100 Subject: [PATCH 1/3] Added initial drawer tests --- test/e2e/extensions/drawer.cy.js | 63 ++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 test/e2e/extensions/drawer.cy.js diff --git a/test/e2e/extensions/drawer.cy.js b/test/e2e/extensions/drawer.cy.js new file mode 100644 index 000000000..ba5c271af --- /dev/null +++ b/test/e2e/extensions/drawer.cy.js @@ -0,0 +1,63 @@ +import Course from '../../../src/course/en/course.json' + +describe('Drawer', () => { + const checkDrawerLength = (count) => { + cy.get('.drawer__item').not('.u-display-none').should('have.length', count) + } + + beforeEach(() => { + cy.visit('/'); + cy.get('button[data-event="toggleDrawer"]').click() + }) + + it('should appear on the right hand side in menu view', () => { + cy.get('.drawer').should('have.css', 'right').and('match', /0px/) + }); + + it('should appear on the right hand side in course view', () => { + cy.get('button.drawer__close-btn').click() + cy.get('button').contains('View').first().click() + cy.get('button[data-event="toggleDrawer"]').click() + cy.get('.drawer').should('have.css', 'right').and('match', /0px/) + }); + + it(`should show ${Course._resources._resourcesItems.length} items`, () => { + checkDrawerLength(4) + }); + + it('should display the correct amount of items in each tab', () => { + cy.get('button.is-selected[id="resources__show-all"]').should('exist') + + cy.get('button[id="resources__show-document"]').should('exist').click() + checkDrawerLength(1) + + cy.get('button[id="resources__show-media"]').should('exist').click() + checkDrawerLength(1) + + cy.get('button[id="resources__show-link"]').should('exist').click() + checkDrawerLength(2) + }); + + it('ahouls display the correct drawer items', () => { + cy.get('.drawer__item').each(($item, index) => { + cy.get($item).within(() => { + cy.get('.drawer__item-title').should('contain', Course._resources._resourcesItems[index].title) + cy.get('.drawer__item-body').should('contain', Course._resources._resourcesItems[index].description) + cy.get('a').should('have.attr', 'target', '_blank').should('have.attr', 'href', Course._resources._resourcesItems[index]._link) + }) + }) + }); + + it('should be able to close the drawer by clicking X', () => { + cy.get('button.drawer__close-btn').click() + + cy.get('.drawer').should('have.attr', 'aria-expanded', 'false') + }); + + it('should be able to close the drawer by hitting ESC', () => { + cy.get('.drawer').type('{esc}') + + cy.get('.drawer').should('have.attr', 'aria-expanded', 'false') + }); + }); + \ No newline at end of file From b7e463289c26a79ceecfc67bcc1579563ac1601a Mon Sep 17 00:00:00 2001 From: Lemmy Adams Date: Fri, 6 Oct 2023 14:08:57 +0100 Subject: [PATCH 2/3] View button more specific --- test/e2e/extensions/drawer.cy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/extensions/drawer.cy.js b/test/e2e/extensions/drawer.cy.js index ba5c271af..c1852cc6e 100644 --- a/test/e2e/extensions/drawer.cy.js +++ b/test/e2e/extensions/drawer.cy.js @@ -16,7 +16,7 @@ describe('Drawer', () => { it('should appear on the right hand side in course view', () => { cy.get('button.drawer__close-btn').click() - cy.get('button').contains('View').first().click() + cy.get('.menu-item .menu-item__button-container button').contains('View').first().click() cy.get('button[data-event="toggleDrawer"]').click() cy.get('.drawer').should('have.css', 'right').and('match', /0px/) }); From a6acf9b66e3df62158ec3e377b70f224559eda41 Mon Sep 17 00:00:00 2001 From: Lemmy Adams Date: Fri, 6 Oct 2023 14:18:37 +0100 Subject: [PATCH 3/3] type --- test/e2e/extensions/drawer.cy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/extensions/drawer.cy.js b/test/e2e/extensions/drawer.cy.js index c1852cc6e..a2931ed87 100644 --- a/test/e2e/extensions/drawer.cy.js +++ b/test/e2e/extensions/drawer.cy.js @@ -38,7 +38,7 @@ describe('Drawer', () => { checkDrawerLength(2) }); - it('ahouls display the correct drawer items', () => { + it('should display the correct drawer items', () => { cy.get('.drawer__item').each(($item, index) => { cy.get($item).within(() => { cy.get('.drawer__item-title').should('contain', Course._resources._resourcesItems[index].title)