|
| 1 | +describe('PO Button Labs Sample', () => { |
| 2 | + beforeEach(() => { |
| 3 | + cy.visit('/button/labs'); |
| 4 | + }); |
| 5 | + |
| 6 | + describe('Estado inicial', () => { |
| 7 | + it('deve renderizar o botão principal', () => { |
| 8 | + cy.get('sample-po-button-labs po-button').first().find('button.po-button').should('be.visible'); |
| 9 | + }); |
| 10 | + |
| 11 | + it('deve iniciar com kind secondary', () => { |
| 12 | + cy.get('sample-po-button-labs po-button').first().should('have.attr', 'p-kind', 'secondary'); |
| 13 | + }); |
| 14 | + |
| 15 | + it('deve renderizar o formulário de configuração', () => { |
| 16 | + cy.get('sample-po-button-labs form').should('exist'); |
| 17 | + }); |
| 18 | + |
| 19 | + it('deve exibir o campo de input para Label', () => { |
| 20 | + cy.get('sample-po-button-labs po-input').should('exist'); |
| 21 | + }); |
| 22 | + |
| 23 | + it('deve exibir o checkbox group de Properties', () => { |
| 24 | + cy.get('sample-po-button-labs po-checkbox-group').should('exist'); |
| 25 | + }); |
| 26 | + |
| 27 | + it('deve exibir os radio groups de configuração', () => { |
| 28 | + cy.get('sample-po-button-labs po-radio-group').should('have.length', 4); |
| 29 | + }); |
| 30 | + |
| 31 | + it('deve exibir o botão Sample Restore', () => { |
| 32 | + cy.get('sample-po-button-labs po-button').last().find('.po-button-label').should('contain.text', 'Sample Restore'); |
| 33 | + }); |
| 34 | + }); |
| 35 | + |
| 36 | + describe('Alteração de Label', () => { |
| 37 | + it('deve atualizar o label do botão ao digitar no campo Label', () => { |
| 38 | + cy.get('sample-po-button-labs po-input input').clear().type('Meu Botão'); |
| 39 | + cy.get('sample-po-button-labs po-button').first().find('.po-button-label').should('contain.text', 'Meu Botão'); |
| 40 | + }); |
| 41 | + }); |
| 42 | + |
| 43 | + describe('Propriedade Disabled', () => { |
| 44 | + it('deve desabilitar o botão ao marcar a opção Disabled', () => { |
| 45 | + cy.get('sample-po-button-labs po-checkbox-group').contains('Disabled').click(); |
| 46 | + cy.get('sample-po-button-labs po-button').first().find('button.po-button').should('be.disabled'); |
| 47 | + }); |
| 48 | + }); |
| 49 | + |
| 50 | + describe('Propriedade Loading', () => { |
| 51 | + it('deve exibir o ícone de loading ao marcar a opção Loading', () => { |
| 52 | + cy.get('sample-po-button-labs po-checkbox-group').contains('Loading').click(); |
| 53 | + cy.get('sample-po-button-labs po-button').first().find('button.po-button').should('be.disabled'); |
| 54 | + cy.get('sample-po-button-labs po-button').first().find('.po-button-loading-icon').should('exist'); |
| 55 | + }); |
| 56 | + }); |
| 57 | + |
| 58 | + describe('Propriedade Danger', () => { |
| 59 | + it('deve aplicar o atributo danger ao marcar a opção Danger', () => { |
| 60 | + cy.get('sample-po-button-labs po-checkbox-group').contains('Danger').click(); |
| 61 | + cy.get('sample-po-button-labs po-button').first().should('have.attr', 'p-danger', 'true'); |
| 62 | + }); |
| 63 | + }); |
| 64 | + |
| 65 | + describe('Alteração de Icon', () => { |
| 66 | + it('deve aplicar o ícone an an-newspaper ao botão', () => { |
| 67 | + cy.get('sample-po-button-labs po-radio-group[name="icon"]').contains('an an-newspaper').click(); |
| 68 | + cy.get('sample-po-button-labs po-button').first().find('po-icon.po-button-icon').should('exist'); |
| 69 | + cy.get('sample-po-button-labs po-button').first().find('po-icon i.an-newspaper').should('exist'); |
| 70 | + }); |
| 71 | + |
| 72 | + it('deve aplicar o ícone an an-calendar-dots ao botão', () => { |
| 73 | + cy.get('sample-po-button-labs po-radio-group[name="icon"]').contains('an an-calendar-dots').click(); |
| 74 | + cy.get('sample-po-button-labs po-button').first().find('po-icon i.an-calendar-dots').should('exist'); |
| 75 | + }); |
| 76 | + |
| 77 | + it('deve aplicar o ícone an an-user ao botão', () => { |
| 78 | + cy.get('sample-po-button-labs po-radio-group[name="icon"]').contains('an an-user').click(); |
| 79 | + cy.get('sample-po-button-labs po-button').first().find('po-icon i.an-user').should('exist'); |
| 80 | + }); |
| 81 | + |
| 82 | + it('deve aplicar o ícone fa fa-podcast ao botão', () => { |
| 83 | + cy.get('sample-po-button-labs po-radio-group[name="icon"]').contains('fa fa-podcast').click(); |
| 84 | + cy.get('sample-po-button-labs po-button').first().find('po-icon i.fa-podcast').should('exist'); |
| 85 | + }); |
| 86 | + }); |
| 87 | + |
| 88 | + describe('Alteração de Kind', () => { |
| 89 | + it('deve alterar o kind para primary', () => { |
| 90 | + cy.get('sample-po-button-labs po-radio-group[name="kind"]').contains('primary').click(); |
| 91 | + cy.get('sample-po-button-labs po-button').first().should('have.attr', 'p-kind', 'primary'); |
| 92 | + }); |
| 93 | + |
| 94 | + it('deve alterar o kind para tertiary', () => { |
| 95 | + cy.get('sample-po-button-labs po-radio-group[name="kind"]').contains('tertiary').click(); |
| 96 | + cy.get('sample-po-button-labs po-button').first().should('have.attr', 'p-kind', 'tertiary'); |
| 97 | + }); |
| 98 | + }); |
| 99 | + |
| 100 | + describe('Alteração de Type', () => { |
| 101 | + it('deve alterar o type para submit', () => { |
| 102 | + cy.get('sample-po-button-labs po-radio-group[name="type"]').contains('submit').click(); |
| 103 | + cy.get('sample-po-button-labs po-button').first().find('button.po-button').should('have.attr', 'type', 'submit'); |
| 104 | + }); |
| 105 | + |
| 106 | + it('deve alterar o type para reset', () => { |
| 107 | + cy.get('sample-po-button-labs po-radio-group[name="type"]').contains('reset').click(); |
| 108 | + cy.get('sample-po-button-labs po-button').first().find('button.po-button').should('have.attr', 'type', 'reset'); |
| 109 | + }); |
| 110 | + }); |
| 111 | + |
| 112 | + describe('Alteração de Size', () => { |
| 113 | + it('deve alterar o tamanho para large', () => { |
| 114 | + cy.get('sample-po-button-labs po-radio-group[name="size"]').contains('large').click(); |
| 115 | + cy.get('sample-po-button-labs po-button').first().find('button.po-button').should('have.class', 'po-button-large'); |
| 116 | + }); |
| 117 | + |
| 118 | + it('deve alterar o tamanho de large para medium', () => { |
| 119 | + // Muda para large primeiro |
| 120 | + cy.get('sample-po-button-labs po-radio-group[name="size"]').contains('large').click(); |
| 121 | + cy.get('sample-po-button-labs po-button').first().find('button.po-button').should('have.class', 'po-button-large'); |
| 122 | + |
| 123 | + // Volta para medium |
| 124 | + cy.get('sample-po-button-labs po-radio-group[name="size"]').contains('medium').click(); |
| 125 | + cy.get('sample-po-button-labs po-button').first().find('button.po-button').should('not.have.class', 'po-button-large'); |
| 126 | + }); |
| 127 | + }); |
| 128 | + |
| 129 | + describe('Interação Danger e Kind Tertiary', () => { |
| 130 | + it('deve desabilitar a opção Danger ao selecionar kind tertiary', () => { |
| 131 | + cy.get('sample-po-button-labs po-radio-group[name="kind"]').contains('tertiary').click(); |
| 132 | + // Quando kind é tertiary, a opção Danger fica desabilitada |
| 133 | + cy.get('sample-po-button-labs po-checkbox-group po-checkbox').last().find('span.po-checkbox').should('have.attr', 'aria-disabled', 'true'); |
| 134 | + }); |
| 135 | + |
| 136 | + it('deve desabilitar a opção tertiary ao marcar Danger', () => { |
| 137 | + cy.get('sample-po-button-labs po-checkbox-group').contains('Danger').click(); |
| 138 | + cy.get('sample-po-button-labs po-radio-group[name="kind"]').find('po-radio').last().find('input').should('be.disabled'); |
| 139 | + }); |
| 140 | + }); |
| 141 | + |
| 142 | + describe('Botão Click', () => { |
| 143 | + it('deve exibir um diálogo ao clicar no botão principal', () => { |
| 144 | + cy.get('sample-po-button-labs po-button').first().find('button.po-button').click(); |
| 145 | + cy.get('po-modal').should('be.visible'); |
| 146 | + cy.get('po-modal').should('contain.text', 'Hello PO World!!!'); |
| 147 | + }); |
| 148 | + }); |
| 149 | + |
| 150 | + describe('Restore', () => { |
| 151 | + it('deve restaurar o estado inicial completo ao clicar em Sample Restore', () => { |
| 152 | + // Altera várias propriedades |
| 153 | + cy.get('sample-po-button-labs po-input input').clear().type('Teste'); |
| 154 | + cy.get('sample-po-button-labs po-radio-group[name="kind"]').contains('primary').click(); |
| 155 | + cy.get('sample-po-button-labs po-radio-group[name="size"]').contains('large').click(); |
| 156 | + cy.get('sample-po-button-labs po-radio-group[name="icon"]').contains('an an-user').click(); |
| 157 | + cy.get('sample-po-button-labs po-checkbox-group').contains('Disabled').click(); |
| 158 | + |
| 159 | + // Clica em restaurar |
| 160 | + cy.get('sample-po-button-labs po-button').last().find('button.po-button').click(); |
| 161 | + |
| 162 | + // Verifica que tudo voltou ao estado inicial |
| 163 | + cy.get('sample-po-button-labs po-button').first().should('have.attr', 'p-kind', 'secondary'); |
| 164 | + cy.get('sample-po-button-labs po-button').first().find('button.po-button').should('not.be.disabled'); |
| 165 | + cy.get('sample-po-button-labs po-button').first().find('button.po-button').should('not.have.class', 'po-button-large'); |
| 166 | + cy.get('sample-po-button-labs po-button').first().find('po-icon').should('not.exist'); |
| 167 | + }); |
| 168 | + }); |
| 169 | +}); |
0 commit comments