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

[INJIWEB-Id4Africa Event]: PDF Template changes, Logo Changes, Responsivenes and Mock Credential Download #67

Merged
merged 8 commits into from
May 14, 2024
7 changes: 4 additions & 3 deletions helm/inji-web/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ fi

echo "MOSIP_INJIWEB_HOST is not present in configmap/global of configserver"
# Add injiweb host to global
kubectl patch configmap global -n config-server --type merge -p "{\"data\": {\"mosip-injiweb-host\": \"$MOSIP_INIEB_HOST\"}}"
kubectl patch configmap global -n config-server --type merge -p "{\"data\": {\"mosip-injiweb-host\": \"$MOSIP_INJIWEBB_HOST\"}}"
kubectl patch configmap global -n default --type merge -p "{\"data\": {\"mosip-injiweb-host\": \"$MOSIP_INJIWEBB_HOST\"}}"
# Add the host
kubectl set env deployment/config-server SPRING_CLOUD_CONFIG_SERVER_OVERRIDES_MOSIP_ESIGNET_INJIWEB_HOST=$MOSIP_INJIWEB_HOST -n config-server
# Restart the configserver deployment
kubectl -n config-server get deploy -o name | xargs -n1 -t kubectl -n config-server rollout restart
kubectl -n config-server get deploy -o name | xargs -n1 -t kubectl -n config-server rollout status

sleep 400s

Expand All @@ -54,7 +55,7 @@ function installing_inji-web() {

INJI_HOST=$(kubectl get cm global -o jsonpath={.data.mosip-injiweb-host})
echo Installing INJIWEB
helm -n $NS install injiweb mosip/inji-web \
helm -n $NS install injiweb mosip/injiweb \
-f values.yaml \
--set istio.hosts\[0\]=$INJI_HOST \
--version $CHART_VERSION
Expand Down
19 changes: 10 additions & 9 deletions inji-web/src/__tests__/components/Credentials/Credentials.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,23 @@ const getCredentialObject = (): CredentialWellknownObject => {
}
}
}
describe("Test Credentials Item Layout",() => {
test.skip('check the presence of the container', () => {

describe.skip("Test Credentials Item Layout",() => {
test('check the presence of the container', () => {
const clickHandler = jest.fn();
const credential:CredentialWellknownObject = getCredentialObject();
render(
<Provider store={{credentials: credential}}>
<Credential credential={credential} index={1} />
</Provider>
);
// render(
// <Provider store={{credentials: credential}}>
// <Credential credential={credential} index={1} />
// </Provider>
// );
const itemBoxElement = screen.getByTestId("ItemBox-Outer-Container");
expect(itemBoxElement).toBeInTheDocument();
});
test.skip('check if content is rendered properly', () => {
test('check if content is rendered properly', () => {
const clickHandler = jest.fn();
const credential:CredentialWellknownObject = getCredentialObject();
render(<Credential credential={credential} index={1} />);
// render(<Credential credential={credential} index={1} />);
const itemBoxElement = screen.getByTestId("ItemBox-Outer-Container");
expect(itemBoxElement).toHaveTextContent("TitleOfItemBox")
});
Expand Down
74 changes: 41 additions & 33 deletions inji-web/src/__tests__/components/PageTemplate/Header.test.tsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,57 @@
import React from 'react';
import {fireEvent, render, screen} from '@testing-library/react';
import {Header} from "../../../components/PageTemplate/Header";
import {wrapUnderRouter} from "../../../utils/mockUtils";
import {useNavigate} from "react-router-dom";
import {mockUseNavigate, wrapUnderRouter} from "../../../utils/mockUtils";

const mockedUsedNavigate = jest.fn();
// const originalWindowEnv = global.window._env_;

jest.mock('../../../components/Common/LanguageSelector', () => ({
LanguageSelector: () => <></>,
}))
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useNavigate: () => mockedUsedNavigate,
}))

describe("Header Container",() => {
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useNavigate: jest.fn().mockImplementation(() => {
return (path:string) => console.log(`Navigating to: ${path}`);
}),
}));

test('check the presence of the container', () => {
render(wrapUnderRouter(<Header />));
const footerElement = screen.getByTestId("Header-Container");
expect(footerElement).toBeInTheDocument();
});
window._env_ = {
DEFAULT_FAVICON: "favicon.ico",
DEFAULT_FONT_URL: "",
DEFAULT_THEME: "purple_theme",
DEFAULT_TITLE: "Inji Web Test",
DEFAULT_LANG: 'en'
};

test('check the presence of the injweb logo', () => {
render(wrapUnderRouter(<Header />));
const injiWebLogo = screen.getByTestId("Header-InjiWeb-Logo-Container");
console.log("injiWebLogo:", injiWebLogo);
expect(injiWebLogo).toBeInTheDocument();
});
describe("Header Container",() => {
test('check the presence of the help', () => {
render(wrapUnderRouter(<Header />));
const footerElementText = screen.getByTestId("Header-Menu-Help");
expect(footerElementText).toBeInTheDocument()
expect(footerElementText).toHaveTextContent("Header.help");
});
test('check the presence of the about inji ', () => {
render(wrapUnderRouter(<Header />));
const footerElementText = screen.getByTestId("Header-Menu-AboutInji");
expect(footerElementText).toBeInTheDocument()
expect(footerElementText).toHaveTextContent("Header.aboutInji");
const headerElementLi = screen.getByTestId("Header-Menu-Help");
expect(headerElementLi).toBeInTheDocument()
expect(headerElementLi).toHaveTextContent("Header.help");
const headerElementDiv = screen.getByTestId("Header-Menu-Help-div");
expect(headerElementDiv).toBeInTheDocument()

fireEvent.click(headerElementDiv);
jest.spyOn(require('react-router-dom'), 'useNavigate').mockReturnValue(mockUseNavigate);
fireEvent.click(headerElementDiv);

expect(mockedUsedNavigate).toHaveBeenCalled();
expect(mockedUsedNavigate).toHaveBeenCalledWith("/help");
});
test('check the presence of the language Selector', () => {

test('check the presence of the About Inji', () => {
render(wrapUnderRouter(<Header />));
const footerElementText = screen.getByTestId("Header-Menu-LanguageSelector");
expect(footerElementText).toBeInTheDocument()
const headerElementLi = screen.getByTestId("Header-Menu-AboutInji");
expect(headerElementLi).toBeInTheDocument()
expect(headerElementLi).toHaveTextContent("Header.aboutInji");
const headerElementDiv = screen.getByTestId("Header-Menu-Help-div");
expect(headerElementDiv).toBeInTheDocument()

fireEvent.click(headerElementDiv);
jest.spyOn(require('react-router-dom'), 'useNavigate').mockReturnValue(mockUseNavigate);
fireEvent.click(headerElementDiv);

expect(mockedUsedNavigate).toHaveBeenCalled();
});
})

119 changes: 119 additions & 0 deletions inji-web/src/__tests__/components/Redirection/DownloadResult.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import React from 'react';
import {render, screen} from '@testing-library/react';
import {DownloadResult} from "../../../components/Redirection/DownloadResult";
import {RequestStatus} from "../../../hooks/useFetch";

jest.mock('../../../components/Common/SpinningLoader', () => ({
SpinningLoader: () => <div data-testid={"SpinningLoader-Container"}/>,
}))

const mockedUsedNavigate = jest.fn();
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useNavigate: () => ({
navigate: mockedUsedNavigate,
}),
}))

describe("DownloadResult Container",() => {
test('check the presence of the container', () => {
render(<DownloadResult title={"Title"} subTitle={"SubTitle"} state={RequestStatus.DONE}/>);
let redirectionElement = screen.getByTestId("DownloadResult-Outer-Container");
expect(redirectionElement).toBeInTheDocument();
redirectionElement = screen.getByTestId("DownloadResult-Title");
expect(redirectionElement).toHaveTextContent("Title")
redirectionElement = screen.getByTestId("DownloadResult-SubTitle");
expect(redirectionElement).toHaveTextContent("SubTitle")
});
})

describe("DownloadResult For Success (DONE) Scenario", () => {

beforeEach(() => {
render(<DownloadResult title={"Title"} subTitle={"SubTitle"} state={RequestStatus.DONE}/>);
})

test('check the presence of the title', () => {
const redirectionElement = screen.getByTestId("DownloadResult-Title");
expect(redirectionElement).toBeInTheDocument();
});

test('check the presence of the subTitle', () => {
const redirectionElement = screen.getByTestId("DownloadResult-SubTitle");
expect(redirectionElement).toBeInTheDocument();
});

test('check the presence of the success ShieldIcon', () => {
const redirectionElement = screen.getByTestId("DownloadResult-Success-ShieldIcon");
expect(redirectionElement).toBeInTheDocument();
});
test('check the presence of the error ShieldIcon to be not in the document', () => {
const redirectionElement = screen.queryByTestId("DownloadResult-Error-ShieldIcon");
expect(redirectionElement).not.toBeInTheDocument();
});
test('check the presence of the Loader to be not in the document', () => {
const redirectionElement = screen.queryByTestId("SpinningLoader-Container");
expect(redirectionElement).not.toBeInTheDocument();
});
})

describe("DownloadResult For Error (ERROR) Scenario", () => {

beforeEach(() => {
render(<DownloadResult title={"Title"} subTitle={"SubTitle"} state={RequestStatus.ERROR}/>);
})

test('check the presence of the title', () => {
const redirectionElement = screen.getByTestId("DownloadResult-Title");
expect(redirectionElement).toBeInTheDocument();
});

test('check the presence of the subTitle', () => {
const redirectionElement = screen.getByTestId("DownloadResult-SubTitle");
expect(redirectionElement).toBeInTheDocument();
});

test('check the presence of the success ShieldIcon to be in the document', () => {
const redirectionElement = screen.queryByTestId("DownloadResult-Success-ShieldIcon");
expect(redirectionElement).not.toBeInTheDocument();
});
test('check the presence of the error ShieldIcon to be in the document', () => {
const redirectionElement = screen.getByTestId("DownloadResult-Error-ShieldIcon");
expect(redirectionElement).toBeInTheDocument();
});
test('check the presence of the Loader to be not in the document', () => {
const redirectionElement = screen.queryByTestId("SpinningLoader-Container");
expect(redirectionElement).not.toBeInTheDocument();
});
})


describe("DownloadResult For Loading (LOADING) Scenario", () => {

beforeEach(() => {
render(<DownloadResult title={"Title"} subTitle={"SubTitle"} state={RequestStatus.LOADING}/>);
})

test('check the presence of the title', () => {
const redirectionElement = screen.getByTestId("DownloadResult-Title");
expect(redirectionElement).toBeInTheDocument();
});

test('check the presence of the subTitle', () => {
const redirectionElement = screen.getByTestId("DownloadResult-SubTitle");
expect(redirectionElement).toBeInTheDocument();
});

test('check the presence of the success ShieldIcon not to be in the document', () => {
const redirectionElement = screen.queryByTestId("DownloadResult-Success-ShieldIcon");
expect(redirectionElement).not.toBeInTheDocument();
});
test('check the presence of the error ShieldIcon to be in the document', () => {
const redirectionElement = screen.queryByTestId("DownloadResult-Error-ShieldIcon");
expect(redirectionElement).not.toBeInTheDocument();
});
test('check the presence of the Loader to be in the document', () => {
const redirectionElement = screen.queryByTestId("SpinningLoader-Container");
expect(redirectionElement).toBeInTheDocument();
});
})
8 changes: 6 additions & 2 deletions inji-web/src/components/Common/AppToaster.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import React from "react";
import {ToastContainer} from "react-toastify";
import {useSelector} from "react-redux";
import {RootState} from "../../types/redux";
import {isRTL} from "../../utils/i18n";

export const AppToaster: React.FC = () => {
const language = useSelector((state:RootState) => state.common.language);
return <ToastContainer
position="top-right"
position={isRTL(language) ? "top-left": "top-right"}
autoClose={1000}
hideProgressBar
newestOnTop
closeOnClick
rtl={false}
rtl={isRTL(language)}
icon={<React.Fragment/>}
pauseOnFocusLoss
draggable
Expand Down
3 changes: 2 additions & 1 deletion inji-web/src/components/Common/EmptyListContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {EmptyListContainerProps} from "../../types/components";
export const EmptyListContainer: React.FC<EmptyListContainerProps> = ({content}) => {
return <React.Fragment>
<div data-testid="EmptyList-Outer-Container"
className="flex justify-center items-center w-full mx-auto my-auto flex-col h-72 shadow-md shadow-iw-shadow border-t-iw-shadow">
className="flex justify-center items-center w-full mx-auto bg-iw-background
my-auto flex-col h-72 shadow-md shadow-iw-shadow border-t-iw-shadow px-10">
<p data-testid="EmptyList-Text"
className="text-center text-light-title dark:text-dark-title">{content}</p>
</div>
Expand Down
48 changes: 24 additions & 24 deletions inji-web/src/components/Common/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ export const NavBar: React.FC<NavBarProps> = (props) => {
return <React.Fragment>
<div data-testid="NavBar-Outer-Container"
className="bg-iw-navigationBar text-iw-title p-4 py-10">
<nav data-testid="NavBar-Inner-Container" className="flex justify-between mx-auto container items-center">
<div className="flex items-center">
<nav data-testid="NavBar-Inner-Container"
className=" mx-auto flex flex-col justify-start container items-start
sm:flex-row sm:justify-start sm:items-center">
<div className="flex items-center my-5 sm:my-0">
<div className={"cursor-pointer"}>
<IoArrowBack data-testid="NavBar-Back-Arrow" size={24} onClick={() => navigate(props.link)}/>
</div>
Expand All @@ -42,29 +44,27 @@ export const NavBar: React.FC<NavBarProps> = (props) => {
</div>

{props.search &&
<>
<div className={"flex items-center w-full justify-end"} data-testid="NavBar-Search-Container">
<div data-testid="Search-Issuer-Container" className="w-96 flex justify-center items-center bg-iw-background shadow-md shadow-iw-shadow">
<FaSearch data-testid="NavBar-Search-Icon"
color={'var(--iw-color-searchIcon)'}
className={"ms-6"}
size={20}/>
<input
data-testid="NavBar-Search-Input"
type="text"
value={searchText}
placeholder={t("searchText")}
onChange={event => filterCredential(event.target.value)}
className="py-6 ps-10 pe-4 w-11/12 flex text-iw-searchTitle focus:outline-none"
/>
{searchText.length > 0 && <IoCloseCircleSharp data-testid="NavBar-Search-Clear-Icon"
onClick={() => filterCredential("")}
color={'var(--iw-color-closeIcon)'}
className={"me-6"}
size={20}/>}
</div>
<div className={"flex items-center w-full justify-start sm:justify-end my-5 sm:my-0"} data-testid="NavBar-Search-Container">
<div data-testid="Search-Issuer-Container" className="w-full sm:w-96 flex justify-center items-center bg-iw-background shadow-md shadow-iw-shadow">
<FaSearch data-testid="NavBar-Search-Icon"
color={'var(--iw-color-searchIcon)'}
className={"m-5"}
size={20}/>
<input
data-testid="NavBar-Search-Input"
type="text"
value={searchText}
placeholder={t("searchText")}
onChange={event => filterCredential(event.target.value)}
className="py-6 w-11/12 flex text-iw-searchTitle focus:outline-none"
/>
{searchText.length > 0 && <IoCloseCircleSharp data-testid="NavBar-Search-Clear-Icon"
onClick={() => filterCredential("")}
color={'var(--iw-color-closeIcon)'}
className={"m-5"}
size={20}/>}
</div>
</>
</div>
}
</nav>
</div>
Expand Down
2 changes: 1 addition & 1 deletion inji-web/src/components/Credentials/Crendential.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const Credential: React.FC<CredentialProps> = (props) => {
onClick={() => {
const state = generateRandomString();
const code_challenge: CodeChallengeObject = generateCodeChallenge(state);
window.open(api.authorization(selectedIssuer.selected_issuer, state, code_challenge), '_self', 'noopener');
window.open(api.authorization(selectedIssuer.selected_issuer, props.credential, state, code_challenge), '_self', 'noopener');
addNewSession({
selectedIssuer: selectedIssuer.selected_issuer,
certificateId: props.credential.id,
Expand Down
2 changes: 1 addition & 1 deletion inji-web/src/components/Help/HelpAccordionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {IoIosArrowDown, IoIosArrowUp} from "react-icons/io";
export const HelpAccordionItem: React.FC<HelpAccordionItemProps> = (props) => {

return <React.Fragment>
<div className="border rounded-md mb-2 shadow-sm shadow-iw-shadow"
<div className="rounded-md mb-2 shadow-sm shadow-iw-shadow"
data-testid="Help-Item-Container">
<button
data-testid="Help-Item-Title-Button"
Expand Down
Loading
Loading