export class List { constructor(private selector: string) {} /** * * Select option by index * */ selectOption(index: number) { return this.options.eq(index).click(); } /** * * Assert that a specific option is checked * */ shouldBeChecked(index: number) { return this.getCheckbox(index).should('have.class', 'checked'); } /** * * Assert that a specific option is not checked * * */ shouldNotBeChecked(index: number) { this.getCheckbox(index).should('not.have.class', 'checked'); } /** * * Assert checked count * */ assertChecked(length: number) { return this.options.find('dato-checkbox .checked').should('have.length', length); } /** * * Click on select all checkbox * */ selectAll() { return this._selectAllContainer.click(); } /** * * Get all the options * */ get options() { return cy.get(this.selector).find('dato-option-v2'); } /** * * Get the visible options * */ get visibleOptions() { return cy .get(this.selector) .find('dato-option-v2') .filter((i, $ele) => $ele.classList.contains('force-hide') === false); } /** * * Get the checkbox by index * */ getCheckbox(index: number) { return this.options.eq(index).find('dato-checkbox .checkmark'); } selectAllChecked() { return this._selectAllContainer.find('.checked').should('be.visible'); } /** * * @internal * * Get select all container * */ get _selectAllContainer() { return cy.get(this.selector).find('dato-list-select-all .select-all'); } /** * * @internal * */ _assertSelectAllLabel(label: string) { return this._selectAllContainer.should('contain.text', label); } /** * * @internal * */ _getGroup(index: number) { return cy .get(this.selector) .find(`.dato-select__group`) .eq(index); } }