Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alan2207 committed Aug 18, 2024
1 parent 468d98e commit ddb3afa
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 33 deletions.
16 changes: 0 additions & 16 deletions apps/nextjs-pages/src/components/seo/__tests__/head.test.tsx

This file was deleted.

2 changes: 2 additions & 0 deletions apps/nextjs-pages/src/lib/__tests__/authorization.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ test('should not view protected resource if user role does not match and show fa
{ user },
);

await screen.findByText(forbiddenMessage);

expect(screen.queryByText(protectedResource)).not.toBeInTheDocument();

expect(screen.getByText(forbiddenMessage)).toBeInTheDocument();
Expand Down
5 changes: 4 additions & 1 deletion apps/nextjs-pages/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export const HomePage = () => {

return (
<>
<Head description="Welcome to bulletproof react" />
<Head
title={'Bulletproof React'}
description="Welcome to bulletproof react"
/>
<div className="flex h-screen items-center bg-white">
<div className="mx-auto max-w-7xl px-4 py-12 text-center sm:px-6 lg:px-8 lg:py-16">
<h2 className="text-3xl font-extrabold tracking-tight text-gray-900 sm:text-4xl">
Expand Down
17 changes: 1 addition & 16 deletions apps/nextjs-pages/src/testing/test-utils.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
render as rtlRender,
screen,
waitForElementToBeRemoved,
} from '@testing-library/react';
import { render as rtlRender } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import Cookies from 'js-cookie';

Expand Down Expand Up @@ -33,15 +29,6 @@ export const loginAsUser = async (user: any) => {
return authUser;
};

export const waitForLoadingToFinish = () =>
waitForElementToBeRemoved(
() => [
...screen.queryAllByTestId(/loading/i),
...screen.queryAllByText(/loading/i),
],
{ timeout: 4000 },
);

const initializeUser = async (user: any) => {
if (typeof user === 'undefined') {
const newUser = await createUser();
Expand All @@ -68,8 +55,6 @@ export const renderApp = async (
user: initializedUser,
};

await waitForLoadingToFinish();

return returnValue;
};

Expand Down

0 comments on commit ddb3afa

Please sign in to comment.