-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate cypress and fix virtual scroll breaks on last chunk (#2853)
* chore: migrate cypress from 9.5.0 to 13.5.1 * chore: enable the "Run All Specs" UI feature * chore: bump cypress-io/github-action from v2 to v6 * chore: run end-to-end tests with cypress in headed mode * chore: update package scripts * fix: virtual scroll breaks on last chunk
- Loading branch information
Showing
11 changed files
with
682 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const { defineConfig } = require('cypress') | ||
|
||
module.exports = defineConfig({ | ||
e2e: { | ||
// Enables the "Run All Specs" UI feature, allowing the execution of | ||
// multiple specs sequentially. | ||
experimentalRunAllSpecs: true, | ||
// We've imported your old cypress plugins here. | ||
// You may want to clean this up later by importing these. | ||
setupNodeEvents(on, config) { | ||
return require('./cypress/plugins/index.js')(on, config) | ||
}, | ||
}, | ||
}) |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
const testArray = new Array(1000).fill(0).map((x, i) => ({ | ||
text: `Option ${i + 1}` | ||
})); | ||
|
||
const selectpickerConfigs = [{ | ||
title: 'Select option with line-height style', | ||
config: { | ||
html: ` | ||
<select class="selectpicker" data-virtual-scroll="true"> | ||
${testArray.map(({ text }) => | ||
`<option value="${text}" style="line-height: 1.6275;">${text}</option>` | ||
).join('')} | ||
</select> | ||
`, | ||
options: { | ||
virtualScroll: true | ||
} | ||
} | ||
}, { | ||
title: 'Select option with default style', | ||
config: { | ||
html: ` | ||
<select class="selectpicker" data-virtual-scroll="true"> | ||
${testArray.map(({ text }) => | ||
`<option value="${text}">${text}</option>` | ||
).join('')} | ||
</select> | ||
`, | ||
options: { | ||
virtualScroll: true | ||
} | ||
} | ||
}]; | ||
|
||
describe('Virtual scroll with custom select option style', () => { | ||
beforeEach(() => { | ||
cy.visit('/tests/index.html'); | ||
}); | ||
|
||
selectpickerConfigs.forEach(({title, config}) => { | ||
it(title, () => { | ||
cy.selectpicker(config).then(($select) => { | ||
const firstSelectOptionText = testArray.at(0).text; | ||
const lastSelectOptionText = testArray.at(-1).text; | ||
const button = `[data-id="${$select[0].id}"]`; | ||
|
||
cy.get(button).click(); | ||
const dropdownMenu = cy.get('.dropdown-menu [role="listbox"]'); | ||
|
||
dropdownMenu.type('{upArrow}'); | ||
cy.get('li').contains(lastSelectOptionText) | ||
.should('have.class', 'active'); | ||
|
||
dropdownMenu.type('{enter}'); | ||
cy.get(button).find('.filter-option-inner-inner') | ||
.should('contain', lastSelectOptionText); | ||
|
||
cy.get(button).click(); | ||
dropdownMenu.type('{downArrow}'); | ||
|
||
cy.get('li').contains(firstSelectOptionText) | ||
.should('have.class', 'active'); | ||
|
||
dropdownMenu.type('{enter}'); | ||
cy.get(button).find('.filter-option-inner-inner') | ||
.should('contain', firstSelectOptionText); | ||
|
||
const n = 20; | ||
const typeOptions = { | ||
// Delay after each keypress (Default: 10) | ||
delay: 0, | ||
}; | ||
|
||
// Test the first n options. | ||
cy.get(button).click(); | ||
|
||
for (let i = 1, iterator = testArray.entries(); i <= n; i++) { | ||
const [, { text }] = iterator.next().value; | ||
|
||
// 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 n select options. | ||
const reversedArray = Array.from(testArray).reverse(); | ||
cy.get(button).click(); | ||
|
||
for (let i = 1, iterator = reversedArray.entries(); i <= n; i++) { | ||
const [, { text }] = iterator.next().value; | ||
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(); | ||
}); | ||
}); | ||
}); | ||
}); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.