Skip to content

Commit

Permalink
Merge branch 'master' into junaed/fssdk-10121-expo-poc-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
junaed-optimizely committed Nov 15, 2024
2 parents b626dda + 068382a commit 7ad29c8
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Checkout branch
uses: actions/checkout@v3
with:
token: ${{ secrets.CI_USER_TOKEN }}
token: ${{ secrets.CI_USER_TOKEN || secrets.GITHUB_TOKEN }}
repository: 'optimizely/travisci-tools'
path: 'home/runner/travisci-tools'
ref: 'master'
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,6 @@ Copyright © 2014 Taylor Hakes
Copyright © 2014 Forbes Lindesay
License: [MIT](https://github.com/taylorhakes/promise-polyfill/blob/master/LICENSE)

[**prop-types**](https://github.com/facebook/prop-types)
Copyright © 2013-present, Facebook, Inc.
License: [MIT](https://github.com/facebook/prop-types/blob/master/LICENSE)

[**react-is**](https://github.com/facebook/react)
Copyright © Facebook, Inc. and its affiliates.
License: [MIT](https://github.com/facebook/react/blob/master/LICENSE)
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"dependencies": {
"@optimizely/optimizely-sdk": "^5.3.4",
"hoist-non-react-statics": "^3.3.2",
"prop-types": "^15.8.1",
"utility-types": "^2.1.0 || ^3.0.0"
},
"peerDependencies": {
Expand All @@ -58,7 +57,6 @@
"@testing-library/react": "^14.3.0",
"@types/hoist-non-react-statics": "^3.3.5",
"@types/jest": "^29.5.12",
"@types/prop-types": "^15.7.12",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"@typescript-eslint/eslint-plugin": "^5.6.2",
Expand All @@ -78,7 +76,6 @@
"rollup": "^3.29.4",
"rollup-plugin-typescript2": "^0.36.0",
"ts-jest": "^29.2.3",
"tslib": "^2.6.3",
"typescript": "^5.5.4"
}
}
19 changes: 19 additions & 0 deletions src/Provider.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ describe('OptimizelyProvider', () => {
});

it('should render successfully without user or userId provided', () => {
// @ts-ignore
mockReactClient.user = undefined;
render(<OptimizelyProvider optimizely={mockReactClient} />);

expect(mockReactClient.setUser).toHaveBeenCalledWith(DefaultUser);
Expand All @@ -95,6 +97,8 @@ describe('OptimizelyProvider', () => {
});

it('should succeed just userAttributes provided', () => {
// @ts-ignore
mockReactClient.user = undefined;
render(<OptimizelyProvider optimizely={mockReactClient} userAttributes={{ attr1: 'value1' }} />);

expect(mockReactClient.setUser).toHaveBeenCalledWith({
Expand All @@ -103,6 +107,21 @@ describe('OptimizelyProvider', () => {
});
});

it('should succeed with the initial user available in client', () => {
render(<OptimizelyProvider optimizely={mockReactClient} />);

expect(mockReactClient.setUser).toHaveBeenCalledWith(user1);
});

it('should succeed with the initial user id and newly passed attributes', () => {
render(<OptimizelyProvider optimizely={mockReactClient} userAttributes={{ attr1: 'value2' }} />);

expect(mockReactClient.setUser).toHaveBeenCalledWith({
id: user1.id,
attributes: { attr1: 'value2' },
});
});

it('should not update when isServerSide is true', () => {
// Initial render
const { rerender } = render(<OptimizelyProvider optimizely={mockReactClient} isServerSide={true} user={user1} />);
Expand Down
6 changes: 6 additions & 0 deletions src/Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ export class OptimizelyProvider extends React.Component<OptimizelyProviderProps,
};
// deprecation warning
logger.warn('Passing userId and userAttributes as props is deprecated, please switch to using `user` prop');
} else if (optimizely.user) {
const { id, attributes } = optimizely.user;
finalUser = {
id,
attributes: userAttributes || attributes || {},
};
} else {
finalUser = {
id: DefaultUser.id,
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"importHelpers": false,
"strictNullChecks": true,
"noLib": false,
"emitDecoratorMetadata": true,
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@
dependencies:
undici-types "~6.13.0"

"@types/prop-types@*", "@types/prop-types@^15.7.12":
"@types/prop-types@*":
version "15.7.12"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.12.tgz#12bb1e2be27293c1406acb6af1c3f3a1481d98c6"
integrity sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==
Expand Down Expand Up @@ -3596,9 +3596,9 @@ merge2@^1.3.0, merge2@^1.4.1:
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==

micromatch@^4.0.4, micromatch@^4.0.5:
version "4.0.7"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.7.tgz#33e8190d9fe474a9895525f5618eee136d46c2e5"
integrity sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==
version "4.0.8"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202"
integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==
dependencies:
braces "^3.0.3"
picomatch "^2.3.1"
Expand Down Expand Up @@ -4185,9 +4185,9 @@ rollup-plugin-typescript2@^0.36.0:
tslib "^2.6.2"

rollup@^3.29.4:
version "3.29.4"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.29.4.tgz#4d70c0f9834146df8705bfb69a9a19c9e1109981"
integrity sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==
version "3.29.5"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.29.5.tgz#8a2e477a758b520fb78daf04bca4c522c1da8a54"
integrity sha512-GVsDdsbJzzy4S/v3dqWPJ7EfvZJfCHiDqe80IyrF59LYuP+e6U1LJoUqeuqRbwAWoMNoXivMNeNAOf5E22VA1w==
optionalDependencies:
fsevents "~2.3.2"

Expand Down Expand Up @@ -4664,7 +4664,7 @@ tslib@^1.8.1:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==

tslib@^2.1.0, tslib@^2.6.2, tslib@^2.6.3:
tslib@^2.1.0, tslib@^2.6.2:
version "2.6.3"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.3.tgz#0438f810ad7a9edcde7a241c3d80db693c8cbfe0"
integrity sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==
Expand Down

0 comments on commit 7ad29c8

Please sign in to comment.