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

DX: Split out feature flags from the Me user data endpoint #7734

Merged
merged 39 commits into from Feb 28, 2024

Conversation

BLoe
Copy link
Collaborator

@BLoe BLoe commented Feb 26, 2024

What does this PR do?

  • Use the same api URL (/api/me), but split out feature flags into a separate RTK Query and separate request in the background script
    • This will simplify some things as part of the upcoming /api/me API Layer / Transformer work
  • Also rename token.ts to authStorage.ts to match other modules in this folder, and better describe what this module does

Remaining work

  • Fix remaining broken tests (I think something is wrong with userMock)
  • Add new tests for featureFlags

Checklist

  • Add tests
  • New files added to src/tsconfig.strictNullChecks.json (if possible)
  • Designate a primary reviewer - @grahamlangford

@BLoe BLoe self-assigned this Feb 26, 2024
Ben Loe and others added 2 commits February 26, 2024 15:21
Co-authored-by: Graham Langford <30706330+grahamlangford@users.noreply.github.com>
Copy link
Collaborator

@grahamlangford grahamlangford left a comment

Choose a reason for hiding this comment

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

Looks good so far. Let me know if you need any help debugging that failing test.

@BLoe BLoe marked this pull request as ready for review February 26, 2024 20:29
Copy link

codecov bot commented Feb 26, 2024

Codecov Report

Attention: Patch coverage is 96.61017% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 72.17%. Comparing base (cbd7760) to head (cf173f2).

Files Patch % Lines
.../components/floatingActions/initFloatingActions.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7734      +/-   ##
==========================================
+ Coverage   72.14%   72.17%   +0.03%     
==========================================
  Files        1270     1270              
  Lines       39760    39770      +10     
  Branches     7375     7371       -4     
==========================================
+ Hits        28684    28705      +21     
+ Misses      11076    11065      -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/auth/featureFlags.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@grahamlangford grahamlangford left a comment

Choose a reason for hiding this comment

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

Looks like there's just an unused import.

Copy link

github-actions bot commented Feb 26, 2024

No loom links were found in the first post. Please add one there if you'd like to it to appear on Slack.

Do not edit this comment manually.

}),
providesTags: ["Me"],
}),
getFeatureFlags: builder.query<string[], void>({
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

This comment has been minimized.

Comment on lines +57 to +59
await waitForEffect();
// Make sure we only fetched once
expect(appApiMock.history.get).toHaveLength(1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

did await waitFor(() => { ... } not work for this?

Copy link
Collaborator Author

@BLoe BLoe Feb 28, 2024

Choose a reason for hiding this comment

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

I had a case where it would eventually make two api calls, but using waitFor() it would run the assertion successfully at the point where only one call had been made and the test would pass, incorrectly.

flags: ["test-flag"],
});

const { result, waitFor } = renderHook(() => useFlags());
Copy link
Collaborator

Choose a reason for hiding this comment

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

❤️

This comment has been minimized.

@@ -235,7 +235,7 @@
"css-minimizer-webpack-plugin": "^6.0.0",
"dotenv": "^16.4.5",
"eslint": "^8.57.0",
"eslint-config-pixiebrix": "^0.37.1",
"eslint-config-pixiebrix": "^0.36.2",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why is this all getting messed up when I merge main into my branch? CC @fregante @grahamlangford

Copy link
Collaborator

Choose a reason for hiding this comment

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

Whats your exact sequence of actions when you merge the main branch and find conflicts? Do you use the CLI or also some UI for git?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I start on my current dev branch, then I do:
git checkout main && git pull && git checkout <my_branch>
Then I run:
git merge main

When this runs, I see this npm-merge-driver: merging package-lock.json message in the output:
image

At this point, I need to run npm i again, otherwise if I push changes here then package-lock is messed up. Is this expected? Like, is it just npm changes on main and I need to run npm i after merging main as a normal step in the process?

Copy link
Collaborator

Choose a reason for hiding this comment

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

My standard workflow is just to run git pull origin main from my feature branch. Haven't had any problems with it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm curious if part of your problem is what ever changed between npm 10.2.5 and 10.3.0? Would need to look at the feature changes. But I doubt a minor would have that radical an effect.

Copy link
Collaborator

Choose a reason for hiding this comment

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

npm-merge-driver

You'll have to uninstall that, it's what's causing the issues. Back when I posted about it on Slack, I withdrew my suggestion a few minutes later.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I need to run npm i after merging main as a normal step in the process?

This is only required if the lockfile has conflicts, because it will resolve them automatically (after you resolve any conflicts in package.json).

Even if there are no conflicts, it's possible that you still need to run the install to make sure you have the latest dependencies, if any were changed.

@BLoe BLoe merged commit c50ddca into main Feb 28, 2024
22 of 23 checks passed
@BLoe BLoe deleted the dev/separate-feature-flags-from-me branch February 28, 2024 19:11
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

4 participants