From b59bf34e62173d5a18a98efc38d88307e12bace6 Mon Sep 17 00:00:00 2001 From: "Ghislain B." Date: Tue, 10 Dec 2024 22:06:27 -0500 Subject: [PATCH] chore(vue): add more E2E tests (#1297) --- .../src/examples/slickgrid/example26.html | 86 ++++++++++--------- test/cypress/e2e/example02.cy.ts | 22 +++++ test/cypress/e2e/example26.cy.ts | 39 ++++++++- 3 files changed, 102 insertions(+), 45 deletions(-) diff --git a/packages/demo/src/examples/slickgrid/example26.html b/packages/demo/src/examples/slickgrid/example26.html index 15ddef4e6..bcd4ea6cc 100644 --- a/packages/demo/src/examples/slickgrid/example26.html +++ b/packages/demo/src/examples/slickgrid/example26.html @@ -10,54 +10,56 @@

-
- -
- -
-
- - +
+
+ +
+ +
+
+ + +
-
-
+
+
+ + +
+
+ +
- - + +
- -
-
- - -
-
-
-
- Updated Item: ${updatedObject | stringify} -
-
- ${alertWarning} +
+
+ Updated Item: ${updatedObject | stringify} +
+
+ ${alertWarning} +
diff --git a/test/cypress/e2e/example02.cy.ts b/test/cypress/e2e/example02.cy.ts index 654f3579f..1ea65d82f 100644 --- a/test/cypress/e2e/example02.cy.ts +++ b/test/cypress/e2e/example02.cy.ts @@ -1,6 +1,8 @@ import { removeExtraSpaces } from '../plugins/utilities'; describe('Example 2 - Grid with Formatters', () => { + const GRID_ROW_HEIGHT = 35; + it('should display Example title', () => { cy.visit(`${Cypress.config('baseUrl')}/example2`); cy.get('h2').should('contain', 'Example 2: Grid with Formatters'); @@ -22,4 +24,24 @@ describe('Example 2 - Grid with Formatters', () => { expect(text).to.eq('500 items'); }); }); + + it('should expect "Effort Driven" 1st cell to include fire icon', () => { + cy.get(`[style="top: ${GRID_ROW_HEIGHT * 0}px;"] > .slick-cell:nth(7)`).find('.mdi.mdi-fire.red').should('have.length', 1); + }); + + it('should expect "Effort Driven" 2nd cell to include a snowflake icon', () => { + cy.get(`[style="top: ${GRID_ROW_HEIGHT * 1}px;"] > .slick-cell:nth(7)`).find('.mdi.mdi-snowflake').should('have.length', 1); + }); + + it('should click on a "Completed" cell and expect it to toggle to checked', () => { + cy.get(`[style="top: ${GRID_ROW_HEIGHT * 0}px;"] > .slick-cell:nth(8)`).find('.mdi.mdi-circle').should('have.length', 1); + cy.get(`[style="top: ${GRID_ROW_HEIGHT * 0}px;"] > .slick-cell:nth(8)`).click(); + cy.get(`[style="top: ${GRID_ROW_HEIGHT * 0}px;"] > .slick-cell:nth(8)`).find('.mdi.mdi-circle').should('have.length', 0); + cy.get(`[style="top: ${GRID_ROW_HEIGHT * 0}px;"] > .slick-cell:nth(8)`).find('.mdi.mdi-check-circle').should('have.length', 1); + + cy.get(`[style="top: ${GRID_ROW_HEIGHT * 1}px;"] > .slick-cell:nth(8)`).find('.mdi.mdi-circle').should('have.length', 1); + cy.get(`[style="top: ${GRID_ROW_HEIGHT * 1}px;"] > .slick-cell:nth(8)`).click(); + cy.get(`[style="top: ${GRID_ROW_HEIGHT * 1}px;"] > .slick-cell:nth(8)`).find('.mdi.mdi-circle').should('have.length', 0); + cy.get(`[style="top: ${GRID_ROW_HEIGHT * 1}px;"] > .slick-cell:nth(8)`).find('.mdi.mdi-check-circle').should('have.length', 1); + }); }); diff --git a/test/cypress/e2e/example26.cy.ts b/test/cypress/e2e/example26.cy.ts index e5fe60879..caee7fe96 100644 --- a/test/cypress/e2e/example26.cy.ts +++ b/test/cypress/e2e/example26.cy.ts @@ -24,16 +24,19 @@ describe('Example 26 - Use of Aurelia Custom Elements', () => { cy.get('.slick-cell select.form-control') .select('John'); + cy.get('[data-test="auto-edit-checkbox"]') + .check(); + cy.get('.slick-row:nth(1)') .children('.slick-cell:nth(1)') .click(); cy.get('.slick-cell select.form-control') - .select('Pierre'); + .select('Paul'); }); - it('should have 2 first rows with "Assignee" of "John" (0) then "Pierre" (1)', () => { - const tasks = [['Task 0', 'John', 'John'], ['Task 1', 'Pierre', 'Pierre']]; + it('should have 2 first rows with "Assignee" of "John" (0) then "Paul" (1)', () => { + const tasks = [['Task 0', 'John', 'John'], ['Task 1', 'Paul', 'Paul']]; cy.get('#grid26') .find('.slick-row') @@ -50,4 +53,34 @@ describe('Example 26 - Use of Aurelia Custom Elements', () => { } }); }); + + it('should filter Assignee and expect only 1 row with Paul', () => { + cy.get('#grid26') + .find('.slick-headerrow-column:nth(1)') + .find('select.form-control') + .select('Paul'); + + cy.get('#grid26') + .find('.slick-row') + .children('.slick-cell:nth(1)') + .should('contain', 'Paul'); + + cy.get('#grid26') + .find('.slick-row') + .should('have.length', 1); + }); + + it('should be able to clear the filter and expect more than 1 row in the grid', () => { + cy.get('[data-test="clear-filters"]') + .click(); + + cy.get('#grid26') + .find('.slick-row') + .children('.slick-cell:nth(1)') + .should('not.contain', 'Paul'); + + cy.get('#grid26') + .find('.slick-row') + .should('have.length.greaterThan', 1); + }); });