Skip to content

Commit

Permalink
Handle NameChanged websocket message on patient flow page
Browse files Browse the repository at this point in the history
  • Loading branch information
nmajor25 committed Oct 30, 2024
1 parent 1a3f635 commit c198a5f
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 25 deletions.
3 changes: 3 additions & 0 deletions src/js/entities-service/entities/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const _Model = BaseModel.extend({
ActionDurationChanged({ duration, attributes = {} }) {
this.set({ duration, ...attributes });
},
NameChanged({ name, attributes = {} }) {
this.set({ name, ...attributes });
},
},
urlRoot() {
if (this.isNew()) {
Expand Down
3 changes: 3 additions & 0 deletions src/js/entities-service/entities/flows.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const _Model = BaseModel.extend({
StateChanged({ state, attributes = {} }) {
this.set({ _state: state.id, ...attributes });
},
NameChanged({ name, attributes = {} }) {
this.set({ name, ...attributes });
},
},
urlRoot() {
if (this.isNew()) return `/api/patients/${ this.get('_patient') }/relationships/flows`;
Expand Down
77 changes: 52 additions & 25 deletions test/integration/patients/patient/patient-flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -2244,11 +2244,6 @@ context('patient flow page', function() {

return fx;
})
.routeAction(fx => {
fx.data = testSocketAction;

return fx;
})
.routeActionActivity()
.visit(`/flow/${ testSocketFlow.id }`)
.wait('@routeFlow')
Expand All @@ -2261,41 +2256,37 @@ context('patient flow page', function() {
getRelationship(testSocketAction).data,
]);

cy
.get('.patient-flow__progress')
.should('have.value', 0);

cy.sendWs({
category: 'OwnerChanged',
category: 'NameChanged',
resource: {
type: 'patient-actions',
id: testSocketAction.id,
type: 'flows',
id: testSocketFlow.id,
},
payload: {
owner: {
type: 'teams',
id: teamCoordinator.id,
},
name: 'New Flow Name',
},
});

cy
.get('[data-header-region]')
.find('.patient-flow__name')
.contains('New Flow Name');

cy.sendWs({
category: 'OwnerChanged',
category: 'NameChanged',
resource: {
type: 'flows',
id: testSocketFlow.id,
type: 'patient-actions',
id: testSocketAction.id,
},
payload: {
owner: {
type: 'teams',
id: teamCoordinator.id,
},
name: 'New Action Name',
},
});

cy
.get('.patient-flow__progress')
.should('have.value', 0);
.get('.patient-flow__list')
.find('.table-list__item .patient__action-name')
.contains('New Action Name');

cy.sendWs({
category: 'ActionDueChanged',
Expand All @@ -2317,6 +2308,42 @@ context('patient flow page', function() {
expect($action.find('[data-due-time-region]')).to.contain('7:00 AM');
});

cy
.get('.patient-flow__progress')
.should('have.value', 0);

cy.sendWs({
category: 'OwnerChanged',
resource: {
type: 'patient-actions',
id: testSocketAction.id,
},
payload: {
owner: {
type: 'teams',
id: teamCoordinator.id,
},
},
});

cy.sendWs({
category: 'OwnerChanged',
resource: {
type: 'flows',
id: testSocketFlow.id,
},
payload: {
owner: {
type: 'teams',
id: teamCoordinator.id,
},
},
});

cy
.get('.patient-flow__progress')
.should('have.value', 0);

cy.sendWs({
category: 'StateChanged',
resource: {
Expand Down

0 comments on commit c198a5f

Please sign in to comment.