From 2609ad14185b011bc3672f5a4471d92e01196fd6 Mon Sep 17 00:00:00 2001 From: Chunlin Min Date: Sun, 9 Apr 2023 19:03:46 -0400 Subject: [PATCH] add cypress tests --- cypress/e2e/astar.js | 60 ++++++++++++++++++++++++++++++++++++++++++ cypress/e2e/heap.cy.js | 51 +++++++++++++++++++++++++++++++++++ cypress/e2e/sort.cy.js | 32 ++++++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 cypress/e2e/astar.js create mode 100644 cypress/e2e/heap.cy.js create mode 100644 cypress/e2e/sort.cy.js diff --git a/cypress/e2e/astar.js b/cypress/e2e/astar.js new file mode 100644 index 0000000..ccb5d03 --- /dev/null +++ b/cypress/e2e/astar.js @@ -0,0 +1,60 @@ +/// + +// test suite +describe('Astar page', () => { + beforeEach(()=>{ + cy.visit('https://jxr98.github.io/AlgoVisualizer/') + cy.get('#graphNav > .nav-link').click(); + cy.get(':nth-child(4) > .dropdown-item').click(); + }) + + /* ==== Test Created with Cypress Studio ==== */ + it('no obstacle search', function() { + /* ==== Generated with Cypress Studio ==== */ + cy.get('#srcX').clear('0'); + cy.get('#srcX').type('0'); + cy.get('#srcY').clear('0'); + cy.get('#srcY').type('0'); + cy.get('#dstX').clear('7'); + cy.get('#dstX').type('7'); + cy.get('#dstY').clear('7'); + cy.get('#dstY').type('7'); + cy.get('#start-button').click(); + /* ==== End Cypress Studio ==== */ + }); + + /* ==== Test Created with Cypress Studio ==== */ + it('error input', function() { + /* ==== Generated with Cypress Studio ==== */ + cy.get('#start-button').click(); + cy.get('#srcXFeedback').should('have.text', 'Empty input'); + cy.get('#dstXFeedback').should('have.text', 'Empty input'); + cy.get('#srcYFeedback').should('have.text', 'Empty input'); + cy.get('#dstYFeedback').should('have.text', 'Empty input'); + cy.get('#srcX').clear('-4'); + cy.get('#srcX').type('-4'); + cy.get('#start-button').click(); + cy.get('#srcY').clear('-6'); + cy.get('#srcY').type('-6'); + cy.get('#start-button').click(); + cy.get('#srcXFeedback').should('have.text', 'invalid x value'); + cy.get('#srcYFeedback').should('have.text', 'invalid y value'); + /* ==== End Cypress Studio ==== */ + }); + + /* ==== Test Created with Cypress Studio ==== */ + it('input on obstacle', function() { + /* ==== Generated with Cypress Studio ==== */ + cy.get('#c0').click(); + cy.get('#srcX').clear('0'); + cy.get('#srcX').type('0'); + cy.get('#srcY').clear('0'); + cy.get('#srcY').type('0'); + cy.get('#start-button').click(); + cy.get('#srcXFeedback').should('have.text', 'coordinate occupied by obstacle'); + /* ==== End Cypress Studio ==== */ + }); +}) + + + \ No newline at end of file diff --git a/cypress/e2e/heap.cy.js b/cypress/e2e/heap.cy.js new file mode 100644 index 0000000..3bbfdcd --- /dev/null +++ b/cypress/e2e/heap.cy.js @@ -0,0 +1,51 @@ +/// + +// test suite +describe('heap page', () => { + beforeEach(()=>{ + cy.visit('https://jxr98.github.io/AlgoVisualizer/') + cy.get('#treeNav > .nav-link').click(); + cy.get('#treeNav > .dropdown-menu > li > .dropdown-item').click(); + }) + + + it('maxheap', function() { + /* ==== Generated with Cypress Studio ==== */ + cy.get('#message-box').click(); + cy.get('#create-tree > h2').click(); + cy.get('#max-heap').click(); + /* ==== End Cypress Studio ==== */ + /* ==== Generated with Cypress Studio ==== */ + cy.get('#message-box').click(); + cy.get('#create-tree > h2').click(); + cy.get('#max-heap').click(); + /* ==== End Cypress Studio ==== */ + }); + + /* ==== Test Created with Cypress Studio ==== */ + it('empty input', function() { + /* ==== Generated with Cypress Studio ==== */ + cy.get('#max-heap').click(); + cy.get('#logPanel').should('have.value', '// Logs:\nplease check input data'); + /* ==== End Cypress Studio ==== */ + }); + + /* ==== Test Created with Cypress Studio ==== */ + it('bad input', function() { + /* ==== Generated with Cypress Studio ==== */ + cy.get('#message-box').click(); + cy.get('#min-heap').click(); + cy.get('#logPanel').should('have.value', '// Logs:\nplease check input data'); + /* ==== End Cypress Studio ==== */ + }); + + /* ==== Test Created with Cypress Studio ==== */ + it('reset', function() { + /* ==== Generated with Cypress Studio ==== */ + cy.get('#reset-button').click(); + /* ==== End Cypress Studio ==== */ + }); +}) + + + \ No newline at end of file diff --git a/cypress/e2e/sort.cy.js b/cypress/e2e/sort.cy.js new file mode 100644 index 0000000..308a619 --- /dev/null +++ b/cypress/e2e/sort.cy.js @@ -0,0 +1,32 @@ +/// + +// test suite +describe('sort page', () => { + beforeEach(()=>{ + cy.visit('https://jxr98.github.io/AlgoVisualizer/') + cy.get('#sortingNav > .nav-link').click(); + cy.get('#sortingNav > .dropdown-menu > li > .dropdown-item').click(); + }) + + /* ==== Test Created with Cypress Studio ==== */ + it('speed ctrl', function() { + /* ==== Generated with Cypress Studio ==== */ + cy.get('#speedCtrl').click(); + cy.get('#speedDisplay').should('have.text', '300ms'); + /* ==== End Cypress Studio ==== */ + }); + + /* ==== Test Created with Cypress Studio ==== */ + it('error input', function() { + /* ==== Generated with Cypress Studio ==== */ + cy.get('#insertionSortArrayInput').clear('-'); + cy.get('#insertionSortArrayInput').type('-'); + cy.get('#panelsStayOpen-collapseOne > .accordion-body > h2').click(); + cy.get('#insertionSortArrayInputFeedback').should('have.text', '\n comma delimited integers only\n '); + /* ==== End Cypress Studio ==== */ + }); + +}) + + + \ No newline at end of file