Skip to content

Commit

Permalink
add cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tonymin committed Apr 9, 2023
1 parent c8291bc commit 2609ad1
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 0 deletions.
60 changes: 60 additions & 0 deletions cypress/e2e/astar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/// <reference types="Cypress" />

// 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 ==== */
});
})



51 changes: 51 additions & 0 deletions cypress/e2e/heap.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/// <reference types="Cypress" />

// 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 ==== */
});
})



32 changes: 32 additions & 0 deletions cypress/e2e/sort.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/// <reference types="Cypress" />

// 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 ==== */
});

})



0 comments on commit 2609ad1

Please sign in to comment.