|
| 1 | +describe('Dual List Selector deprecated With Actions Demo Test', () => { |
| 2 | + it('Navigate to demo section', () => { |
| 3 | + cy.visit('http://localhost:3000/dual-list-selector-with-actions-demo-nav-link'); |
| 4 | + }); |
| 5 | + |
| 6 | + it('Verify existence', () => { |
| 7 | + cy.get('.pf-v6-c-dual-list-selector').should('exist'); |
| 8 | + }); |
| 9 | + |
| 10 | + it('Verify default value content', () => { |
| 11 | + cy.get('.pf-v6-c-dual-list-selector__list').first().should('have.value', ''); |
| 12 | + cy.get('.pf-v6-c-dual-list-selector__list li').should('have.length', 4); |
| 13 | + }); |
| 14 | + |
| 15 | + it('Verify custom aria-labels, status, and titles', () => { |
| 16 | + cy.get('.pf-m-available .pf-v6-c-dual-list-selector__title-text').contains('Available options'); |
| 17 | + cy.get('.pf-m-available .pf-v6-c-dual-list-selector__status-text').contains('0 of 4 options selected'); |
| 18 | + cy.get('.pf-m-available .pf-v6-c-dual-list-selector__tools-filter input').should( |
| 19 | + 'have.attr', |
| 20 | + 'aria-label', |
| 21 | + 'Search input' |
| 22 | + ); |
| 23 | + cy.get('.pf-m-available .pf-v6-c-dual-list-selector__list').should('have.attr', 'aria-labelledby'); |
| 24 | + |
| 25 | + cy.get('.pf-v6-c-dual-list-selector__controls-item button').eq(1).should('have.attr', 'aria-label', 'Add all'); |
| 26 | + cy.get('.pf-v6-c-dual-list-selector__controls-item button') |
| 27 | + .eq(0) |
| 28 | + .should('have.attr', 'aria-label', 'Add selected') |
| 29 | + .and('have.attr', 'disabled'); |
| 30 | + cy.get('.pf-v6-c-dual-list-selector__controls-item button') |
| 31 | + .eq(3) |
| 32 | + .should('have.attr', 'aria-label', 'Remove selected') |
| 33 | + .and('have.attr', 'disabled'); |
| 34 | + cy.get('.pf-v6-c-dual-list-selector__controls-item button') |
| 35 | + .eq(2) |
| 36 | + .should('have.attr', 'aria-label', 'Remove all') |
| 37 | + .and('have.attr', 'disabled'); |
| 38 | + |
| 39 | + cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__title-text').contains('Chosen options'); |
| 40 | + cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__status-text').contains('0 of 0 options selected'); |
| 41 | + cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__tools-filter input').should( |
| 42 | + 'have.attr', |
| 43 | + 'aria-label', |
| 44 | + 'Search input' |
| 45 | + ); |
| 46 | + }); |
| 47 | + |
| 48 | + it('Verify selecting options', () => { |
| 49 | + cy.get('.pf-v6-c-dual-list-selector__list-item .pf-m-selected').should('not.exist'); |
| 50 | + cy.get('.pf-v6-c-dual-list-selector__list-item').eq(0).click(); |
| 51 | + cy.get('.pf-v6-c-dual-list-selector__list-item .pf-m-selected').should('exist'); |
| 52 | + cy.get('.pf-v6-c-dual-list-selector__list-item').eq(1).click(); |
| 53 | + cy.get('.pf-v6-c-dual-list-selector__list-item .pf-m-selected').should('have.length', 2); |
| 54 | + cy.get('.pf-v6-c-dual-list-selector__list-item').eq(0).click(); |
| 55 | + cy.get('.pf-v6-c-dual-list-selector__list-item .pf-m-selected').should('have.length', 1); |
| 56 | + }); |
| 57 | + |
| 58 | + it('Verify selecting and choosing options', () => { |
| 59 | + cy.get('.pf-v6-c-dual-list-selector__controls-item').eq(0).click(); |
| 60 | + cy.get('.pf-v6-c-dual-list-selector__list').eq(0).find('li').should('have.length', 3); |
| 61 | + cy.get('.pf-v6-c-dual-list-selector__list').eq(1).find('li').should('have.length', 1); |
| 62 | + cy.get('.pf-v6-c-dual-list-selector__list-item').eq(1).click(); |
| 63 | + cy.get('.pf-v6-c-dual-list-selector__controls-item').eq(0).click(); |
| 64 | + |
| 65 | + cy.get('.pf-m-available .pf-v6-c-dual-list-selector__status-text').contains('0 of 2 options selected'); |
| 66 | + cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__status-text').contains('0 of 2 options selected'); |
| 67 | + |
| 68 | + cy.get('.pf-v6-c-dual-list-selector__list').eq(0).find('li').should('have.length', 2); |
| 69 | + cy.get('.pf-v6-c-dual-list-selector__list').eq(1).find('li').should('have.length', 2); |
| 70 | + |
| 71 | + cy.get('.pf-v6-c-dual-list-selector__list-item').eq(0).click(); |
| 72 | + cy.get('.pf-m-available .pf-v6-c-dual-list-selector__status-text').contains('1 of 2 options selected'); |
| 73 | + cy.get('.pf-v6-c-dual-list-selector__list-item').eq(0).click(); |
| 74 | + }); |
| 75 | + |
| 76 | + it('Verify removing all options', () => { |
| 77 | + cy.get('.pf-v6-c-dual-list-selector__controls-item').eq(2).click(); |
| 78 | + cy.get('.pf-v6-c-dual-list-selector__menu').eq(0).find('li').should('have.length', 4); |
| 79 | + cy.get('.pf-v6-c-dual-list-selector__menu').eq(1).find('li').should('have.length', 0); |
| 80 | + cy.get('.pf-m-available .pf-v6-c-dual-list-selector__status-text').contains('0 of 4 options selected'); |
| 81 | + cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__status-text').contains('0 of 0 options selected'); |
| 82 | + }); |
| 83 | + |
| 84 | + it('Verify choosing all options', () => { |
| 85 | + cy.get('.pf-v6-c-dual-list-selector__controls-item').eq(1).click(); |
| 86 | + cy.get('.pf-v6-c-dual-list-selector__menu').eq(0).find('li').should('have.length', 0); |
| 87 | + cy.get('.pf-v6-c-dual-list-selector__menu').eq(1).find('li').should('have.length', 4); |
| 88 | + cy.get('.pf-m-available .pf-v6-c-dual-list-selector__status-text').contains('0 of 0 options selected'); |
| 89 | + cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__status-text').contains('0 of 4 options selected'); |
| 90 | + }); |
| 91 | + |
| 92 | + it('Verify sort works', () => { |
| 93 | + cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__list-item').last().contains('Option 4'); |
| 94 | + cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__tools-actions button').first().click(); |
| 95 | + cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__list-item').last().contains('Option 1'); |
| 96 | + cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__list-item').first().contains('Option 4'); |
| 97 | + |
| 98 | + cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__tools-actions button').first().click(); |
| 99 | + cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__list-item').last().contains('Option 4'); |
| 100 | + cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__list-item').first().contains('Option 1'); |
| 101 | + }); |
| 102 | + |
| 103 | + it('Verify chosen search works', () => { |
| 104 | + cy.get('.pf-v6-c-dual-list-selector__list').eq(1).find('li').should('have.length', 4); |
| 105 | + cy.get('.pf-v6-c-dual-list-selector__tools-filter input').eq(1).type('Option 1'); |
| 106 | + cy.get('.pf-v6-c-dual-list-selector__list').eq(1).find('li').should('have.length', 1); |
| 107 | + }); |
| 108 | + |
| 109 | + it('Verify removing all options', () => { |
| 110 | + cy.get('.pf-v6-c-dual-list-selector__tools-filter input') |
| 111 | + .eq(1) |
| 112 | + .type('{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}'); |
| 113 | + cy.get('.pf-v6-c-dual-list-selector__controls-item').eq(2).click(); |
| 114 | + cy.get('.pf-v6-c-dual-list-selector__menu').eq(0).find('li').should('have.length', 4); |
| 115 | + cy.get('.pf-v6-c-dual-list-selector__menu').eq(1).find('li').should('have.length', 0); |
| 116 | + }); |
| 117 | + |
| 118 | + it('Verify available search works', () => { |
| 119 | + cy.get('.pf-v6-c-dual-list-selector__list').eq(0).find('li').should('have.length', 4); |
| 120 | + cy.get('.pf-v6-c-dual-list-selector__tools-filter input').eq(0).type('Option 3'); |
| 121 | + cy.get('.pf-v6-c-dual-list-selector__list').eq(0).find('li').should('have.length', 1); |
| 122 | + }); |
| 123 | + |
| 124 | + it('Verify adding all filtered options', () => { |
| 125 | + cy.get('.pf-v6-c-dual-list-selector__list').eq(0).find('li').should('have.length', 1); |
| 126 | + cy.get('.pf-v6-c-dual-list-selector__controls-item').eq(1).click(); |
| 127 | + cy.get('.pf-v6-c-dual-list-selector__list').eq(0).find('li').should('have.length', 0); |
| 128 | + cy.get('.pf-v6-c-dual-list-selector__list').eq(1).find('li').should('have.length', 1); |
| 129 | + cy.get('.pf-v6-c-dual-list-selector__tools-filter input') |
| 130 | + .eq(0) |
| 131 | + .type('{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}'); |
| 132 | + cy.get('.pf-v6-c-dual-list-selector__list').eq(0).find('li').should('have.length', 3); |
| 133 | + }); |
| 134 | +}); |
0 commit comments