Skip to content

Commit

Permalink
Implementação inicial da automação da criação e numeração de disposit…
Browse files Browse the repository at this point in the history
…ivos que alteram norma #923
  • Loading branch information
eurobertacs committed Oct 8, 2024
1 parent d586c12 commit 9305188
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 0 deletions.
100 changes: 100 additions & 0 deletions cypress/e2e/nova-emenda/nova-emenda-mpv-885.cy.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
41 changes: 41 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,47 @@ Cypress.Commands.add('getContainerArtigoByNumero', (numero: number): Cypress.Cha
});
});

Cypress.Commands.add('getContainerArtigoNormaByNumero', (numero: number): Cypress.Chainable<JQuery<HTMLElement>> => {
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<JQuery<HTMLElement>> => {
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<JQuery<HTMLElement>> => {
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<JQuery<HTMLElement>> => {
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<JQuery<HTMLElement>> => {
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<JQuery<HTMLElement>> => {
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<HTMLElement>, opcaoDeMenu: string): void => {
cy.wrap(subject).click().find('div.container__menu > sl-dropdown').click().find('sl-menu > sl-menu-item').contains(opcaoDeMenu).click();
});
Expand Down Expand Up @@ -474,7 +510,12 @@ declare global {
checarTextoPresenteEmComandoEmenda(texto: string): void;
checarDadosAposAbrirEmenda(payload: ChecarDadosAposAbrirEmendaPayloadCypress): Chainable<void>;
getContainerArtigoByNumero(numero: number): Cypress.Chainable<JQuery<HTMLElement>>;
getContainerArtigoNormaByNumero(numero: number): Cypress.Chainable<JQuery<HTMLElement>>;
getContainerArtigoByRotulo(rotulo: string): Cypress.Chainable<JQuery<HTMLElement>>;
getContainerArtigoNormaByRotulo(rotulo: string): Cypress.Chainable<JQuery<HTMLElement>>;
getContainerParagrafoNormaByRotulo(rotulo: string): Cypress.Chainable<JQuery<HTMLElement>>;
getContainerIncisoNormaByRotulo(rotulo: string): Cypress.Chainable<JQuery<HTMLElement>>;
getContainerAlineaNormaByRotulo(rotulo: string): Cypress.Chainable<JQuery<HTMLElement>>;
focusOnConteudo(): Cypress.Chainable<JQuery<HTMLElement>>;
selecionarOpcaoDeMenuDoDispositivo(opcaoDeMenu: string): void;
getOpcoesDeMenuDoDispositivo(): Cypress.Chainable<JQuery<HTMLElement>>;
Expand Down

0 comments on commit 9305188

Please sign in to comment.