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

Fix bug where mutations menu would show wrong workflow #1011

Merged
merged 8 commits into from
May 25, 2022

Conversation

MetRonnie
Copy link
Member

@MetRonnie MetRonnie commented May 12, 2022

Fixes a bug where navigating between running workflows and clicking on the workflow hamburger button would bring up the menu for the previous workflow. Closes #1006.

Note: It is not possible to write an e2e test for the bugfix while we only have one workflow in the mock/demo mode, so reviewers should test manually. You may want to review commit-by-commit.

This also changes the way the mutations menu is handled while the set of mutations is still loading. Instead of waiting until the mutations have loaded before allowing the user to open the menu, it now opens the menu and displays a skeleton loader until the mutations have loaded.

ezgif-5-2ece7f6960

In practice the time it takes to load the mutations is small but for testing purposes you can manually delay the loading by e.g. 15s by applying this patch:

diff --git a/src/services/workflow.service.js b/src/services/workflow.service.js
index d2a438c..7c923e9 100644
--- a/src/services/workflow.service.js
+++ b/src/services/workflow.service.js
@@ -118,6 +118,7 @@ class WorkflowService {
   async loadMutations () {
     // TODO: this assumes all workflows use the same schema which is and
     //       isn't necessarily true, not quite sure, come back to this later.
+    await new Promise(resolve => { setTimeout(resolve, 15e3) })
     const response = await this.apolloClient.query({
       query: getIntrospectionQuery(),
       fetchPolicy: 'no-cache'

Also adds test for:

Requirements check-list

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Appropriate tests are included (unit and/or functional).
  • Changelog entry included.
  • No documentation update required.

@MetRonnie MetRonnie added this to the 1.2.0 milestone May 12, 2022
@MetRonnie MetRonnie self-assigned this May 12, 2022
@MetRonnie MetRonnie modified the milestones: 1.2.0, 1.3.0 May 13, 2022
@MetRonnie MetRonnie changed the title Test async loading of mutations Fix bug where mutations menu would show wrong workflow May 24, 2022
@MetRonnie MetRonnie modified the milestones: 1.3.0, 1.2.1 May 24, 2022
])
})

describe('iterateType', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

The diff is not so helpful for the remainder of this file; you may want to tick "Hide whitespace"

MetRonnie added 3 commits May 24, 2022 18:18
Show skeleton loader in mutations menu while mutations are still loading
Comment on lines +46 to +47
'import/no-duplicates': 'off',
'no-duplicate-imports': 'error'
Copy link
Member Author

Choose a reason for hiding this comment

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

This results in less faff when importing typedefs separately from the proper imports (like how we use if TYPE_CHECKING: in Python)

Comment on lines -68 to +69
import FormGenerator from '@/components/graphqlFormGenerator/FormGenerator'
import Task from '@/components/cylc/Task'
import FormGenerator from '@/components/graphqlFormGenerator/FormGenerator.vue'
import Task from '@/components/cylc/Task.vue'
Copy link
Member Author

Choose a reason for hiding this comment

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

(This is just to allow VSCode intellisense to work)

Comment on lines -189 to +186
if (!this.mutations || this.user.permissions.length < 2) {
if (!this.mutations.length || this.user.permissions.length < 2) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Remember that empty arrays are truthy in JavaScript! Always use .length for testing conventional truthiness otherwise you're just testing that it is not undefined

@MetRonnie MetRonnie added the bug Something isn't working label May 24, 2022
@MetRonnie MetRonnie requested a review from AaronDCole May 24, 2022 17:28
Copy link
Contributor

@AaronDCole AaronDCole left a comment

Choose a reason for hiding this comment

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

Works great Ronnie! Tested running three concurrent workflows with five old workflows, no issues that I can see.

Copy link
Contributor

@datamel datamel left a comment

Choose a reason for hiding this comment

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

Checked out and tested manually, including the auth changes via test user account. Working smoothly for me.

@datamel datamel merged commit a698e49 into cylc:master May 25, 2022
@MetRonnie MetRonnie deleted the aync-mutate branch May 25, 2022 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aotf: mutation associated with the wrong workflow
3 participants