Skip to content

Commit

Permalink
ref(in): refactor para modificacion de api de internacion (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
negro89 authored Oct 4, 2022
1 parent fd52fc5 commit 94973a4
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const moment = require('moment');

function getStubs() {
cy.route('**/internacion**/**').as('backToMapa');
cy.intercept('**/internacion**/**').as('backToMapa');

cy.route('GET', '/api/core/term/snomed/expression?expression=^2051000013106**', [{
"conceptId": "12345",
Expand Down Expand Up @@ -33,8 +31,9 @@ function getStubs() {
"semanticTag": "objeto físico"
}]).as('expEquipamiento');

cy.route('POST', '**/api/modules/rup/internacion/camas**').as('createCama')
cy.route('PATCH', '**/api/modules/rup/internacion/camas/**').as('editCama')
cy.intercept('POST', '**/api/modules/rup/internacion/camas**').as('createCama')
cy.intercept('PATCH', '**/api/modules/rup/internacion/camas/**').as('editCama')
cy.intercept('PATCH', '**/api/modules/rup/internacion/camaEstados/**').as('editCamaEstados')
}

describe('ABM Camas', () => {
Expand All @@ -54,7 +53,6 @@ describe('ABM Camas', () => {

beforeEach(() => {
cy.server();

getStubs();

cy.viewport(1920, 1080);
Expand All @@ -64,8 +62,8 @@ describe('ABM Camas', () => {

it('Alta Cama', () => {
cy.plexDropdown('label="NUEVO RECURSO"', "CAMA");

cy.plexText('label="Nombre"', 'Cama 666');
cy.plexDatetime('name="fechaDisponible"', { text: cy.today(), skipEnter: true });
cy.plexSelectAsync('label="Tipo de cama"', 'Cam', '@expTipoDeCama', 0);
cy.plexSelectAsync('label="Equipamiento"', 'sis', '@expEquipamiento', 0);
cy.plexSelectAsync('label="Especialidad/es"', 'Enf', '@expEspecialidad', 0);
Expand All @@ -74,9 +72,9 @@ describe('ABM Camas', () => {
cy.plexSelectType('label="Ubicación"', 'habi1');

cy.plexButton('GUARDAR').click();
cy.wait('@createCama').then((xhr) => {
const cama = xhr.response.body;
expect(xhr.status).to.be.eq(200);
cy.wait('@createCama').then(({response}) => {
const cama = response.body;
expect(response.statusCode).to.be.eq(200);
expect(cama.nombre).to.be.eq('Cama 666');
expect(cama.unidadOrganizativaOriginal.term).to.be.eq('servicio médico');
expect(cama.sectores[0].nombre).to.be.eq('habi1');
Expand All @@ -91,9 +89,8 @@ describe('ABM Camas', () => {
cy.get('[label="CAMA"] > plex-title > .plex-title > .title-content').plexButtonIcon('pencil').click();

cy.plexText('label="Nombre"').clear();
cy.plexText('label="Nombre"', 'Cama 888');
cy.plexText('label="Nombre"', '{selectall}{backspace}' + 'Cama 888');
cy.plexSelectAsync('label="Tipo de cama"', 'Cam', '@expTipoDeCama', 0);
//cy.plexSelectAsync('label="Especialidad/es"', 'Enf', '@expEspecialidad', 0);
cy.plexSelectAsync('label="Equipamiento"', 'ap', '@expEquipamiento', 0);
cy.plexSelectType('label="Genero"').clearSelect();
cy.plexSelectAsync('label="Genero"', 'Fem', '@expGenero', 0);
Expand All @@ -103,9 +100,9 @@ describe('ABM Camas', () => {
cy.plexSelectType('label="Unidad organizativa"', 'servicio');

cy.plexButton('GUARDAR').click();
cy.wait('@editCama').then((xhr) => {
const cama = xhr.response.body;
expect(xhr.status).to.be.eq(200);
cy.wait('@editCama').then(({response}) => {
const cama = response.body;
expect(response.statusCode).to.be.eq(200);
expect(cama.nombre).to.be.eq('Cama 888');
expect(cama.sectores[0].nombre).to.be.eq('edificio este');
expect(cama.tipoCama.term).to.be.eq('Cama');
Expand All @@ -121,8 +118,8 @@ describe('ABM Camas', () => {
cy.plexButton('INACTIVAR CAMA').click();
cy.get('button').contains('CONFIRMAR').click();

cy.wait('@editCama').then((xhr) => {
expect(xhr.status).to.be.eq(200);
cy.wait('@editCamaEstados').then(({response}) => {
expect(response.statusCode).to.be.eq(200);
});;

cy.wait(200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('Acciones sobre paciente ingresado desde capa estadistica-v2', () => {
cy.intercept('PATCH', '**/api/modules/rup/internacion/internacion-resumen/**').as('patchResumen');
cy.intercept('PATCH', '**/api/modules/rup/prestaciones/**').as('patchPrestacion');
cy.intercept('PATCH', '**/api/modules/rup/internacion/camas/**').as('patchCamas');
cy.intercept('PATCH', '**/api/modules/rup/internacion/camaEstados/**').as('patchCamaEstados');
cy.intercept('GET', '**/api/core/term/cie10?**', [{
id: '59bbf1ed53916746547cbdba',
idCie10: 1187.0,
Expand Down Expand Up @@ -93,7 +94,7 @@ describe('Acciones sobre paciente ingresado desde capa estadistica-v2', () => {
cy.plexButtonIcon('check').click();
cy.swal('confirm', 'Los datos se actualizaron correctamente');

cy.wait('@patchCamas').then(({ response }) => {
cy.wait('@patchCamaEstados').then(({ response }) => {
expect(response.statusCode).to.eq(200);
});
// verificamos sincronización entre resumen y prestación
Expand Down
20 changes: 10 additions & 10 deletions cypress/e2e/apps/rup/internacion/estadistica-v2/ingresos.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ describe('Acciones sobre paciente ingresado desde capa asistencial', () => {
cy.goto('/mapa-camas', token);

cy.server();
cy.route('GET', '**/api/modules/rup/internacion/camas?**').as('getCamas');
cy.route('GET', '**/api/modules/rup/internacion/camas/**').as('getCama');
cy.route('GET', '**/api/core/tm/profesionales**').as('getProfesionales');
cy.route('PATCH', '**/api/modules/rup/internacion/camas/**').as('patchCamas');
cy.route('PATCH', '**/api/modules/rup/internacion/internacion-resumen/**').as('patchResumen');
cy.route('POST', '**/api/modules/rup/prestaciones**').as('postPrestacion');
cy.intercept('GET', '**/api/modules/rup/internacion/camas?**').as('getCamas');
cy.intercept('GET', '**/api/modules/rup/internacion/camas/**').as('getCama');
cy.intercept('GET', '**/api/core/tm/profesionales**').as('getProfesionales');
cy.intercept('PATCH', '**/api/modules/rup/internacion/changeTime/**').as('patchCamaEstados');
cy.intercept('PATCH', '**/api/modules/rup/internacion/internacion-resumen/**').as('patchResumen');
cy.intercept('PATCH', '**/api/modules/rup/prestaciones/**').as('patchPrestacion');
cy.route('GET', '/api/core/term/snomed/expression?expression=<<394658006&words=**', [{
"conceptId": "1234",
"term": "Enfermeria en Rehabilitación",
Expand Down Expand Up @@ -73,12 +73,12 @@ describe('Acciones sobre paciente ingresado desde capa asistencial', () => {

cy.plexButtonIcon('check').click();

cy.wait('@patchCamas').then((xhr) => {
expect(xhr.status).to.be.eq(200);
cy.wait('@patchPrestacion').then(({response}) => {
expect(response.statusCode).to.be.eq(200);
});

cy.wait('@patchResumen').then((xhr) => {
expect(xhr.status).to.be.eq(200);
cy.wait('@patchResumen').then(({response}) => {
expect(response.statusCode).to.be.eq(200);
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('Capa Estadistica - Egresos', () => {
cy.intercept('GET', '**/api/modules/rup/internacion/camas**').as('getCamas');
cy.intercept('GET', '**/api/modules/rup/internacion/camas/historial?**').as('getHistorial');
cy.intercept('PATCH', '**/api/modules/rup/prestaciones/**').as('patchPrestaciones');
cy.intercept('PATCH', '**/api/modules/rup/internacion/camas/**').as('patchCamas');
cy.intercept('PATCH', '**/api/modules/rup/internacion/camaEstados/**').as('patchCamaEstados');
cy.viewport(1920, 1080);
});

Expand Down
5 changes: 3 additions & 2 deletions cypress/e2e/apps/rup/internacion/estadistica/ingresos.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Capa Estadistica - Ingresos', () => {
});

beforeEach(() => {
cy.server()
cy.server();
cy.intercept('GET', '**/api/core-v2/mpi/pacientes?**').as('busquedaPaciente');
cy.intercept('GET', '**/api/core-v2/mpi/pacientes/**').as('getPaciente');
cy.intercept('GET', '**/api/core/tm/profesionales**').as('getProfesionales');
Expand All @@ -45,6 +45,7 @@ describe('Capa Estadistica - Ingresos', () => {

cy.intercept('PATCH', '**/api/modules/rup/prestaciones/**').as('patchPrestaciones');
cy.intercept('PATCH', '**/api/modules/rup/internacion/camas/**').as('patchCamas');
cy.intercept('PATCH', '**/api/modules/rup/internacion/camaEstados/**').as('patchCamaEstados');
cy.viewport(1920, 1080);
});

Expand Down Expand Up @@ -86,7 +87,7 @@ describe('Capa Estadistica - Ingresos', () => {

cy.plexButtonIcon('check').click();

cy.wait('@patchCamas').then(({response}) => {
cy.wait('@patchCamaEstados').then(({response}) => {
expect(response.statusCode).to.eq(200);
});

Expand Down
45 changes: 22 additions & 23 deletions cypress/e2e/apps/rup/internacion/mapa-camas/detalle-cama.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,29 @@ describe('Mapa Camas - Detalle de Cama', () => {
});

beforeEach(() => {
cy.server();
cy.viewport(1920, 1080);
cy.route('GET', '**/api/auth/organizaciones**', true).as('getOrganizaciones');
cy.route('GET', '**/api/modules/rup/internacion/camas/**').as('getCama');
cy.route('GET', '**/api/modules/rup/internacion/camas?**').as('getCamas');
cy.route('GET', '**/api/core-v2/mpi/pacientes/**', paciente).as('getPaciente');
cy.route('PATCH', '**/api/modules/rup/internacion/deshacer').as('deshacer');
cy.route('PATCH', '**/api/modules/rup/prestaciones/**').as('anularPrestacion');
cy.intercept('GET', '**/api/auth/organizaciones**').as('getOrganizaciones');
cy.intercept('GET', '**/api/modules/rup/internacion/camas/**').as('getCama');
cy.intercept('GET', '**/api/modules/rup/internacion/camas?**').as('getCamas');
cy.intercept('GET', '**/api/core-v2/mpi/pacientes/**', paciente).as('getPaciente');
cy.intercept('PATCH', '**/api/modules/rup/internacion/deshacer').as('deshacer');
cy.intercept('PATCH', '**/api/modules/rup/prestaciones/**').as('anularPrestacion');
});

it('Verificar datos de cama', () => {
cy.goto('/mapa-camas', token);
cy.wait('@getCamas').then((xhr) => {
expect(xhr.status).to.be.eq(200);
cy.wait('@getCamas').then(({response}) => {
expect(response.statusCode).to.be.eq(200);
});

cy.get('table tr').eq(1).find('td').eq(1).contains('ANDES').click();

cy.wait('@getCama').then((xhr) => {
expect(xhr.status).to.be.eq(200);
cy.wait('@getCama').then(({response}) => {
expect(response.statusCode).to.be.eq(200);
});
// VERIF. NOMBRE
cy.get('plex-detail section div').eq(1).find('div').should(($div) => {
expect($div.get(3).innerText).to.equal(cama.cama.nombre);
cy.get('plex-detail section div.contenedor-textos > div').eq(1).find('div').should(($div) => {
expect($div.contents().eq(cama.cama.nombre));
});

// VERIF. ESTADO
Expand Down Expand Up @@ -123,13 +122,13 @@ describe('Mapa Camas - Detalle de Cama', () => {
});

// VERIF. NOMBRE - APELLIDO PACIENTE
cy.get('plex-detail').eq(1).find('section').find('div').eq(1).find('div').should(($div) => {
expect($div.get(1).innerText).to.equal(`${paciente.apellido}, ${paciente.nombre}`);
cy.get('plex-detail section div.contenedor-textos > div').eq(0).find('div').should(($div) => {
expect($div.contents().eq(`${paciente.apellido}, ${paciente.nombre}`));
});

// VERIF. DOCUMENTO
cy.get('plex-detail').eq(1).find('section').find('div').eq(1).find('div').should(($div) => {
expect($div.get(2).innerText.split('.').join("").trim()).to.equal(paciente.documento);
cy.get('plex-detail section div.contenedor-textos > div').eq(1).find('div').should(($div) => {
expect($div.contents().eq(paciente.documento));
});

// VERIF. SEXO
Expand All @@ -145,20 +144,20 @@ describe('Mapa Camas - Detalle de Cama', () => {

it('Deshacer internacion', () => {
cy.goto('/mapa-camas', token);
cy.wait('@getCamas').then((xhr) => {
expect(xhr.status).to.be.eq(200);
cy.wait('@getCamas').then(({response}) => {
expect(response.statusCode).to.be.eq(200);
});

cy.getCama(cama.cama.nombre).click();

cy.deshacerInternacion();

cy.wait('@deshacer').then((xhr) => {
expect(xhr.status).to.be.eq(200);
cy.wait('@deshacer').then(({response}) => {
expect(response.statusCode).to.be.eq(200);
});

cy.wait('@anularPrestacion').then((xhr) => {
expect(xhr.status).to.be.eq(200);
cy.wait('@anularPrestacion').then(({response}) => {
expect(response.statusCode).to.be.eq(200);
})

cy.swal('confirm', 'Se deshizo la internación');
Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/apps/rup/internacion/medica/egresos.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const moment = require('moment');
cy.intercept('GET', '**api/modules/rup/internacion/medica/**').as('getHistorial2');
cy.intercept('GET', '**/api/modules/rup/internacion/camas?**').as('getCamas');
cy.intercept('PATCH', '**/api/modules/rup/internacion/camas/**').as('patchCamas');
cy.intercept('PATCH', '**/api/modules/rup/internacion/camaEstados/**').as('patchCamaEstados');
cy.intercept('PATCH', '**/api/modules/rup/internacion/sala-comun/**').as('egresoSalaComun');

cy.viewport(1920, 1080);
Expand All @@ -46,7 +47,7 @@ const moment = require('moment');

cy.plexButtonIcon('check').click();

cy.wait('@patchCamas')
cy.wait('@patchCamaEstados')
cy.toast('success', 'Egreso guardado correctamente');
});

Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/apps/rup/internacion/medica/ingresos.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
cy.intercept('GET', '**/api/auth/organizaciones**').as('getOrganizaciones');
cy.intercept('GET', '**/api/modules/rup/internacion/camas?**').as('getCamas');
cy.intercept('PATCH', '**/api/modules/rup/internacion/camas/**').as('patchCamas');
cy.intercept('PATCH', '**/api/modules/rup/internacion/camaEstados/**').as('patchCamaEstados');
cy.intercept('POST', '**/api/modules/rup/internacion/sala-comun/**').as('internarPaciente');
cy.intercept('GET', '/api/modules/rup/prestaciones/huds/**', []).as('huds');
cy.viewport(1920, 1080);
Expand All @@ -62,7 +63,7 @@
cy.wait('@getCamas');
cy.plexSelectType('label="Cama"', 'CAMA');
cy.plexButtonIcon('check').click();
cy.wait('@patchCamas').then(({response}) => {
cy.wait('@patchCamaEstados').then(({response}) => {
expect(response.statusCode).to.eq(200);
});
cy.swal('confirm', 'Paciente internado');
Expand Down
22 changes: 11 additions & 11 deletions cypress/e2e/apps/rup/internacion/medica/movimientos.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ const moment = require('moment');
});

beforeEach(() => {
cy.server();
cy.route('GET', `**/api/modules/rup/internacion/${capa}/**`).as('getHistorial');
cy.route('GET', '**/api/modules/rup/internacion/camas?**').as('getCamas');
cy.route('PATCH', '**/api/modules/rup/internacion/camas/**').as('patchCamas');
cy.route('PATCH', '**/api/modules/rup/internacion/sala-comun/**').as('egresoSalaComun');
cy.intercept('GET', `**/api/modules/rup/internacion/${capa}/**`).as('getHistorial');
cy.intercept('GET', '**/api/modules/rup/internacion/camas?**').as('getCamas');
cy.intercept('PATCH', '**/api/modules/rup/internacion/camas/**').as('patchCamas');
cy.intercept('PATCH', '**/api/modules/rup/internacion/camaEstados/**').as('patchCamaEstados');
cy.intercept('PATCH', '**/api/modules/rup/internacion/sala-comun/**').as('egresoSalaComun');

cy.viewport(1920, 1080);
});

it('Movimiento Sala -> Cama', () => {
cy.getCama(pacientes[0].apellido).click();

cy.wait('@getHistorial').then((xhr) => {
expect(xhr.status).to.be.eq(200);
cy.wait('@getHistorial').then(({response}) => {
expect(response.statusCode).to.be.eq(200);
});

cy.get('plex-title[titulo="DATOS DE CAMA"] div').eq(2);
Expand All @@ -49,12 +49,12 @@ const moment = require('moment');

cy.plexButtonIcon('check').click();

cy.wait('@egresoSalaComun').then((xhr) => {
expect(xhr.status).to.be.eq(200);
cy.wait('@egresoSalaComun').then(({response}) => {
expect(response.statusCode).to.be.eq(200);
});

cy.wait('@patchCamas').then((xhr) => {
expect(xhr.status).to.be.eq(200);
cy.wait('@patchCamaEstados').then(({response}) => {
expect(response.statusCode).to.be.eq(200);
});

cy.swal('confirm', 'Pase de unidad organizativa exitoso');
Expand Down

0 comments on commit 94973a4

Please sign in to comment.