diff --git a/cypress/e2e/nova-emenda/nova-emenda-mpv-885.cy.ts b/cypress/e2e/nova-emenda/nova-emenda-mpv-885.cy.ts new file mode 100644 index 00000000..7b1261d5 --- /dev/null +++ b/cypress/e2e/nova-emenda/nova-emenda-mpv-885.cy.ts @@ -0,0 +1,100 @@ +describe('Emenda para MPV 885', () => { + it('Emenda padrão - inclusão e numeração de dispositivo', () => { + cy.novaEmenda({ + projetoNormaSelectValue: 'mpv_885_2019', + modoEmendaSelectValue: 'emenda', + }); + + cy.checarEstadoInicialAoCriarNovaEmendaPadrao({ nomeProposicao: 'MPV 885/2019', totalElementos: 66 }); + + // adicionando e numerando artigo de alteração de norma + cy.getContainerArtigoNormaByNumero(1).click().selecionarOpcaoDeMenuDoDispositivo('Adicionar artigo depois'); + + cy.get('#lxEtaId87 > .container__linha > .container__texto > .texto__rotulo').click(); + cy.get('sl-input').shadow().find('div.form-control.form-control--medium.form-control--has-label.form-control--has-help-text').find('div.form-control-input').type('1-A'); + cy.get('sl-dialog > [variant="primary"]').click(); + + const textoArtigo = 'Texto do novo artigo de alteração de norma:'; + cy.get('div.container__elemento.dispositivo--adicionado') + .as('container') + .should('have.length', 1) + .alterarTextoDoDispositivo(textoArtigo) + .wait(Cypress.config('isInteractive') ? 1000 : 2000) + .then(() => cy.get('@container').contains(textoArtigo)); + + cy.checarComandoEmenda(); + cy.checarTextoPresenteEmComandoEmenda(textoArtigo); + + // adicionando e numerando parágrafo de alteração de norma + cy.getContainerArtigoNormaByRotulo('Art. 1º-A').click().selecionarOpcaoDeMenuDoDispositivo('Adicionar parágrafo'); + + cy.get('#lxEtaId88 > :nth-child(1) > .container__texto > .texto__rotulo').click(); + cy.get('sl-input').shadow().find('div.form-control.form-control--medium.form-control--has-label.form-control--has-help-text').find('div.form-control-input').type('unico'); + cy.get('sl-dialog > [variant="primary"]').click(); + + const textoParagrafo = 'Texto do novo parágrafo de alteração de norma:'; + cy.get('div.container__elemento.dispositivo--adicionado') + .as('container') + .should('have.length', 2) + .alterarTextoDoDispositivo(textoParagrafo) + .wait(Cypress.config('isInteractive') ? 1000 : 2000) + .then(() => cy.get('@container').contains(textoParagrafo)); + + cy.checarComandoEmenda(); + cy.checarTextoPresenteEmComandoEmenda(textoParagrafo); + + // adicionando e numerando inciso de alteração de norma + cy.getContainerParagrafoNormaByRotulo('Parágrafo único').click().selecionarOpcaoDeMenuDoDispositivo('Adicionar inciso'); + + cy.get('#lxEtaId89 > :nth-child(1) > .container__texto > .texto__rotulo').click(); + cy.get('sl-input').shadow().find('div.form-control.form-control--medium.form-control--has-label.form-control--has-help-text').find('div.form-control-input').type('I'); + cy.get('sl-dialog > [variant="primary"]').click(); + + const textoInciso = 'texto do novo inciso de alteração de norma:'; + cy.get('div.container__elemento.dispositivo--adicionado') + .as('container') + .should('have.length', 3) + .alterarTextoDoDispositivo(textoInciso) + .wait(Cypress.config('isInteractive') ? 1000 : 2000) + .then(() => cy.get('@container').contains(textoInciso)); + + cy.checarComandoEmenda(); + cy.checarTextoPresenteEmComandoEmenda(textoInciso); + + // adicionando e numerando alínea de alteração de norma + cy.getContainerIncisoNormaByRotulo('I').click().selecionarOpcaoDeMenuDoDispositivo('Adicionar alínea'); + + cy.get('#lxEtaId90 > :nth-child(1) > .container__texto > .texto__rotulo').click(); + cy.get('sl-input').shadow().find('div.form-control.form-control--medium.form-control--has-label.form-control--has-help-text').find('div.form-control-input').type('a'); + cy.get('sl-dialog > [variant="primary"]').click(); + + const textoAlinea = 'texto da nova alínea de alteração de norma:'; + cy.get('div.container__elemento.dispositivo--adicionado') + .as('container') + .should('have.length', 4) + .alterarTextoDoDispositivo(textoAlinea) + .wait(Cypress.config('isInteractive') ? 1000 : 2000) + .then(() => cy.get('@container').contains(textoAlinea)); + + cy.checarComandoEmenda(); + cy.checarTextoPresenteEmComandoEmenda(textoAlinea); + + // adicionando e numerando alínea de alteração de norma + cy.getContainerAlineaNormaByRotulo('a').click().selecionarOpcaoDeMenuDoDispositivo('Adicionar item'); + + cy.get('#lxEtaId91 > :nth-child(1) > .container__texto > .texto__rotulo').click(); + cy.get('sl-input').shadow().find('div.form-control.form-control--medium.form-control--has-label.form-control--has-help-text').find('div.form-control-input').type('1'); + cy.get('sl-dialog > [variant="primary"]').click(); + + const textoItem = 'texto do novo item de alteração de norma.'; + cy.get('div.container__elemento.dispositivo--adicionado') + .as('container') + .should('have.length', 5) + .alterarTextoDoDispositivo(textoItem) + .wait(Cypress.config('isInteractive') ? 1000 : 2000) + .then(() => cy.get('@container').contains(textoItem)); + + cy.checarComandoEmenda(); + cy.checarTextoPresenteEmComandoEmenda(textoItem); + }); +}); diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 471500ed..75f2ae4c 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -110,11 +110,47 @@ Cypress.Commands.add('getContainerArtigoByNumero', (numero: number): Cypress.Cha }); }); +Cypress.Commands.add('getContainerArtigoNormaByNumero', (numero: number): Cypress.Chainable> => { + return cy.get('div.container__elemento.elemento-tipo-artigo div.container__texto--nivel1 label').then($labels => { + const regex = new RegExp(`^Art\\. ${numero}(\\.|º)$`); + const $matchingLabel = $labels.filter((index, label) => regex.test(label.textContent || '')); // Filtra os labels que correspondem ao número do artigo + if ($matchingLabel.length) { + return cy.wrap($matchingLabel).closest('div.container__elemento.elemento-tipo-artigo'); + } else { + return cy.wrap(Cypress.$()); // Retorna um objeto jQuery vazio dentro de um Chainable + } + }); +}); + Cypress.Commands.add('getContainerArtigoByRotulo', (rotulo: string): Cypress.Chainable> => { const regex = new RegExp(`${rotulo}`); return cy.get('div.container__elemento.elemento-tipo-artigo div.container__texto--nivel0 label').contains(regex).first().closest('div.container__elemento.elemento-tipo-artigo'); }); +Cypress.Commands.add('getContainerArtigoNormaByRotulo', (rotulo: string): Cypress.Chainable> => { + const regex = new RegExp(`${rotulo}`); + return cy.get('div.container__elemento.elemento-tipo-artigo div.container__texto--nivel1 label').contains(regex).first().closest('div.container__elemento.elemento-tipo-artigo'); +}); + +Cypress.Commands.add('getContainerParagrafoNormaByRotulo', (rotulo: string): Cypress.Chainable> => { + const regex = new RegExp(`${rotulo}`); + return cy + .get('div.container__elemento.elemento-tipo-paragrafo div.container__texto--nivel2 label') + .contains(regex) + .first() + .closest('div.container__elemento.elemento-tipo-paragrafo'); +}); + +Cypress.Commands.add('getContainerIncisoNormaByRotulo', (rotulo: string): Cypress.Chainable> => { + const regex = new RegExp(`${rotulo}`); + return cy.get('div.container__elemento.elemento-tipo-inciso div.container__texto--nivel3 label').contains(regex).first().closest('div.container__elemento.elemento-tipo-inciso'); +}); + +Cypress.Commands.add('getContainerAlineaNormaByRotulo', (rotulo: string): Cypress.Chainable> => { + const regex = new RegExp(`${rotulo}`); + return cy.get('div.container__elemento.elemento-tipo-alinea div.container__texto--nivel4 label').contains(regex).first().closest('div.container__elemento.elemento-tipo-alinea'); +}); + Cypress.Commands.add('selecionarOpcaoDeMenuDoDispositivo', { prevSubject: 'element' }, (subject: JQuery, opcaoDeMenu: string): void => { cy.wrap(subject).click().find('div.container__menu > sl-dropdown').click().find('sl-menu > sl-menu-item').contains(opcaoDeMenu).click(); }); @@ -474,7 +510,12 @@ declare global { checarTextoPresenteEmComandoEmenda(texto: string): void; checarDadosAposAbrirEmenda(payload: ChecarDadosAposAbrirEmendaPayloadCypress): Chainable; getContainerArtigoByNumero(numero: number): Cypress.Chainable>; + getContainerArtigoNormaByNumero(numero: number): Cypress.Chainable>; getContainerArtigoByRotulo(rotulo: string): Cypress.Chainable>; + getContainerArtigoNormaByRotulo(rotulo: string): Cypress.Chainable>; + getContainerParagrafoNormaByRotulo(rotulo: string): Cypress.Chainable>; + getContainerIncisoNormaByRotulo(rotulo: string): Cypress.Chainable>; + getContainerAlineaNormaByRotulo(rotulo: string): Cypress.Chainable>; focusOnConteudo(): Cypress.Chainable>; selecionarOpcaoDeMenuDoDispositivo(opcaoDeMenu: string): void; getOpcoesDeMenuDoDispositivo(): Cypress.Chainable>;