Skip to content

fix(clerk-js): Fix act output in tests [SDK-1054]#2289

Merged
tmilewski merged 4 commits intomainfrom
SDK-1054-jest-console-output
Dec 7, 2023
Merged

fix(clerk-js): Fix act output in tests [SDK-1054]#2289
tmilewski merged 4 commits intomainfrom
SDK-1054-jest-console-output

Conversation

@tmilewski
Copy link
Copy Markdown
Member

@tmilewski tmilewski commented Dec 7, 2023

Description

Fixes act (and one console.log) output in Jest tests for clerk-js.

SDK-1054

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Packages affected

  • @clerk/backend
  • @clerk/chrome-extension
  • @clerk/clerk-js
  • @clerk/clerk-expo
  • @clerk/fastify
  • gatsby-plugin-clerk
  • @clerk/localizations
  • @clerk/nextjs
  • @clerk/clerk-react
  • @clerk/remix
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/themes
  • @clerk/types
  • build/tooling/chore

@tmilewski tmilewski self-assigned this Dec 7, 2023
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Dec 7, 2023

🦋 Changeset detected

Latest commit: 3fa0fe9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 7, 2023

⚠️ Changes detected under the ClerkJS ui directory!

Don't forget to apply the same changes under the /ui.retheme directory:
packages/clerk-js/src/ui/** ➡️ packages/clerk-js/src/ui.retheme/**

Also, you may need to update the following files:

  • packages/localizations/src/en-US.retheme.ts
  • packages/localizations/src/index.retheme.ts
  • packages/types/src/appearance.retheme.ts
  • packages/types/src/clerk.retheme.ts
  • packages/types/src/index.retheme.ts
  • packages/types/src/localization.retheme.ts

Copy link
Copy Markdown
Contributor

@panteliselef panteliselef left a comment

Choose a reason for hiding this comment

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

🧹 No more "act" errors 🎉

await waitFor(() => {
expect(getByRole('tab', { name: 'Requests' })).toBeInTheDocument();
});
await waitForLoadingCompleted(container);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💯

await waitForLoadingCompleted(container);

const pagination = getByText(/displaying/i).closest('p');
expect(pagination?.textContent).toEqual('Displaying 1 – 5 of 5');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💯

});
const { queryByRole } = await act(() => render(<OrganizationSwitcher />, { wrapper }));

jest.advanceTimersByTime(15000);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do u remember what was the issue here ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've updated this, but a lot of the issues boil down to useDelayedVisibility and its use of setTimeout.

@tmilewski tmilewski added this pull request to the merge queue Dec 7, 2023
Merged via the queue into main with commit d08d969 Dec 7, 2023
@tmilewski tmilewski deleted the SDK-1054-jest-console-output branch December 7, 2023 23:12

const { createFixtures } = bindCreateFixtures('OrganizationProfile');

async function waitForLoadingCompleted(container: HTMLElement) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

❓ Is it possible that the issue is related to using getBy... instead of findBy... which is a combination of waitFor and getBy...?
I would prefer we avoid mingling the logic to wait for a loader to be removed with the usage of waitForLoadingCompleted and depend on findBy... instead.

octoper pushed a commit that referenced this pull request Dec 13, 2023
* fix(clerk-js): Fix unhandled act errors [SDK-1054]

* chore(*): Add changeset

* chore(clerk-js): Add missing awaits

* chore(clerk-js): Minor updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants