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

refactor:vitest to UserPortal/Organizations #2783

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import Organizations from './Organizations';
import React, { act } from 'react';
const { getItem } = useLocalStorage();

/**
* Mock data for GraphQL queries.
*/

const MOCKS = [
{
request: {
Expand Down Expand Up @@ -317,6 +321,10 @@ const MOCKS = [
},
];

/**
* Custom Mock Link for handling static GraphQL mocks.
*/

const link = new StaticMockLink(MOCKS, true);

async function wait(ms = 100): Promise<void> {
Expand All @@ -333,6 +341,9 @@ const resizeWindow = (width: number): void => {
};

describe('Testing Organizations Screen [User Portal]', () => {
/**
* Test to ensure the screen is rendered properly.
*/
palisadoes marked this conversation as resolved.
Show resolved Hide resolved
test('Screen should be rendered properly', async () => {
render(
<MockedProvider addTypename={false} link={link}>
Expand All @@ -347,8 +358,13 @@ describe('Testing Organizations Screen [User Portal]', () => {
);

await wait();
expect(screen.getByText('My Organizations')).toBeInTheDocument();
});

/**
* Test to check if the search functionality works as expected.
*/

test('Search works properly', async () => {
render(
<MockedProvider addTypename={false} link={link}>
Expand All @@ -374,6 +390,10 @@ describe('Testing Organizations Screen [User Portal]', () => {
await wait();
});

/**
* Test to verify the mode change to joined organizations.
*/

test('Mode is changed to joined organizations', async () => {
render(
<MockedProvider addTypename={false} link={link}>
Expand All @@ -397,6 +417,10 @@ describe('Testing Organizations Screen [User Portal]', () => {
expect(screen.queryAllByText('joinedOrganization')).not.toBe([]);
});

/**
* Test case to ensure the mode can be changed to display created organizations.
*/

test('Mode is changed to created organizations', async () => {
render(
<MockedProvider addTypename={false} link={link}>
Expand All @@ -420,6 +444,10 @@ describe('Testing Organizations Screen [User Portal]', () => {
expect(screen.queryAllByText('createdOrganization')).not.toBe([]);
});

/**
* Test case to check if the "Join Now" button renders correctly on the page.
*/

test('Join Now button render correctly', async () => {
render(
<MockedProvider addTypename={false} link={link}>
Expand Down Expand Up @@ -463,6 +491,10 @@ describe('Testing Organizations Screen [User Portal]', () => {
expect(screen.queryAllByText('createdOrganization')).not.toBe([]);
});

/**
* Test case to ensure the sidebar is functional, including opening and closing actions.
*/

test('Testing Sidebar', async () => {
render(
<MockedProvider addTypename={false} link={link}>
Expand Down
Loading