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

If worklist is restarting, don't set new sort comparator #1259

Merged
merged 1 commit into from
May 9, 2024

Conversation

nmajor25
Copy link
Contributor

@nmajor25 nmajor25 commented May 7, 2024

Shortcut Story ID: [sc-50540]

@nmajor25 nmajor25 requested a review from paulfalgout May 7, 2024 21:36
@nmajor25 nmajor25 marked this pull request as draft May 7, 2024 21:37
@@ -55,7 +55,7 @@ export default App.extend({
this.setState(filterState.getFiltersState());
},
onChangeStateSort() {
if (!this.isRunning()) return;
if (!this.isRunning() || this.isRestarting()) return;
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 can't reproduce this bug in my dev environment, so can't tell if this actually fixes the issue.

Also still contemplating how to test this.

Copy link
Member

Choose a reason for hiding this comment

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

Here's the test, but isRestarting doesn't fix the issue:

    cy
      .intercept('GET', '/api/flows*', { delay: 1000, body: { data: [] } })
      .visit('/worklist/owned-by');

    cy
      .get('[data-date-filter-region]')
      .should('contain', 'Added:')
      .should('contain', 'This Month')
      .click();

    cy
      .get('.app-frame__pop-region')
      .contains('Last Week')
      .click();

    cy
      .get('.worklist-list__filter-sort')
      .click()
      .get('.picklist')
      .contains('Patient Last: A')
      .click();

Copy link
Contributor Author

@nmajor25 nmajor25 May 8, 2024

Choose a reason for hiding this comment

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

What about checking that the list view has a collection before setting the comparator?

Like:

  onChangeStateSort() {
    if (!this.isRunning()) return;

    const listView = this.getChildView('list');

    if (listView.collection) {
      listView.setComparator(this.getComparator());
    }
  },

That seems to work...

Copy link

cypress bot commented May 7, 2024

Passing run #6366 ↗︎

0 281 0 0 Flakiness 0

Details:

Fix sync bug in the `/base/app.js`
Project: RoundingWell Care Ops Frontend Commit: d20ce66977
Status: Passed Duration: 02:56 💡
Started: May 9, 2024 3:39 PM Ended: May 9, 2024 3:42 PM

Review all test suite changes for PR #1259 ↗︎

@coveralls
Copy link

coveralls commented May 7, 2024

Pull Request Test Coverage Report for Build cdb37ccb-08f4-4b90-973a-bd4d4ba2477f

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall first build on bugfix/worklist-filter at 99.91%

Totals Coverage Status
Change from base Build 965aa496-a373-4df6-a574-0334073fadb4: 99.9%
Covered Lines: 5941
Relevant Lines: 5945

💛 - Coveralls

@@ -55,7 +55,7 @@ export default App.extend({
this.setState(filterState.getFiltersState());
},
onChangeStateSort() {
if (!this.isRunning()) return;
if (!this.isRunning() || this.isRestarting()) return;
Copy link
Member

Choose a reason for hiding this comment

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

Here's the test, but isRestarting doesn't fix the issue:

    cy
      .intercept('GET', '/api/flows*', { delay: 1000, body: { data: [] } })
      .visit('/worklist/owned-by');

    cy
      .get('[data-date-filter-region]')
      .should('contain', 'Added:')
      .should('contain', 'This Month')
      .click();

    cy
      .get('.app-frame__pop-region')
      .contains('Last Week')
      .click();

    cy
      .get('.worklist-list__filter-sort')
      .click()
      .get('.picklist')
      .contains('Patient Last: A')
      .click();

@nmajor25 nmajor25 marked this pull request as ready for review May 8, 2024 20:49
@nmajor25 nmajor25 requested a review from paulfalgout May 8, 2024 21:45
@paulfalgout
Copy link
Member

OK so.. this fixed seemed oddly unnecessary.. how was it that the app was running.. wasn't restarting and still had the preloader running.

It turns out the issue was deeper and it might subsequently also solve the issue we're seeing in the program action bug. This'll actually be an odd place to test this.. Really at some point we need to add component tests for the base classes. But I think we can keep this test and just add a comment that links to this PR and a message about moving it to a component test.

So in base/app.js it was setting loading to false, but that fetchId check prevents older fetches from resolving.. so.. if you make two requests one after another where the 2nd should take precedent.. the first one clears the loading flag which modifies running..

Currently:

  onSyncData(fetchId, options, args = []) {
    this._isLoading = false;
    if (!this.isRunning() || this._fetchId !== fetchId) return;

    this.finallyStart.call(this, options, ...args);
  },
  triggerSyncFail(fetchId, options, ...args) {
    this._isLoading = false;
    if (!this.isRunning() || this._fetchId !== fetchId) return;

    this.triggerMethod('fail', options, ...args);
  },

Change to: (notice the switch from isRunning() to _isRunning)

onSyncData(fetchId, options, args = []) {
    if (!this._isRunning || this._fetchId !== fetchId) return;

    this._isLoading = false;

    this.finallyStart.call(this, options, ...args);
  },
  triggerSyncFail(fetchId, options, ...args) {
    if (!this._isRunning || this._fetchId !== fetchId) return;

    this._isLoading = false;

    this.triggerMethod('fail', options, ...args);
  },

@shadowhand
Copy link
Contributor

shadowhand commented May 9, 2024

@paulfalgout that explanation makes a ton of sense. My spidey senses were tingling when I saw this story because it seemed like something we would have noticed before, as the particular trigger is relatively common.

@nmajor25
Copy link
Contributor Author

nmajor25 commented May 9, 2024

@paulfalgout interesting... I updated the PR to your solution and it seems to fix this worklist bug (via the test passing).

But it doesn't fix the program action sidebar bug in #1260.

@paulfalgout paulfalgout merged commit 501085e into develop May 9, 2024
5 checks passed
@paulfalgout paulfalgout deleted the bugfix/worklist-filter branch May 9, 2024 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants