diff --git a/src/components/centric/selectCommunity/TcCommunityListItems.tsx b/src/components/centric/selectCommunity/TcCommunityListItems.tsx index df007439..89b0d248 100644 --- a/src/components/centric/selectCommunity/TcCommunityListItems.tsx +++ b/src/components/centric/selectCommunity/TcCommunityListItems.tsx @@ -4,6 +4,7 @@ import TcText from '../../shared/TcText'; import { ICommunity } from '../../../utils/interfaces'; import clsx from 'clsx'; import { StorageService } from '../../../services/StorageService'; +import { MdGroups } from 'react-icons/md'; /** * Props for the TcCommunityListItems component. @@ -17,15 +18,26 @@ interface ITcCommunityListItemsProps { } /** - * Renders a list of community items. + * TcCommunityListItems Component * - * Each item in the list displays an avatar and a label. - * The component ensures that items are displayed with a hover effect and - * a consistent layout across various screen sizes. + * Renders a list of community items, each displaying an avatar and a label. + * Features include: + * - Reading the currently selected community from local storage on initial render. + * - Updating the selected community both internally and via `onSelectCommunity` callback when a community is clicked. + * - Responsive layout for different screen sizes. + * - Displaying a message when there are no communities. * - * @param communities - An array of community data with avatar and label properties. - * @returns A JSX element containing the list of community items. + * Props: + * - communities (ICommunity[]): Array of community objects with `avatarURL` and `name`. + * - onSelectCommunity (Function): Callback when a community is selected. + * + * Usage: + * */ + function TcCommunityListItems({ communities, onSelectCommunity, @@ -62,7 +74,13 @@ function TcCommunityListItems({ key={community.name + index} onClick={() => setSelectedCommunity(community)} > - + {community?.avatarURL ? ( + + ) : ( + + + + )} ))} diff --git a/src/components/centric/selectCommunity/TcSelectCommunity.spec.tsx b/src/components/centric/selectCommunity/TcSelectCommunity.spec.tsx index 3a2854d5..8d5ca63f 100644 --- a/src/components/centric/selectCommunity/TcSelectCommunity.spec.tsx +++ b/src/components/centric/selectCommunity/TcSelectCommunity.spec.tsx @@ -1,21 +1,57 @@ import React from 'react'; -import { render, screen } from '@testing-library/react'; -import '@testing-library/jest-dom/extend-expect'; +import { render, screen, fireEvent } from '@testing-library/react'; import TcCommunityListItems from './TcCommunityListItems'; +import { ICommunity } from '../../../utils/interfaces'; -describe('', () => { - const mockCommunities = [ - { avatar: 'path1', label: 'Community 1' }, - { avatar: 'path2', label: 'Community 2' }, - { avatar: 'path3', label: 'Community 3' }, +describe('TcCommunityListItems', () => { + const mockCommunities: ICommunity[] = [ + { + id: '1', + name: 'Community 1', + platforms: ['platform1', 'platform2'], + users: ['user1', 'user2'], + avatarURL: 'url1', + }, + { + id: '2', + name: 'Community 2', + platforms: ['platform3', 'platform4'], + users: ['user3', 'user4'], + avatarURL: 'url2', + }, ]; - it('renders the community items correctly', () => { - render(); + const onSelectCommunityMock = jest.fn(); - // Check that each community is rendered - mockCommunities.forEach((community) => { - expect(screen.getByText(community.label)).toBeInTheDocument(); - }); + it('renders community items correctly', () => { + render( + + ); + expect(screen.getByText('Community 1')).toBeInTheDocument(); + expect(screen.getByText('Community 2')).toBeInTheDocument(); + }); + + it('calls onSelectCommunity when a community is clicked', () => { + render( + + ); + fireEvent.click(screen.getByText('Community 1')); + expect(onSelectCommunityMock).toHaveBeenCalledWith(mockCommunities[0]); + }); + + it('displays a message when no communities are available', () => { + render( + + ); + expect(screen.getByText('No community exist')).toBeInTheDocument(); }); }); diff --git a/src/components/communitySettings/communityIntegrations/TcAvailableIntegrations.tsx b/src/components/communitySettings/communityIntegrations/TcAvailableIntegrations.tsx index c4b86ed9..79f4823c 100644 --- a/src/components/communitySettings/communityIntegrations/TcAvailableIntegrations.tsx +++ b/src/components/communitySettings/communityIntegrations/TcAvailableIntegrations.tsx @@ -1,11 +1,8 @@ import React from 'react'; import TcAvailableIntegrationsItem from './TcAvailableIntegrationsItem'; import { IntegrationPlatform } from '../../../utils/enums'; -import { useToken } from '../../../context/TokenContext'; function TcAvailableIntegrations() { - const { community } = useToken(); - return (
{Object.values(IntegrationPlatform).map((platform, index) => ( diff --git a/src/components/communitySettings/communityIntegrations/TcConnectedPlatforms.spec.tsx b/src/components/communitySettings/communityIntegrations/TcConnectedPlatforms.spec.tsx index 965773a5..5a819c9d 100644 --- a/src/components/communitySettings/communityIntegrations/TcConnectedPlatforms.spec.tsx +++ b/src/components/communitySettings/communityIntegrations/TcConnectedPlatforms.spec.tsx @@ -1,19 +1,56 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; - import TcConnectedPlatforms from './TcConnectedPlatforms'; -describe('', () => { - it('renders TcConnectedPlatformsItem components based on mock data', () => { - render(); +// Mock the TcConnectedPlatformsItem component since it's imported and used in TcConnectedPlatforms +jest.mock('./TcConnectedPlatformsItem', () => { + return function MockTcConnectedPlatformsItem({ + platform, + }: { + platform: any; + }) { + return ( +
+ {/* Render the platform's name for testing purposes */} + {platform.name} +
+ ); + }; +}); + +describe('TcConnectedPlatforms', () => { + it('renders connected platforms correctly', () => { + // Define mock data for connected platforms + const connectedPlatforms = [ + { + name: 'Platform 1', + community: 'Community 1', + isInProgress: false, + connectedAt: '2023-01-01', + id: '1', + disconnectedAt: null, + metadata: {}, + }, + { + name: 'Platform 2', + community: 'Community 2', + isInProgress: true, + connectedAt: '2023-01-02', + id: '2', + disconnectedAt: null, + metadata: {}, + }, + ]; + + // Render the TcConnectedPlatforms component with the mock data + render(); - // Check if the platform title from mock data is rendered - const allPlatformTitleElements = screen.getAllByText('Discord'); - expect(allPlatformTitleElements[0]).toBeInTheDocument(); + // Check if the platform names are rendered correctly + const platform1Element = screen.getByText('Platform 1'); + const platform2Element = screen.getByText('Platform 2'); - // Check if the community name from mock data is rendered - const communityNameElement = screen.getByText('Togethercrew'); - expect(communityNameElement).toBeInTheDocument(); + expect(platform1Element).toBeInTheDocument(); + expect(platform2Element).toBeInTheDocument(); }); }); diff --git a/src/components/communitySettings/communityIntegrations/TcConnectedPlatformsItem.spec.tsx b/src/components/communitySettings/communityIntegrations/TcConnectedPlatformsItem.spec.tsx index 0e9c24bb..7e825980 100644 --- a/src/components/communitySettings/communityIntegrations/TcConnectedPlatformsItem.spec.tsx +++ b/src/components/communitySettings/communityIntegrations/TcConnectedPlatformsItem.spec.tsx @@ -1,29 +1,27 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; - import TcConnectedPlatformsItem from './TcConnectedPlatformsItem'; describe('', () => { - it('renders the platform title, icon, status, and community info', () => { - const MockIcon = () => MockIcon; - - render( - } - platformTitle="Mock Platform" - status={true} - community={{ - logo: 'https://example.com/logo.png', - name: 'Mock Community', - }} - /> - ); + const mockPlatform = { + name: 'Discord', + community: 'Mock Community', + isInProgress: false, + connectedAt: '2021-01-01', + id: '1', + disconnectedAt: null, + metadata: { + profileImageUrl: 'https://example.com/image.png', + name: 'Example Community', + username: 'exampleuser', + icon: 'icon-id', + }, + }; - // Checking the platform title - expect(screen.getByText('Mock Platform')).toBeInTheDocument(); + it('renders the platform title, status, and community info', () => { + render(); - // Checking the icon - expect(screen.getByText('MockIcon')).toBeInTheDocument(); + expect(screen.getByText('Discord')).toBeInTheDocument(); }); }); diff --git a/src/components/communitySettings/communityIntegrations/TcConnectedPlatformsItem.tsx b/src/components/communitySettings/communityIntegrations/TcConnectedPlatformsItem.tsx index efe9cf0b..fac8de4f 100644 --- a/src/components/communitySettings/communityIntegrations/TcConnectedPlatformsItem.tsx +++ b/src/components/communitySettings/communityIntegrations/TcConnectedPlatformsItem.tsx @@ -1,35 +1,40 @@ /** - * TcConnectedPlatformsItem Component. + * TcConnectedPlatformsItem Component * - * This component displays information about a connected platform, such as: - * - Platform's name and its status (in progress, completed, or error). - * - An icon representing the platform. - * - Community details: logo and name. + * This component displays detailed information about a specific platform connected to a community. + * It includes the platform's name, connection status, and related community details. * * Props: - * - `icon`: A React element representing the platform's icon. - * It can be a JSX element or any component. + * - `platform` (IPlatformProps): An object containing the platform's details, including: + * - `name`: The name of the platform. + * - `community`: The name of the associated community. + * - `isInProgress`: Boolean indicating the connection status of the platform. + * - `connectedAt`: Date string representing when the platform was connected. + * - `id`: The unique identifier of the platform. + * - `disconnectedAt`: Date string or null, indicating when the platform was disconnected, if applicable. + * - `metadata`: An object containing additional metadata about the platform. * - * - `platformTitle`: The name or title of the platform, represented as a string. - * - * - `status`: Represents the platform's connection status. - * It's a boolean value true or false. - * - * - `community`: An object detailing the community associated with the platform: - * - `logo`: A string URL pointing to the community's logo. - * - `name`: The name of the community. + * The component visually represents the platform with an icon, the platform's name, and the community's information. + * It also provides a menu for additional actions, represented by a 'three dots' icon. * * @component * @example - * } - * platformTitle="Some Platform" - * status={true or false} - * community={{ - * logo: 'https://example.com/logo.png', - * name: 'Example Community' - * }} - * /> + * const platform = { + * name: 'Discord', + * community: 'Example Community', + * isInProgress: false, + * connectedAt: '2021-01-01', + * id: '1', + * disconnectedAt: null, + * metadata: { + * profileImageUrl: 'https://example.com/image.png', + * name: 'Example Community', + * username: 'exampleuser', + * icon: 'icon-id' + * } + * }; + * + * */ import React from 'react'; diff --git a/src/components/communitySettings/platform/TcCommunityName.tsx b/src/components/communitySettings/platform/TcCommunityName.tsx index 27c09409..7ef2879f 100644 --- a/src/components/communitySettings/platform/TcCommunityName.tsx +++ b/src/components/communitySettings/platform/TcCommunityName.tsx @@ -13,7 +13,7 @@ function TcCommunityName({ platform }: TccommunityName) { return (
- +
diff --git a/src/components/communitySettings/switchCommunity/TcActiveCommunity.tsx b/src/components/communitySettings/switchCommunity/TcActiveCommunity.tsx index 5101f040..13c58f1e 100644 --- a/src/components/communitySettings/switchCommunity/TcActiveCommunity.tsx +++ b/src/components/communitySettings/switchCommunity/TcActiveCommunity.tsx @@ -8,6 +8,7 @@ import Loading from '../../global/Loading'; import TcInput from '../../shared/TcInput'; import { debounce } from '@mui/material'; import { useSnackbar } from '../../../context/SnackbarContext'; +import { MdGroups } from 'react-icons/md'; const updateCommunityName = debounce( async (communityId, newName, updateFunc, fetchFunc, showSnackbar) => { @@ -98,7 +99,9 @@ function TcActiveCommunity() { src={community?.avatarURL} sx={{ width: 40, height: 40 }} className="mx-auto" - /> + > + + {loading ? ( ) : ( diff --git a/src/components/layouts/Sidebar.tsx b/src/components/layouts/Sidebar.tsx index 6cbf80af..40c17ace 100644 --- a/src/components/layouts/Sidebar.tsx +++ b/src/components/layouts/Sidebar.tsx @@ -10,20 +10,11 @@ type items = { import { conf } from '../../configs/index'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -// import the icons you need -import { - faUserGroup, - faHeartPulse, - faGear, -} from '@fortawesome/free-solid-svg-icons'; +import { faUserGroup, faHeartPulse } from '@fortawesome/free-solid-svg-icons'; -import { Router, useRouter } from 'next/router'; +import { useRouter } from 'next/router'; import Link from 'next/link'; -import { Tooltip, Typography } from '@mui/material'; import useAppStore from '../../store/useStore'; -import { StorageService } from '../../services/StorageService'; -import { IUser } from '../../utils/types'; -import { BsBarChartFill } from 'react-icons/bs'; import { FiSettings } from 'react-icons/fi'; const Sidebar = () => { @@ -42,6 +33,8 @@ const Sidebar = () => { // } }, []); + // `${conf.DISCORD_CDN}icons/${platform.metadata.id}/${platform?.metadata.icon}.png` + const menuItems: items[] = [ { name: 'Community Insights', diff --git a/src/components/layouts/shared/TcPrompt.spec.tsx b/src/components/layouts/shared/TcPrompt.spec.tsx index 6aded069..deeffcc3 100644 --- a/src/components/layouts/shared/TcPrompt.spec.tsx +++ b/src/components/layouts/shared/TcPrompt.spec.tsx @@ -1,59 +1,54 @@ -// TcPrompt.test.js - import React from 'react'; import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import TcPrompt from './TcPrompt'; +import mockRouter from 'next-router-mock'; +import { StorageService } from '../../../services/StorageService'; -const mockedUseRouter = { - pathname: '/', - route: '/', - asPath: '/', - query: {}, - push: jest.fn(), - replace: jest.fn(), - reload: jest.fn(), - back: jest.fn(), - prefetch: jest.fn(), - beforePopState: jest.fn(), - events: { - on: jest.fn(), - off: jest.fn(), - emit: jest.fn(), - }, - isFallback: false, -}; - -jest.mock('next/router', () => ({ - useRouter: () => { - return mockedUseRouter; - }, -})); +jest.mock('next/router', () => require('next-router-mock')); +jest.mock('../../../services/StorageService'); describe('TcPrompt', () => { + beforeEach(() => { + jest.clearAllMocks(); + jest.spyOn(StorageService, 'readLocalStorage').mockImplementation((key) => { + if (key === 'community') { + return { platforms: [] }; // Adjust this return value as needed for different test cases + } + return undefined; + }); + }); + test('renders without crashing', () => { + mockRouter.setCurrentUrl('/'); render(); + // Additional checks can be added here }); - test.each([ - [ - '/', - 'To see the data, connect your community platforms.', - 'Connect Community', - ], - [ - '/growth', - 'To see the data, connect your community’s Twitter account', - 'Connect Twitter account', - ], - ])( - 'renders correct message and buttonText for route: %s', - (pathname, expectedMessage, expectedButtonText) => { - mockedUseRouter.pathname = pathname; - render(); + test('renders prompt when no platforms are connected', () => { + mockRouter.setCurrentUrl('/'); + render(); + expect( + screen.getByText('To see the data, connect your community platforms.') + ).toBeInTheDocument(); + }); - expect(screen.getByText(expectedMessage)).toBeInTheDocument(); - expect(screen.getByText(expectedButtonText)).toBeInTheDocument(); - } - ); + test('does not render prompt on excluded routes', () => { + mockRouter.setCurrentUrl('/cetric'); + render(); + expect( + screen.queryByText('To see the data, connect your community platforms.') + ).not.toBeInTheDocument(); + }); + + test('does not render prompt when platforms are connected', () => { + mockRouter.setCurrentUrl('/'); + jest + .spyOn(StorageService, 'readLocalStorage') + .mockReturnValue({ platforms: ['Discord'] }); + render(); + expect( + screen.queryByText('To see the data, connect your community platforms.') + ).not.toBeInTheDocument(); + }); }); diff --git a/src/components/shared/TcAutocomplete/TcAutocomplete.spec.tsx b/src/components/shared/TcAutocomplete/TcAutocomplete.spec.tsx deleted file mode 100644 index 9677d145..00000000 --- a/src/components/shared/TcAutocomplete/TcAutocomplete.spec.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import React from 'react'; -import { render, fireEvent, screen } from '@testing-library/react'; -import '@testing-library/jest-dom'; -import TcAutocomplete from './TcAutocomplete'; - -describe('TcAutocomplete Component', () => { - const mockOptions = [ - { label: 'Option 1', id: 1 }, - { label: 'Option 2', id: 2 }, - // ... more options - ]; - - test('renders autocomplete component', () => { - render( - {}} - /> - ); - expect(screen.getByLabelText('Test Autocomplete')).toBeInTheDocument(); - }); - - test('displays options when typed in', () => { - render( - {}} - /> - ); - const input = screen.getByRole('combobox'); - fireEvent.change(input, { target: { value: 'Option' } }); - expect(screen.getByText('Option 1')).toBeInTheDocument(); - expect(screen.getByText('Option 2')).toBeInTheDocument(); - }); - - test('calls onChange when an option is selected', () => { - const handleChange = jest.fn(); - render( - - ); - const input = screen.getByRole('combobox'); - fireEvent.change(input, { target: { value: 'Option 1' } }); - fireEvent.click(screen.getByText('Option 1')); - expect(handleChange).toHaveBeenCalledWith(mockOptions[0]); - }); -}); diff --git a/src/components/shared/TcAutocomplete/TcAutocomplete.tsx b/src/components/shared/TcAutocomplete/TcAutocomplete.tsx deleted file mode 100644 index efa60196..00000000 --- a/src/components/shared/TcAutocomplete/TcAutocomplete.tsx +++ /dev/null @@ -1,53 +0,0 @@ -/** - * TcAutocomplete Component - * - * A reusable autocomplete component using Material-UI's Autocomplete. - * This component allows users to search and select from a list of options. - * - * Props: - * - options: Array of objects representing the autocomplete options. Each object should have a `label` property. - * - label: String to display as the label of the text field. - * - onChange: Function called when an option is selected. It receives the new value as its argument. - * - ...props: Any additional props to spread onto the MUI Autocomplete component. - * - * Example Usage: - * - */ - -import React from 'react'; -import Autocomplete from '@mui/material/Autocomplete'; -import TcInput from '../TcInput'; - -interface TcAutocompleteProps { - options: Array<{ - label: string; - [key: string]: any; - }>; - label: string; - onChange: (newValue: any) => void; - [x: string]: any; -} - -const TcAutocomplete: React.FC = ({ - options, - label, - onChange, - ...props -}) => { - return ( - onChange(newValue)} - getOptionLabel={(option) => option.label} - renderInput={(params) => ( - - )} - {...props} - /> - ); -}; - -export default TcAutocomplete; diff --git a/src/components/shared/TcAutocomplete/index.ts b/src/components/shared/TcAutocomplete/index.ts deleted file mode 100644 index 825d6407..00000000 --- a/src/components/shared/TcAutocomplete/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { default as TcAutocomplete } from './TcAutocomplete'; - -export default TcAutocomplete; diff --git a/src/pages/callback.spec.tsx b/src/pages/callback.spec.tsx deleted file mode 100644 index 54c2c314..00000000 --- a/src/pages/callback.spec.tsx +++ /dev/null @@ -1,81 +0,0 @@ -import React from 'react'; -import { render, screen, waitFor } from '@testing-library/react'; -import { useRouter } from 'next/router'; -import Callback from './callback'; -import { StatusCode } from '../utils/enums'; - -jest.mock('next/router', () => ({ - useRouter: jest.fn(), -})); - -describe('Callback component', () => { - let mockUseRouter: jest.Mock; - - beforeEach(() => { - mockUseRouter = useRouter as jest.Mock; - }); - - it('should show repeated discord authorization attempt message', async () => { - mockUseRouter.mockReturnValue({ - isReady: true, - asPath: `/callback?statusCode=${StatusCode.REPEATED_DISCORD_AUTHORIZATION_ATTEMPT}`, - }); - - render(); - - await waitFor(() => { - expect( - screen.getByText( - 'You have authorized before and are trying to authorize again.' - ) - ).toBeInTheDocument(); - }); - }); - - it('should show successful first time discord authorization message', async () => { - mockUseRouter.mockReturnValue({ - isReady: true, - asPath: `/callback?statusCode=${StatusCode.DISCORD_AUTHORIZATION_SUCCESSFUL_FIRST_TIME}`, - }); - - render(); - - await waitFor(() => { - expect( - screen.getByText('Welcome! Authorization for sign-in was successful.') - ).toBeInTheDocument(); - }); - }); - - it('should show discord authorization failure message', async () => { - mockUseRouter.mockReturnValue({ - isReady: true, - asPath: `/callback?statusCode=${StatusCode.DISCORD_AUTHORIZATION_FAILURE}`, - }); - - render(); - - await waitFor(() => { - expect( - screen.getByText('Authorization failed. Please try again.') - ).toBeInTheDocument(); - }); - }); - - it('should handle no status code in URL', async () => { - mockUseRouter.mockReturnValue({ - isReady: true, - asPath: '/callback', - }); - - render(); - - await waitFor(() => { - expect( - screen.getByText( - 'An error occurred while processing your request. Please try again.' - ) - ).toBeInTheDocument(); - }); - }); -}); diff --git a/src/pages/callback.tsx b/src/pages/callback.tsx index 50c99e52..7ae311f7 100644 --- a/src/pages/callback.tsx +++ b/src/pages/callback.tsx @@ -133,6 +133,10 @@ function Callback() { setMessage('Twitter Authorization failed.'); router.push('/community-settings'); + case StatusCode.DISCORD_AUTHORIZATION_FAILURE_FROM_SETTINGS: + setMessage('Discord Authorization during setup on setting faield.'); + router.push('/community-settings'); + default: console.error('Unexpected status code received:', code); setMessage('An unexpected error occurred. Please try again later.'); @@ -164,7 +168,7 @@ function Callback() { } }, [router.isReady]); - return ; + return ; } export default Callback; diff --git a/src/pages/centric/create-new-community.spec.tsx b/src/pages/centric/create-new-community.spec.tsx deleted file mode 100644 index 2faf84dd..00000000 --- a/src/pages/centric/create-new-community.spec.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react'; -import { render, screen } from '@testing-library/react'; -import '@testing-library/jest-dom/extend-expect'; -import userEvent from '@testing-library/user-event'; -import CreateNewCommunity from './create-new-community'; - -describe('CreateNewCommunity', () => { - it('renders the TcBoxContainer with correct content', () => { - render(); - - expect( - screen.getByText('Create a new community account') - ).toBeInTheDocument(); - expect(screen.getByLabelText('Community name')).toBeInTheDocument(); - expect(screen.getByText('Privacy Policy')).toBeInTheDocument(); - expect(screen.getByText('Terms of Service.')).toBeInTheDocument(); - expect(screen.getByRole('checkbox')).toBeInTheDocument(); - expect(screen.getByText('Create community')).toBeInTheDocument(); - }); - - it('allows user to check the agreement checkbox', () => { - render(); - - const checkbox = screen.getByRole('checkbox'); - expect(checkbox).not.toBeChecked(); - userEvent.click(checkbox); - expect(checkbox).toBeChecked(); - }); -}); diff --git a/src/pages/centric/index.spec.tsx b/src/pages/centric/index.spec.tsx deleted file mode 100644 index f91726e1..00000000 --- a/src/pages/centric/index.spec.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import React, { ClassAttributes, ImgHTMLAttributes } from 'react'; -import { render, fireEvent } from '@testing-library/react'; -import '@testing-library/jest-dom/extend-expect'; // for the "toBeInTheDocument" matcher -import Index from './index'; -import router from 'next/router'; - -// Mock the next/router push function -jest.mock('next/router', () => ({ - ...jest.requireActual('next/router'), - push: jest.fn(), -})); - -describe('', () => { - it('renders the Connect your Discord title', () => { - const { getByText } = render(); - expect(getByText('Connect your Discord')).toBeInTheDocument(); - }); - - it('renders the button and checks if it redirects on click', () => { - const { getByText } = render(); - const button = getByText('Connect your Discord'); - fireEvent.click(button); - expect(router.push).toHaveBeenCalledWith('/centric/tac'); - }); - - it('renders the text about more login options', () => { - const { getByText } = render(); - expect(getByText('More log-in options comming soon.')).toBeInTheDocument(); - }); -}); diff --git a/src/pages/centric/index.tsx b/src/pages/centric/index.tsx index 3bbee4d4..e6b655f5 100644 --- a/src/pages/centric/index.tsx +++ b/src/pages/centric/index.tsx @@ -3,7 +3,6 @@ import centricLayout from '../../layouts/centricLayout'; import TcBoxContainer from '../../components/shared/TcBox/TcBoxContainer'; import TcText from '../../components/shared/TcText'; import TcButton from '../../components/shared/TcButton'; -import router from 'next/router'; import useAppStore from '../../store/useStore'; function Index() { diff --git a/src/pages/centric/select-community.spec.tsx b/src/pages/centric/select-community.spec.tsx deleted file mode 100644 index 7682a67e..00000000 --- a/src/pages/centric/select-community.spec.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import React from 'react'; -import { render } from '@testing-library/react'; -import '@testing-library/jest-dom/extend-expect'; // for the "toBeInTheDocument" matcher -import SelectCommunity from './select-community'; - -describe('SelectCommunity', () => { - it('renders the TcBoxContainer', () => { - const { getByTestId } = render(); - - // Ensure TcBoxContainer is in the document. - // Note: You would need to add "data-testid='tcbox-container'" to TcBoxContainer in your component. - const boxContainer = getByTestId('tcbox-container'); - expect(boxContainer).toBeInTheDocument(); - }); - - it('renders the TcSelectCommunity inside the TcBoxContainer', () => { - const { getByTestId } = render(); - - // Ensure TcSelectCommunity is in the document. - // Note: You would need to add "data-testid='tcselect-community'" to TcSelectCommunity in your component. - const selectCommunityComponent = getByTestId('tcselect-community'); - expect(selectCommunityComponent).toBeInTheDocument(); - }); -}); diff --git a/src/pages/centric/tac.spec.tsx b/src/pages/centric/tac.spec.tsx deleted file mode 100644 index 0e15c938..00000000 --- a/src/pages/centric/tac.spec.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import React from 'react'; -import { render, fireEvent } from '@testing-library/react'; -import '@testing-library/jest-dom/extend-expect'; // for the "toBeInTheDocument" and other extended matchers -import Tac from './tac'; - -describe('tac Component', () => { - it('renders correctly', () => { - const { getByText } = render(); - expect(getByText('One more thing...')).toBeInTheDocument(); - expect( - getByText('Please take a moment to familiarize yourself with') - ).toBeInTheDocument(); - }); - - it('has the correct link', () => { - const { getByText } = render(); - const link = getByText('Privacy Policy and Terms of Service.'); - expect(link).toHaveAttribute( - 'href', - 'https://www.togethercrew.com/privacy-and-terms' - ); - }); - - it('can toggle the checkbox', () => { - const { getByRole } = render(); - const checkbox = getByRole('checkbox'); - expect(checkbox).not.toBeChecked(); - fireEvent.click(checkbox); - expect(checkbox).toBeChecked(); - }); - - it('has a Continue button', () => { - const { getByText } = render(); - const button = getByText('Continue'); - expect(button).toBeInTheDocument(); - // If you have further behaviors linked to this button, you would add more tests (like checking if a function is called when it's clicked, etc.) - }); -});