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

Cypress test edit action in dashboard actions list NB: OLD - these changes will be integrated into new PRs and this will eventually be deleted #593

Closed

Conversation

denektenina
Copy link
Contributor

@denektenina denektenina commented Sep 3, 2021

Made cypress tests for actions in actions table on dashboard and follow up page. Testing the following:

  • In Dashboard Actions table, actions can be edited and completed in side panel
  • In FollowUp Actions table, actions can be edited and completed in side panel
  • (New) Actions are visible in Dashboard Actions tab
  • (New) Actions are visible in FollowUp Actions tab

Notes / improvements

  • I recently fixed a bug where newly created notes did not appear in the notes list until the side panel were closed and reopened again. The existing tests did not test that, and this issue were partly opened because of this. Therefore, I considered it important to make tests that covered this, so I included this also in existing tests.
  • I am not testing if deleted actions are visible in any of the tables. This is because the delete function is currently being debated and might be changed. This can thus be done in a later PR.
  • I have made some structural changes to the tests after discussions with the team. This has also affected the closing comments tests, since these were also written by me.

@denektenina denektenina linked an issue Sep 3, 2021 that may be closed by this pull request
@denektenina denektenina self-assigned this Sep 3, 2021
@denektenina denektenina force-pushed the cypress_test_actions_list branch 3 times, most recently from 4a20e45 to 3bce321 Compare September 5, 2021 14:41
@denektenina denektenina marked this pull request as ready for review September 5, 2021 14:41
@hnformentin
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@petterwildhagen
Copy link
Contributor

In Dashboard Actions table, actions can be edited and completed in side panel
PETTER: Who can edit and complete actions ?
In FollowUp Actions table, actions can be edited and completed in side panel
PETTER: Who can edit and complete actions?
(New) Actions are visible in Dashboard Actions tab
(New) Actions are visible in FollowUp Actions tab

I recently fixed a bug where newly created notes did not appear in the notes list until the side panel were closed and reopened again. The existing tests did not test that, and this issue were partly opened because of this. Therefore, I considered it important to make a test that covered this. This was difficult to test because the notes call was often slow to return, so I landed on setting a wait for 4 seconds before asserting the existence in the notes list. 4 seconds is because cypress automatically fails any calls that take longer than that to return, making it consistent. It makes the tests slower since many of them are waiting longer than they have to, but I think this is important to test.
PETTER: Avoid long waits - they make the tests flaky - investigate why it takes so much time and fix root cause (the slowness)

@hnformentin

This comment has been minimized.

Copy link
Contributor

@achaikou achaikou left a comment

Choose a reason for hiding this comment

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

Can't do a proper review as it's too crowded here already, and all of us have very different opinions about the testing framework (we might need to add contributing guidelines), so just a couple of comments that I believe I didn't try fighting anyone else before.

frontend/cypress/support/action.ts Outdated Show resolved Hide resolved
editActionDialog.completeActionConfirmButton().should('exist')
editActionDialog.completeActionCancelButton().should('exist')
}
it('Action can be edited', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Something important for me: are your newly added tests actually interesting enough to be run every single time?

My original idea was just to add randomization of entry point to the existing complete/edit test as this is not actually any new functionality. Now these tests just repeat!

This might however be another point where we all think very differently. I honestly can't even do a review/look at the tests now, because everything is duplicated and I fiercely, fiercely hate duplication. *angry cat noises*

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After our talk yesterday I have gone through and reassessed my checks, so I think I can defend the checks I am doing now, and have removed others. Please review again and resolve if you are happy :)

Copy link
Contributor

Choose a reason for hiding this comment

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

No, I really am not 😄 so I will try to push my point one more time.
As I said, this is quite important for me. You duplicate same test 3 times. I can live with it running without randomization, but the fact that code is copied - makes me sad.
As you see, action tests become a big, big mess with regards to current amount of failures we see on the CI. Code duplication will only make it worse.

That was my second and final attempt to convince you to unify the tests 😄 If you don't see a way to rewrite these tests to make them not duplicated and tidy, I give up. Apparently other reviewers didn't believe it to be important, so I am outnumbered 😄

P.S. Failures in repeated tests might have given me the idea about what's wrong, so I am a little bit more warmed up to this today 😄

Copy link
Contributor Author

@denektenina denektenina Sep 10, 2021

Choose a reason for hiding this comment

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

If this is still relevant in the newest PR, please show me where the duplicates are. You say I "same test 3 times", is this in the complete-tests or other places? If in the complete tests, we can fix this for my new PR. If not, we can fix in a later PR.

If you are referring to lines like:

editActionDialog.checkIfCompletedInView(action.completed)
editActionDialog.completeActionButton().click()
editActionDialog.checkIfCompleteConfirmViewVisible(true)

being repeated in the same order several places, please specify if you argue for removing some of the lines because it is not needed to check, or if you argue for placing them in a separate function and reusing this to avoid code duplicate.

What I meant in my comment above is that I did unify the "complete with" and "complete without" comment-tests. This removed a lot of duplicates. I think cancel complete differs, but please argue if you think something should be changed there. If this is too much to explain to me in writing, we could maybe have a call and make the changes together?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for trying to explain this! ❤️

New PR at the moment doesn't introduce more tests, so it is not relevant to it. And currently I am happy with the "check" functions. And in general I like new PR very much ❤️

By duplicates I mean

  • complete/edit action from workshop/follow up
  • complete/edit action from Actions Tab on Follow Up
  • complete/edit action from Dashboard

The flow of these actions is repeated. The meaning of these tests is repeated. That's what I don't like.

There were 3 options for me how to deal with that

  1. Randomization (you randomize the way you enter the dialog) - you run it just once from random entry point
  2. For loop, like for roles - you run it 3 times, for each way to enter the dialog (as with randomization, the whole flow is still covered by 1 code sequence and 3 entry functions). I do not like this approach, as it will take long to complete and doesn't introduce much value to the tests.
  3. wait until we establish this "lightweight second level" of Petters test strategy where we will only check from all 3 places that 1) edit link is present 2) Complete action button is present 3) whatever else we need to check (that notes number is as expected?) without actually doing or checking anything else

I am at the moment for a mix of approaches 1 and 3, but that requires Petters vision implemented as example for some tests and our discussion on randomization to happen

frontend/cypress/integration/actions_spec.ts Outdated Show resolved Hide resolved
frontend/cypress/integration/actions_spec.ts Outdated Show resolved Hide resolved
frontend/cypress/integration/actions_spec.ts Outdated Show resolved Hide resolved
frontend/cypress/integration/actions_spec.ts Outdated Show resolved Hide resolved
frontend/cypress/integration/actions_spec.ts Outdated Show resolved Hide resolved
frontend/cypress/integration/actions_spec.ts Outdated Show resolved Hide resolved
frontend/cypress/integration/actions_spec.ts Outdated Show resolved Hide resolved
@denektenina denektenina force-pushed the cypress_test_actions_list branch 2 times, most recently from 3d043a7 to ba204b5 Compare September 8, 2021 09:19
Copy link
Contributor

@achaikou achaikou left a comment

Choose a reason for hiding this comment

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

You already fixed the seed.plant instability, so good 👍
The failing tests are probably part of the instability I am currently investigating. Can't say anything yet.

frontend/cypress/integration/actions_spec.ts Show resolved Hide resolved
editActionDialog.completeActionConfirmButton().should('exist')
editActionDialog.completeActionCancelButton().should('exist')
}
it('Action can be edited', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

No, I really am not 😄 so I will try to push my point one more time.
As I said, this is quite important for me. You duplicate same test 3 times. I can live with it running without randomization, but the fact that code is copied - makes me sad.
As you see, action tests become a big, big mess with regards to current amount of failures we see on the CI. Code duplication will only make it worse.

That was my second and final attempt to convince you to unify the tests 😄 If you don't see a way to rewrite these tests to make them not duplicated and tidy, I give up. Apparently other reviewers didn't believe it to be important, so I am outnumbered 😄

P.S. Failures in repeated tests might have given me the idea about what's wrong, so I am a little bit more warmed up to this today 😄

seed.plant()
})

it('Actions are visible on Dashboard Actions Tab', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am so not sure about this test in general... The main goal of the dashboard is to "only display all the actions assigned to the current user across the projects", but what we essentially check is "some actions assigned to current user in the project we are in are displayed"

  • if we really want to test functionality of the dashboad, we need to introduce actions from a different project
  • we probably need to make sure that all the actions in the table are assigned to the user and there are no unexpected actions are present (we in theory could have checked that in other view tests as well, but I believe danger there is lesser, though still up for discussion)
  • it would be great to also make sure that all the actions assigned to the user are present here (again, can apply to other view tests as well, but that would be difficult to implement)
  • (probably fine) dashboard tab displays all the actions assigned to the user. It might happen that there are too many actions present, so the actions we are searching for might not be visible on the page. Probably (?) cypress should deal with this.

So I think that this is also something to be discussed as a general concept if we want/need it in our tests as checking that expected and actual map 1 x 1 would need additional graphql query calls. (Separate project/user would work only if we agree to test this on special occasions only)

Basically awesome point for discussion, but if you are tired of them and no discussion happens, test in current form can stay, but I would prefer it marked with comments "here are possible improvements"

Comment on lines +521 to +523
if (putAllActionsOnEditor) {
preassignedActionValues.assignedTo = editor
}
Copy link
Contributor

Choose a reason for hiding this comment

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

To the dashboard dicsussion:
If we could have a graphql call "return me all actions assigned to the user" or, in a perfect world have separate projects with separate user where we are in full control which actions are created (I actually think we can do it!!), we wouldn't need this hack.

frontend/cypress/support/action.ts Show resolved Hide resolved
frontend/cypress/support/action.ts Show resolved Hide resolved
@@ -83,8 +84,7 @@ describe('Actions', () => {
const actionProgression = faker.random.arrayElement([Progression.Workshop, Progression.FollowUp])

beforeEach(() => {
;({ seed, existingAction, existingNotes } = createEvaluationWithActionsWithNotes({ title: 'Just some random action' }))
editor = faker.random.arrayElement(seed.participants)
;({ seed, editor, existingAction, existingNotes } = createEvaluationWithActionsWithNotes({ title: 'Just some random action' }))
Copy link
Contributor

Choose a reason for hiding this comment

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

replace editor with user and login in the same way as other tests in actions_spec.
only return seed in before each.
Move getting of existingAction & existingNotes into test itselg

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basing my new PR on your newest PR so I think this is fixed

@denektenina denektenina changed the title Cypress test edit action in dashboard actions list Cypress test edit action in dashboard actions list NB: OLD - these changes will be integrated into new PRs and this will eventually be deleted Sep 10, 2021
@denektenina
Copy link
Contributor Author

Closing this because the tests have been covered in other PRs. The only thing still missing is potentially testing that notes appear in the list right after adding (without reload) in all three views. It has been debated a lot whether or not we should test all kinds of editing of actions and notes with reload in all three side panels, but we have landed on doing it, and it will be done in other PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create Cypress tests for action panel from action list. ref #565
4 participants