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

Release@next [] #219

Merged
merged 271 commits into from
Jan 8, 2024
Merged

Release@next [] #219

merged 271 commits into from
Jan 8, 2024

Conversation

chasepoirier
Copy link
Contributor

No description provided.

chasepoirier and others added 30 commits September 28, 2023 10:21
@chasepoirier chasepoirier requested a review from a team January 5, 2024 19:03
… and fetchById methods (#206)

* feat: add useFetchBySlug, useFetchById hooks and plain js fetchBySlug and fetchById methods

* chore: fix test

* chore: renaming isFetching to isLoading

* chore: fix tests

* chore: changing types name to match style guide

* chore: lint fixes

* chore: update readme with example of useFetchBySlug
packages/core/src/fetchers/fetchBySlug.ts Show resolved Hide resolved
Comment on lines 14 to 26
try {
await fetchExperienceEntry({
// @ts-expect-error intentionally setting it to undefined
client: undefined,
experienceTypeId: 'books',
locale: 'en-US',
identifier: { slug: 'slug' },
});
} catch (e) {
expect((e as Error).message).toBe(
'Failed to fetch experience entities. Required "client" parameter was not provided'
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

[request change]
This test won't function correctly. If the function doesn't throw an error, we don't call expect and thus don't make the test as failed. Also expect calls should never be conditionally but also have to be called. Please have a look at the docs of toThrow (here) and rejects (here).

    await expect(async () => {
      await fetchExperienceEntry({
        // @ts-expect-error intentionally setting it to undefined
        client: undefined,
        experienceTypeId: 'books',
        locale: 'en-US',
        identifier: { slug: 'slug' },
      });
    }).rejects.toThrow('Failed to fetch experience entities. Required "client" parameter was not provided');

The same goes for the other broken tests in this file.

Copy link
Member

Choose a reason for hiding this comment

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

These tests were brought over from the other project, so they would of had the issue there as well. I'll take a look at the suggestion and improve it.

Comment on lines +14 to +25
try {
await fetchReferencedEntities({
// @ts-expect-error intentionally setting it to undefined
client: undefined,
experienceEntry: compositionEntry,
locale: 'en-US',
});
} catch (e) {
expect((e as Error).message).toBe(
'Failed to fetch experience entities. Required "client" parameter was not provided'
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

[request change]
Same feedback as for the tets in fetchExperienceEntry.spec.ts that try/catch clauses are not working for jest tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

[nitpick]
There is a typo in this file name. It should be feetchExperienceEntry.spec.ts.

Comment on lines +40 to +43
await waitFor(() => {
expect(result.current).toBeDefined();
expect(result.current.isLoading).toBe(true);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

[nitpick]
waitFor is not meant to be used with multiple assertions and can lead to unwanted issues:

Suggested change
await waitFor(() => {
expect(result.current).toBeDefined();
expect(result.current.isLoading).toBe(true);
});
await waitFor(() => expect(result.current?.isLoading).toBe(true));

See here for more explanation on this: https://kentcdodds.com/blog/common-mistakes-with-react-testing-library#having-multiple-assertions-in-a-single-waitfor-callback

},
});

await waitFor(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

[nitpick]
Same problem as with in the comment above. Especially this waitFor is a very brittle check that can easily break.

},
});

await waitFor(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

[nitpick]
Same feedback about invalid multiple assertions in waitFor

Copy link
Contributor

Choose a reason for hiding this comment

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

This is multiple times happening in this test file.

);
} catch (e) {
expect((e as Error).message).toBe(
Copy link
Contributor

Choose a reason for hiding this comment

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

[nitpick]
Same feedback as above that try/catch doesn't work in jest tests as intended. Use toThrow instead.

localeCode,
}: useClientSideExperienceFetchersProps) => {
/**
* @deprecated please use `useFetchBySlug` or `useFetchById` hooks instead
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we can remove this one as well as part of the major release?

Copy link
Member

Choose a reason for hiding this comment

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

This will be the first release where it is deprecated. I'd usually wait at least one release to let users move over before it is removed, but since this is alpha its not as big of a deal. Might be good to chat about it as a whole.

Copy link
Contributor

@Chaoste Chaoste 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 providing this PR, re-structuring our logic and merging all these improvements :)
I initially requested changes on a few nitpicks and not working unit tests but I guess it's better to merge this one first and then create additional PRs based on those as this is not blocking.

Note: at least we might wanna consider removing deprecated methods as part of this major release.

Co-authored-by: Thomas Kellermeier <Chaoste@users.noreply.github.com>
Co-authored-by: Thomas Kellermeier <Chaoste@users.noreply.github.com>
…onfigure ctfl env vars via localStorage [] (#215)

* chore: wip

* chore: wip

* feat(test-app): add ability to configure ctfl env vars via localStorage

* chore(visual-editor-app): removing visual-editor-app package

* chore: package-lock fix
@chasepoirier chasepoirier merged commit a4480ce into next Jan 8, 2024
7 checks passed
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.

6 participants