Skip to content

Commit

Permalink
refactor: optimize the performance of testing virtual scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
nivallore committed Nov 20, 2023
1 parent 30f3be4 commit 5e95836
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions cypress/e2e/virtual-scroll.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,44 @@ describe('Virtual scroll with custom select option style', () => {
cy.get(button).find('.filter-option-inner-inner')
.should('contain', firstSelectOptionText);

// test the first 50 options
const n = 20;
const typeOptions = {
// Delay after each keypress (Default: 10)
delay: 0,
};

// Test the first n options.
{
let n = 50;
let iterator = testArray.entries();
cy.get(button).click();
while (n--) {

for (let i = 1; i <= n; i++) {
const [, { text }] = iterator.next().value;
cy.get('li').contains(text)
.should('have.class', 'active');
dropdownMenu.type('{downArrow}');

// Sampling (testing every 5 typing actions)
if (i % 5 === 0) {
cy.get('li').contains(text)
.should('have.class', 'active');
}
dropdownMenu.type('{downArrow}', typeOptions);
}
cy.get(button).click();
}

// test the last 50 options
// Test the last n select options.
{
let n = 50;
let iterator = Array.from(testArray).reverse().entries();
cy.get(button).click();
while (n--) {

for (let i = 1; i <= n; i++) {
const [, { text }] = iterator.next().value;
dropdownMenu.type('{upArrow}');
cy.get('li').contains(text)
.should('have.class', 'active');
dropdownMenu.type('{upArrow}', typeOptions);

// Sampling (testing every 5 typing actions)
if (i % 5 === 0) {
cy.get('li').contains(text)
.should('have.class', 'active');
}
}
cy.get(button).click();
}
Expand Down

0 comments on commit 5e95836

Please sign in to comment.