Skip to content

Conversation

@Mudaafi
Copy link
Contributor

@Mudaafi Mudaafi commented Feb 13, 2024

No description provided.

@Mudaafi Mudaafi requested a review from a team February 13, 2024 01:55
@linear
Copy link

linear bot commented Feb 13, 2024

CSL-3248 OS UI PLP - Update useCioClient to be like quizzes and autocomplete for consistency

Business Outcome:

  • As Enes I want consistency, not Islam's chaos

Definition of done:

) => Nullable<ConstructorIOClient> | never;
type UseCioClientProps = {
apiKey?: string;
cioClient?: any;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

any since we might want to pass in a node client instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's very unlikely that we will pass a node client to it. Can we make it ConstructorIO from client javascript for now and change it later if we decided that we can pass a node client

Copy link
Contributor Author

Choose a reason for hiding this comment

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

idm going down that path, but TypeScript server-side consumers might feel undervalued

...options,
});
return (
cioClient ||
Copy link
Contributor

@mocca102 mocca102 Feb 15, 2024

Choose a reason for hiding this comment

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

I think we can remove this line 26 ☝️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch!


it('renders CioPlp provider without children on the server without error, if client is provided', () => {
// Render the component to a string
const html = ReactDOMServer.renderToString(<CioPlp cioClient={{}} />);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we're not passing the mocked JS client here?

Copy link
Contributor Author

@Mudaafi Mudaafi Feb 15, 2024

Choose a reason for hiding this comment

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

I was going for an arbitrary client, but we can do that too. Scratch that, did you mean the mock client in test-utils? Wouldn't that resolve to null in this server context?

Copy link
Contributor

Choose a reason for hiding this comment

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

You're correct it's not necessary

});

it('renders CioPlp provider without children on the client without error, if client is provided', () => {
expect(() => render(<CioPlp cioClient={{}} />)).not.toThrow();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we're not passing the mocked JS client here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above, I didn't see the need to specifically pass the mocked client here since an empty object is more generic but I can change that.

Copy link
Contributor

@mocca102 mocca102 left a comment

Choose a reason for hiding this comment

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

I love the changes made here and thank you for adding more tests

@esezen esezen requested a review from mocca102 February 22, 2024 20:56
export type CioPlpConfigs = { apiKey?: string };
export type CioPlpConfigs = {
apiKey?: string;
cioClient?: any;
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we changing this any to Nullable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thought I changed this, thanks for catching it

Copy link
Contributor

@mocca102 mocca102 left a comment

Choose a reason for hiding this comment

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

LGTM!

@Mudaafi Mudaafi merged commit a1c735c into main Mar 1, 2024
@Mudaafi Mudaafi deleted the csl-3248-os-ui-plp-update-usecioclient-to-be-like-quizzes-and branch March 1, 2024 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants