diff --git a/src/screens/OrgList/OrganizationModal.tsx b/src/screens/OrgList/OrganizationModal.tsx
index 8a44d2b851..fb3589d1e5 100644
--- a/src/screens/OrgList/OrganizationModal.tsx
+++ b/src/screens/OrgList/OrganizationModal.tsx
@@ -2,7 +2,7 @@ import React from 'react';
import { Modal, Form, Row, Col, Button } from 'react-bootstrap';
import convertToBase64 from 'utils/convertToBase64';
import type { ChangeEvent } from 'react';
-import styles from './OrgList.module.css';
+import styles from '../../style/app.module.css';
import type { InterfaceAddress } from 'utils/interfaces';
import { countryOptions } from 'utils/formEnumFields';
import useLocalStorage from 'utils/useLocalstorage';
diff --git a/src/style/app.module.css b/src/style/app.module.css
index 1903c7b323..4acd2c72be 100644
--- a/src/style/app.module.css
+++ b/src/style/app.module.css
@@ -1279,3 +1279,316 @@ input[type='radio']:checked + label {
max-height: 220px;
overflow-y: auto;
}
+
+/* * Refortoring css for OrgList */
+
+.btnsContainerOrgList {
+ display: flex;
+ margin: 2.5rem 0 2.5rem 0;
+}
+
+.btnsContainerOrgList .btnsBlockOrgList {
+ display: flex;
+}
+
+.orgCreationBtn {
+ width: 100%;
+ border: None;
+}
+
+.enableEverythingBtn {
+ width: 100%;
+ border: None;
+}
+
+.pluginStoreBtn {
+ width: 100%;
+ background-color: white;
+ color: var(--brown-color);
+ border: 0.5px solid var(--brown-color);
+}
+.searchButtonOrgList {
+ position: absolute;
+ z-index: 10;
+ bottom: 0;
+ inset-inline-end: 0px;
+ height: 100%;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+}
+
+.pluginStoreBtn:hover,
+.pluginStoreBtn:focus {
+ background-color: var(--dropdown-hover-color) !important;
+ color: var(--brown-color) !important;
+ border-color: var(--brown-color) !important;
+}
+
+.flexContainer {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ width: 100%;
+}
+
+.orText {
+ display: block;
+ position: absolute;
+ top: -0.2rem;
+ left: calc(50% - 2.6rem);
+ margin: 0 auto;
+ padding: 0.5rem 2rem;
+ z-index: 100;
+ background: var(--bs-white);
+ color: var(--bs-secondary);
+}
+
+.sampleOrgSection {
+ display: grid;
+ grid-template-columns: repeat(1, 1fr);
+ row-gap: 1em;
+ width: 100%;
+}
+
+.sampleOrgCreationBtn {
+ width: 100%;
+ background-color: transparent;
+ color: #707070;
+ border-color: #707070;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+}
+
+.sampleHover:hover {
+ border-color: grey;
+ color: grey;
+}
+
+.sampleModalTitle {
+ background-color: var(--bs-primary);
+}
+
+.btnsContainerOrgList .btnsBlockOrgList button {
+ margin-left: 1rem;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+}
+
+.btnsContainerOrgList .inputOrgList {
+ flex: 1;
+ position: relative;
+}
+
+.btnsContainerOrgList input {
+ outline: 1px solid var(--bs-gray-400);
+}
+
+.btnsContainerOrgList .inputOrgList button {
+ width: 52px;
+}
+
+.listBoxOrgList {
+ display: flex;
+ flex-wrap: wrap;
+ overflow: unset !important;
+}
+
+.listBoxOrgList .itemCardOrgList {
+ width: 50%;
+}
+
+.notFound {
+ flex: 1;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ flex-direction: column;
+}
+
+@media (max-width: 1440px) {
+ .contractOrgList {
+ padding-left: calc(250px + 2rem + 1.5rem);
+ }
+
+ .listBoxOrgList .itemCardOrgList {
+ width: 100%;
+ }
+}
+
+@media (max-width: 1020px) {
+ .btnsContainerOrgList {
+ flex-direction: column;
+ margin: 1.5rem 0;
+ }
+
+ .btnsContainerOrgList .btnsBlockOrgList {
+ margin: 1.5rem 0 0 0;
+ justify-content: space-between;
+ }
+
+ .btnsContainerOrgList .btnsBlockOrgList button {
+ margin: 0;
+ }
+
+ .btnsContainerOrgList .btnsBlockOrgList div button {
+ margin-right: 1.5rem;
+ }
+}
+
+/* For mobile devices */
+
+@media (max-width: 520px) {
+ .btnsContainerOrgList {
+ margin-bottom: 0;
+ }
+
+ .btnsContainerOrgList .btnsBlockOrgList {
+ display: block;
+ margin-top: 1rem;
+ margin-right: 0;
+ }
+
+ .btnsContainerOrgList .btnsBlockOrgList div {
+ flex: 1;
+ }
+
+ .btnsContainerOrgList .btnsBlockOrgList div[title='Sort organizations'] {
+ margin-right: 0.5rem;
+ }
+
+ .btnsContainerOrgList .btnsBlockOrgList button {
+ margin-bottom: 1rem;
+ margin-right: 0;
+ width: 100%;
+ }
+}
+
+/* Loading OrgList CSS */
+
+.itemCardOrgList .loadingWrapper {
+ background-color: var(--bs-white);
+ margin: 0.5rem;
+ height: calc(120px + 2rem);
+ padding: 1rem;
+ border-radius: 8px;
+ outline: 1px solid var(--bs-gray-200);
+ position: relative;
+}
+
+.itemCardOrgList .loadingWrapper .innerContainer {
+ display: flex;
+}
+
+.itemCardOrgList .loadingWrapper .innerContainer .orgImgContainer {
+ width: 120px;
+ height: 120px;
+ border-radius: 4px;
+}
+
+.itemCardOrgList .loadingWrapper .innerContainer .content {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ margin-left: 1rem;
+}
+
+.titlemodaldialog {
+ color: #707070;
+ font-size: 20px;
+ margin-bottom: 20px;
+ padding-bottom: 5px;
+}
+
+form label {
+ font-weight: bold;
+ padding-bottom: 1px;
+ font-size: 14px;
+ color: #707070;
+}
+
+form > input {
+ display: block;
+ margin-bottom: 20px;
+ border: 1px solid #e8e5e5;
+ box-shadow: 2px 1px #e8e5e5;
+ padding: 10px 20px;
+ border-radius: 5px;
+ background: none;
+ width: 100%;
+ transition: all 0.3s ease-in-out;
+ -webkit-transition: all 0.3s ease-in-out;
+ -moz-transition: all 0.3s ease-in-out;
+ -ms-transition: all 0.3s ease-in-out;
+ -o-transition: all 0.3s ease-in-out;
+}
+
+.itemCardOrgList .loadingWrapper .innerContainer .content h5 {
+ height: 24px;
+ width: 60%;
+ margin-bottom: 0.8rem;
+}
+
+.modalbody {
+ width: 50px;
+}
+
+.pluginStoreBtnContainer {
+ display: flex;
+ gap: 1rem;
+}
+
+.itemCardOrgList .loadingWrapper .innerContainer .content h6[title='Location'] {
+ display: block;
+ width: 45%;
+ height: 18px;
+}
+
+.itemCardOrgList .loadingWrapper .innerContainer .content h6 {
+ display: block;
+ width: 30%;
+ height: 16px;
+ margin-bottom: 0.8rem;
+}
+
+.itemCardOrgList .loadingWrapper .button {
+ position: absolute;
+ height: 48px;
+ width: 92px;
+ bottom: 1rem;
+ right: 1rem;
+ z-index: 1;
+}
+
+@media (max-width: 450px) {
+ .itemCardOrgList .loadingWrapper {
+ height: unset;
+ margin: 0.5rem 0;
+ padding: 1.25rem 1.5rem;
+ }
+
+ .itemCardOrgList .loadingWrapper .innerContainer {
+ flex-direction: column;
+ }
+
+ .itemCardOrgList .loadingWrapper .innerContainer .orgImgContainer {
+ height: 200px;
+ width: 100%;
+ margin-bottom: 0.8rem;
+ }
+
+ .itemCardOrgList .loadingWrapper .innerContainer .content {
+ margin-left: 0;
+ }
+
+ .itemCardOrgList .loadingWrapper .button {
+ bottom: 0;
+ right: 0;
+ border-radius: 0.5rem;
+ position: relative;
+ margin-left: auto;
+ display: block;
+ }
+}
From 8ec66eafa20ef0d3325d7da6b6a01cf92d2e55b6 Mon Sep 17 00:00:00 2001
From: Bandhan Majumder <133476557+bandhan-majumder@users.noreply.github.com>
Date: Tue, 24 Dec 2024 19:56:30 +0530
Subject: [PATCH 12/28] refactor: jest to vitest of OrganizationActionItems :
fixes #2557 (#2773)
* added missed mocks
Not all the params were being mocked properly. As a result of not getting the expected response, useQuery was returning error in actionItemsError. This is fixed now
* Delete src/screens/OrganizationActionItems/OrganizationActionItems.test.tsx
* Create OrganizationActionItems.spec.tsx
Migrated to vitest with functionalities
* Update OrganizationActionItems.spec.tsx
---
.../OrganizationActionItem.mocks.ts | 10 +
.../OrganizationActionItems.spec.tsx | 663 ++++++++++++++++++
.../OrganizationActionItems.test.tsx | 359 ----------
3 files changed, 673 insertions(+), 359 deletions(-)
create mode 100644 src/screens/OrganizationActionItems/OrganizationActionItems.spec.tsx
delete mode 100644 src/screens/OrganizationActionItems/OrganizationActionItems.test.tsx
diff --git a/src/screens/OrganizationActionItems/OrganizationActionItem.mocks.ts b/src/screens/OrganizationActionItems/OrganizationActionItem.mocks.ts
index d7d661fc9d..88f4ed3eef 100644
--- a/src/screens/OrganizationActionItems/OrganizationActionItem.mocks.ts
+++ b/src/screens/OrganizationActionItems/OrganizationActionItem.mocks.ts
@@ -24,6 +24,7 @@ export const MOCKS = [
query: ACTION_ITEM_LIST,
variables: {
organizationId: 'orgId',
+ eventId: 'eventId',
orderBy: null,
where: {
assigneeName: '',
@@ -47,6 +48,7 @@ export const MOCKS = [
query: ACTION_ITEM_LIST,
variables: {
organizationId: 'orgId',
+ eventId: 'eventId',
orderBy: null,
where: {
categoryName: '',
@@ -64,6 +66,7 @@ export const MOCKS = [
query: ACTION_ITEM_LIST,
variables: {
organizationId: 'orgId',
+ eventId: 'eventId',
orderBy: 'dueDate_ASC',
where: {
assigneeName: '',
@@ -81,6 +84,7 @@ export const MOCKS = [
query: ACTION_ITEM_LIST,
variables: {
organizationId: 'orgId',
+ eventId: 'eventId',
orderBy: 'dueDate_DESC',
where: {
assigneeName: '',
@@ -98,6 +102,7 @@ export const MOCKS = [
query: ACTION_ITEM_LIST,
variables: {
organizationId: 'orgId',
+ eventId: 'eventId',
orderBy: null,
where: {
assigneeName: '',
@@ -116,6 +121,7 @@ export const MOCKS = [
query: ACTION_ITEM_LIST,
variables: {
organizationId: 'orgId',
+ eventId: 'eventId',
orderBy: null,
where: {
assigneeName: '',
@@ -134,6 +140,7 @@ export const MOCKS = [
query: ACTION_ITEM_LIST,
variables: {
organizationId: 'orgId',
+ eventId: 'eventId',
orderBy: null,
where: {
assigneeName: 'John',
@@ -151,6 +158,7 @@ export const MOCKS = [
query: ACTION_ITEM_LIST,
variables: {
organizationId: 'orgId',
+ eventId: 'eventId',
orderBy: null,
where: {
categoryName: 'Category 1',
@@ -407,6 +415,7 @@ export const MOCKS_ERROR = [
query: ACTION_ITEM_LIST,
variables: {
organizationId: 'orgId',
+ eventId: 'eventId',
orderBy: null,
where: {
assigneeName: '',
@@ -474,6 +483,7 @@ export const MOCKS_EMPTY = [
query: ACTION_ITEM_LIST,
variables: {
organizationId: 'orgId',
+ eventId: 'eventId',
orderBy: null,
where: {
assigneeName: '',
diff --git a/src/screens/OrganizationActionItems/OrganizationActionItems.spec.tsx b/src/screens/OrganizationActionItems/OrganizationActionItems.spec.tsx
new file mode 100644
index 0000000000..7ae0fc58eb
--- /dev/null
+++ b/src/screens/OrganizationActionItems/OrganizationActionItems.spec.tsx
@@ -0,0 +1,663 @@
+import React, { act } from 'react';
+import { MockedProvider } from '@apollo/react-testing';
+import { LocalizationProvider } from '@mui/x-date-pickers';
+import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
+import { fireEvent, render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { I18nextProvider } from 'react-i18next';
+import { Provider } from 'react-redux';
+import { MemoryRouter, Route, Routes } from 'react-router-dom';
+import { store } from 'state/store';
+import { StaticMockLink } from 'utils/StaticMockLink';
+import i18n from 'utils/i18nForTest';
+import OrganizationActionItems from 'screens/OrganizationActionItems/OrganizationActionItems';
+
+import {
+ MOCKS,
+ MOCKS_EMPTY,
+ MOCKS_ERROR,
+} from './OrganizationActionItem.mocks';
+import { vi } from 'vitest';
+
+vi.mock('react-toastify', () => ({
+ toast: {
+ success: vi.fn(),
+ error: vi.fn(),
+ },
+}));
+
+vi.mock('@mui/x-date-pickers/DateTimePicker', async () => {
+ return {
+ DateTimePicker: (
+ await vi.importActual('@mui/x-date-pickers/DesktopDateTimePicker')
+ ).DesktopDateTimePicker,
+ };
+});
+
+const link1 = new StaticMockLink(MOCKS);
+const link2 = new StaticMockLink(MOCKS_ERROR);
+const link3 = new StaticMockLink(MOCKS_EMPTY);
+const t = {
+ ...JSON.parse(
+ JSON.stringify(
+ i18n.getDataByLanguage('en')?.translation.organizationActionItems ?? {},
+ ),
+ ),
+ ...JSON.parse(JSON.stringify(i18n.getDataByLanguage('en')?.common ?? {})),
+ ...JSON.parse(JSON.stringify(i18n.getDataByLanguage('en')?.errors ?? {})),
+};
+
+const debounceWait = async (ms = 300): Promise
=> {
+ await act(() => {
+ return new Promise((resolve) => {
+ setTimeout(resolve, ms);
+ });
+ });
+};
+
+describe('Testing Organization Action Items Screen', () => {
+ beforeAll(() => {
+ vi.mock('react-router-dom', async () => ({
+ ...(await vi.importActual('react-router-dom')),
+ useParams: () => ({ orgId: 'orgId', eventId: 'eventId' }),
+ }));
+ });
+
+ afterAll(() => {
+ vi.clearAllMocks();
+ vi.clearAllTimers();
+ });
+
+ it('should redirect to fallback URL if URL params are undefined', async () => {
+ render(
+
+
+
+
+
+
+ }
+ />
+ }
+ />
+
+
+
+
+
+ ,
+ );
+
+ await waitFor(() => {
+ expect(window.location.pathname).toBe('/');
+ });
+ });
+
+ it('should render Organization Action Items screen', async () => {
+ render(
+