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

[NT-409] Fix issue with feature flags ordering #879

Merged
merged 3 commits into from
Oct 9, 2019

Conversation

dusi
Copy link
Contributor

@dusi dusi commented Oct 7, 2019

📲 What

#877 has recently broken the way we can toggle feature flags ON and OFF so this PR fixes that.

🤔 Why

The toggling was previously broken due to sorting only being applied to the data source (not the actual data being sorted).

reloadWithData did get the sorted array while updateConfigWithFeatures did not ... therefore when the data was fetched from the server in un-sorted order it would cause weird behaviour (the data displayed would not reflect the data being toggled ON/OFF).

🛠 How

This PR should fix that by both applying sort to updateConfigWithFeatures as well as adding tests to cover this case.

✅ Acceptance criteria

In order to test this we should test both scenarios. For that please put the following code in FeatureFlagToolsViewModel.swift on line 46.

Since the feature toggles are returned in random order you might need to run the app couple times.

.map { configFeatures in
  var features = [FeatureEnabled]()

  for (key, value) in configFeatures {
    guard let feature = Feature(rawValue: key) else {
      continue
    }

    features.append((feature: feature, isEnabled: value))
  }
  print("*** features: \(features)")
  return features
}

A) Feature toggles are received in alphabetical order

  • Verify that feature toggles are printed in alphabetical order (the above print statement)
  • Toggle feature toggles ON and OFF and double check they're affecting app's behaviour (proper native checkout flow)

B) Feature toggles are not received in alphabetical order

  • Verify that feature toggles are printed in non-alphabetical order (the above print statement)
  • Toggle feature toggles ON and OFF and double check they're affecting app's behaviour (proper native checkout flow)

.map { features in features.sorted { $0.feature.description < $1.feature.description } }

self.updateConfigWithFeatures = features
Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can see that previously reloadWithData would get sorted array while updateConfigWithFeatures would not ... this should be fixed now

Copy link
Contributor

@cdolm92 cdolm92 left a comment

Choose a reason for hiding this comment

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

Thanks for fixing! looks good to me 🎉

@dusi dusi merged commit 3d19cd5 into master Oct 9, 2019
@dusi dusi deleted the fix-feature-flag-issue-when-sorted-alphabetically branch October 9, 2019 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants