Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor test/integration/patients/patient/dashboard.js tests for jsonapi #1245

Merged
merged 4 commits into from
May 20, 2024

Conversation

nmajor25
Copy link
Contributor

Shortcut Story ID: [sc-49091]

Copy link

Copy link

cypress bot commented Mar 22, 2024

Passing run #6385 ↗︎

0 237 0 0 Flakiness 0

Details:

Refactor `add action and flow` test further
Project: RoundingWell Care Ops Frontend Commit: 3b695557a6
Status: Passed Duration: 02:54 💡
Started: May 16, 2024 5:29 PM Ended: May 16, 2024 5:31 PM

Review all test suite changes for PR #1245 ↗︎

@coveralls
Copy link

coveralls commented Mar 22, 2024

Pull Request Test Coverage Report for Build a3c1413d-5cca-4ec7-b546-802f35b4f802

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall first build on test-refactor at 98.38%

Totals Coverage Status
Change from base Build 1171a9d3-9108-478c-82e7-f42f55df9e40: 98.4%
Covered Lines: 5856
Relevant Lines: 5937

💛 - Coveralls

test/integration/patients/patient/dashboard.js Outdated Show resolved Hide resolved
test/integration/patients/patient/dashboard.js Outdated Show resolved Hide resolved
fx.data[4].attributes.archived_at = testTs();
fx.data[4].relationships['program-actions'] = { data: [] };
fx.data[4].relationships['program-flows'] = { data: [] };
fx.data = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test setup would be best to create the elements at the top using the uuids that come back.. however there is a circular relationship so some of the getFoos will need to be passed uuids since they need to be used in a relationship prior to their instantiation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some updates to this test. But probably more that can be done here.

test/integration/patients/patient/dashboard.js Outdated Show resolved Hide resolved
relationships: {
'program-flows': getRelationship([{ id: '4' }], 'flows'),
'program-actions': getRelationship(
[{ id: '1' }, { id: '4' }, { id: '5' }, { id: '6' }],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of the ids and the ones below should be able to be done by using only getProgram, getProgramAction and getProgramFlow except that you'll need uuids to setup the circular ids.. should be like on patient-flow or program-flow tests as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got a solution for this. But it feels overly complicated. Open to any better ideas.

@@ -405,7 +405,7 @@ context('patient dashboard page', function() {
.should('contain', `patient-action/${ testAction.id }/form/${ testForm.id }`);
});

specify('add action and flow', function() {
specify.only('add action and flow', function() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot the .only here 🤦, but it's removed in the next commit.

const currentClinican = getCurrentClinician({
relationships: {
role: getRelationship(roleEmployee),
},
});

const testProgramActionIds = [uuid(), uuid(), uuid(), uuid(), uuid(), uuid()];
const testProgramFlowIds = [uuid(), uuid(), uuid(), uuid(), uuid(), uuid()];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to set these all at the top. And then use them throughout.

Otherwise using e.g. testProgramActions[0].id or testProgramFlows[0].id in testPrograms = [] would cause errors. Since we'd be trying to use data/variables that weren't instantiated yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you flipped it and made programIds with uuid then you could define the flows/actions first and use the ids generated from there for relations on the program.
You could also use _.times with uuid

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think that works well 👍 , and _.times is also much better

@nmajor25 nmajor25 requested a review from paulfalgout May 15, 2024 16:40
Copy link
Member

@paulfalgout paulfalgout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nearly there

const currentClinican = getCurrentClinician({
relationships: {
role: getRelationship(roleEmployee),
},
});

const testProgramActionIds = [uuid(), uuid(), uuid(), uuid(), uuid(), uuid()];
const testProgramFlowIds = [uuid(), uuid(), uuid(), uuid(), uuid(), uuid()];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you flipped it and made programIds with uuid then you could define the flows/actions first and use the ids generated from there for relations on the program.
You could also use _.times with uuid

archived_at: null,
},
relationships: {
program: getRelationship(testProgramIds[1], 'programs'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test still passes if these are removed... 🤔

@paulfalgout paulfalgout merged commit e00f643 into develop May 20, 2024
5 checks passed
@paulfalgout paulfalgout deleted the test-refactor branch May 20, 2024 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants