|
| 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('app-button-labs po-button').first().find('button.po-button').should('be.visible'); |
| 9 | + }); |
| 10 | + |
| 11 | + it('deve iniciar com kind secondary', () => { |
| 12 | + cy.get('app-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('app-button-labs form').should('exist'); |
| 17 | + }); |
| 18 | + |
| 19 | + it('deve exibir o campo de input para Label', () => { |
| 20 | + cy.get('app-button-labs po-input').should('exist'); |
| 21 | + }); |
| 22 | + |
| 23 | + it('deve exibir o checkbox group de Properties', () => { |
| 24 | + cy.get('app-button-labs po-checkbox-group').should('exist'); |
| 25 | + }); |
| 26 | + |
| 27 | + it('deve exibir os radio groups de configuração', () => { |
| 28 | + cy.get('app-button-labs po-radio-group').should('have.length', 4); |
| 29 | + }); |
| 30 | + |
| 31 | + it('deve exibir o botão Sample Restore', () => { |
| 32 | + cy.get('app-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('app-button-labs po-input input').clear().type('Meu Botão'); |
| 39 | + cy.get('app-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('app-button-labs po-checkbox-group').contains('Disabled').click(); |
| 46 | + cy.get('app-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('app-button-labs po-checkbox-group').contains('Loading').click(); |
| 53 | + cy.get('app-button-labs po-button').first().find('button.po-button').should('be.disabled'); |
| 54 | + cy.get('app-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('app-button-labs po-checkbox-group').contains('Danger').click(); |
| 61 | + cy.get('app-button-labs po-button').first().should('have.attr', 'p-danger', 'true'); |
| 62 | + }); |
| 63 | + }); |
| 64 | + |
| 65 | + describe('Alteração de Kind', () => { |
| 66 | + it('deve alterar o kind para primary', () => { |
| 67 | + cy.get('app-button-labs po-radio-group[name="kind"]').contains('primary').click(); |
| 68 | + cy.get('app-button-labs po-button').first().should('have.attr', 'p-kind', 'primary'); |
| 69 | + }); |
| 70 | + |
| 71 | + it('deve alterar o kind para tertiary', () => { |
| 72 | + cy.get('app-button-labs po-radio-group[name="kind"]').contains('tertiary').click(); |
| 73 | + cy.get('app-button-labs po-button').first().should('have.attr', 'p-kind', 'tertiary'); |
| 74 | + }); |
| 75 | + }); |
| 76 | + |
| 77 | + describe('Alteração de Size', () => { |
| 78 | + it('deve alterar o tamanho para large', () => { |
| 79 | + cy.get('app-button-labs po-radio-group[name="size"]').contains('large').click(); |
| 80 | + cy.get('app-button-labs po-button').first().find('button.po-button').should('have.class', 'po-button-large'); |
| 81 | + }); |
| 82 | + }); |
| 83 | + |
| 84 | + describe('Botão Click', () => { |
| 85 | + it('deve exibir um diálogo ao clicar no botão principal', () => { |
| 86 | + cy.get('app-button-labs po-button').first().find('button.po-button').click(); |
| 87 | + cy.get('po-modal').should('be.visible'); |
| 88 | + cy.get('po-modal').should('contain.text', 'Hello PO World!!!'); |
| 89 | + }); |
| 90 | + }); |
| 91 | + |
| 92 | + describe('Restore', () => { |
| 93 | + it('deve restaurar o estado inicial ao clicar em Sample Restore', () => { |
| 94 | + // Altera o label |
| 95 | + cy.get('app-button-labs po-input input').clear().type('Teste'); |
| 96 | + cy.get('app-button-labs po-button').first().find('.po-button-label').should('contain.text', 'Teste'); |
| 97 | + |
| 98 | + // Clica em restaurar |
| 99 | + cy.get('app-button-labs po-button').last().find('button.po-button').click(); |
| 100 | + |
| 101 | + // Verifica que o kind voltou para secondary |
| 102 | + cy.get('app-button-labs po-button').first().should('have.attr', 'p-kind', 'secondary'); |
| 103 | + }); |
| 104 | + }); |
| 105 | +}); |
0 commit comments