Skip to content

Commit

Permalink
AKR:OTR:VKT:YKI:SHARED(Frontend) fix error toast. Also revert date pi…
Browse files Browse the repository at this point in the history
…cker back to 5.x
  • Loading branch information
jrkkp committed Jan 8, 2024
1 parent 24d5f2a commit 985b03d
Show file tree
Hide file tree
Showing 13 changed files with 186 additions and 66 deletions.
4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@opetushallitus/kieli-ja-kaantajatutkinnot.root",
"engines": {
"node": "16.16.0"
"node": "v20.9.0"
},
"packageManager": "[email protected]",
"private": true,
Expand Down Expand Up @@ -31,7 +31,7 @@
"@mui/icons-material": "^5.14.16",
"@mui/material": "^5.14.17",
"@mui/system": "^5.14.17",
"@mui/x-date-pickers": "^6.18.0",
"@mui/x-date-pickers": "^5.0.20",
"@reduxjs/toolkit": "^1.9.7",
"@types/js-cookie": "^3.0.5",
"axios": "^1.6.0",
Expand Down
8 changes: 7 additions & 1 deletion frontend/packages/akr/src/routers/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,17 @@ import { StatisticsPage } from 'pages/StatisticsPage';
export const AppRouter: FC = () => {
const translateCommon = useCommonTranslation();

const ErrorToast = () => {
useAPIErrorToast();

return <></>;
};

const Root = (
<div className="app">
<NotifierContextProvider>
<Header />
<ErrorToast />
<Notifier />
<ScrollToTop />
<main className="content" id="main-content">
Expand All @@ -52,7 +59,6 @@ export const AppRouter: FC = () => {
useEffect(() => {
document.title = translateCommon('appTitle');
}, [translateCommon]);
useAPIErrorToast();

const router = createBrowserRouter(
createRoutesFromElements(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('ClerkSendEmailPage', () => {
onToast.expectText('Sähköpostisi lähetettiin kääntäjille');
});

it.skip('should display an error toast if there was an error when sending the email', () => {
it('should display an error toast if there was an error when sending the email', () => {
fillAndSendMessage();

runWithIntercept(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('ExaminationDatesPage', () => {
onExaminationDatesPage.expectRowToContain(1, '18.11.2021');
});

it.skip('should let user to add a new, unique examination date', () => {
it('should let user to add a new, unique examination date', () => {
onExaminationDatesPage.expectTotalExaminationDatesCount(10);
onExaminationDatesPage.expectAddButtonDisabled();

Expand All @@ -74,12 +74,12 @@ describe('ExaminationDatesPage', () => {
onToast.expectText('Tutkintopäivän 04.10.2030 lisäys onnistui');
});

it.skip('should not add duplicate examination dates', () => {
it('should not add duplicate examination dates', () => {
onExaminationDatesPage.setDateForNewExaminationDate('01.01.2022');
onExaminationDatesPage.expectAddButtonDisabled();
});

it.skip('should show a generic API error toast when trying to add a examination date', () => {
it('should show a generic API error toast when trying to add a examination date', () => {
onExaminationDatesPage.setDateForNewExaminationDate('04.10.2030');

cy.intercept('POST', APIEndpoints.ExaminationDate, {
Expand Down Expand Up @@ -128,7 +128,7 @@ describe('ExaminationDatesPage', () => {
onToast.expectText('Tutkintopäivä 18.11.2021 poistettu');
});

it.skip('should show an error toast if examination date is chosen to be deleted, but an API error occurs', () => {
it('should show an error toast if examination date is chosen to be deleted, but an API error occurs', () => {
onExaminationDatesPage.filterByStatus(ExaminationDateStatus.Passed);
onExaminationDatesPage.clickDeleteRowIcon(1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('MeetingDatesPage', () => {
onMeetingDatesPage.expectRowToContain(1, '18.11.2021');
});

it.skip('should let user to add a new, unique meeting date', () => {
it('should let user to add a new, unique meeting date', () => {
onMeetingDatesPage.expectTotalMeetingDatesCount(10);
onMeetingDatesPage.expectAddButtonDisabled();

Expand All @@ -73,12 +73,12 @@ describe('MeetingDatesPage', () => {
onToast.expectText('Kokouspäivän 04.10.2030 lisäys onnistui');
});

it.skip('should not add duplicate meeting dates', () => {
it('should not add duplicate meeting dates', () => {
onMeetingDatesPage.setDateForNewMeetingDate('01.01.2022');
onMeetingDatesPage.expectAddButtonDisabled();
});

it.skip('should show a generic API error toast when trying to add a meeting date', () => {
it('should show a generic API error toast when trying to add a meeting date', () => {
onMeetingDatesPage.setDateForNewMeetingDate('04.10.2030');

cy.intercept('POST', APIEndpoints.MeetingDate, {
Expand Down Expand Up @@ -126,7 +126,7 @@ describe('MeetingDatesPage', () => {
onToast.expectText('Kokouspäivä 18.11.2021 poistettu');
});

it.skip('should show an error toast if meeting date is chosen to be deleted, but an API error occurs', () => {
it('should show an error toast if meeting date is chosen to be deleted, but an API error occurs', () => {
onMeetingDatesPage.filterByStatus(MeetingDateStatus.Passed);
onMeetingDatesPage.clickDeleteRowIcon(1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ beforeEach(() => {
});

describe('ClerkTranslatorOverview:Page', () => {
it.skip('should display a "not found" message if no translator exists with the id given as the route parameter', () => {
it('should display a "not found" message if no translator exists with the id given as the route parameter', () => {
onClerkTranslatorOverviewPage.navigateById(1234567890);
onClerkTranslatorOverviewPage.expectTranslatorNotFoundText();
cy.isOnPage(AppRoutes.ClerkHomePage);
Expand Down
8 changes: 7 additions & 1 deletion frontend/packages/otr/src/routers/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,17 @@ import { PublicHomePage } from 'pages/PublicHomePage';
export const AppRouter: FC = () => {
const translateCommon = useCommonTranslation();

const ErrorToast = () => {
useAPIErrorToast();

return <></>;
};

const Root = (
<div className="app">
<NotifierContextProvider>
<Header />
<ErrorToast />
<Notifier />
<ScrollToTop />
<main className="content" id="main-content">
Expand All @@ -49,7 +56,6 @@ export const AppRouter: FC = () => {
useEffect(() => {
document.title = translateCommon('appTitle');
}, [translateCommon]);
useAPIErrorToast();

const router = createBrowserRouter(
createRoutesFromElements(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ describe('MeetingDatesPage', () => {
onMeetingDatesPage.expectRowToContain(1, '01.01.2022');
});

it.skip('should let user to add a new, unique meeting date', () => {
it('should let user to add a new, unique meeting date', () => {
onMeetingDatesPage.setDateForNewMeetingDate(dateForNewMeetingDate);
onMeetingDatesPage.clickAddButton();

onToast.expectText(`Kokouspäivän ${dateForNewMeetingDate} lisäys onnistui`);
});

it.skip('should not allow adding duplicate meeting dates', () => {
it('should not allow adding duplicate meeting dates', () => {
onMeetingDatesPage.setDateForNewMeetingDate('01.01.2022');
onMeetingDatesPage.expectAddButtonDisabled();
});

it.skip('should show an error toast when trying to add a meeting date fails', () => {
it('should show an error toast when trying to add a meeting date fails', () => {
onMeetingDatesPage.setDateForNewMeetingDate('01.01.2030');
onMeetingDatesPage.clickAddButton();

Expand All @@ -64,7 +64,7 @@ describe('MeetingDatesPage', () => {
onToast.expectText('Kokouspäivä 01.01.2022 poistettu');
});

it.skip('should show an error toast if meeting date is chosen to be deleted, but an API error occurs', () => {
it('should show an error toast if meeting date is chosen to be deleted, but an API error occurs', () => {
onMeetingDatesPage.clickDeleteRowIcon(0);
onDialog.clickButtonByText('Kyllä');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,15 @@ export const CustomDatePicker = ({
disabled={disabled}
minDate={minDate ?? dayjs(MIN_DATE)}
maxDate={maxDate ?? dayjs(MAX_DATE)}
slots={{
textField: (params) => {
const textFieldParams = {
...params,
error,
helperText,
showHelperText,
};
renderInput={(params) => {
const textFieldParams = {
...params,
error,
helperText,
showHelperText,
};

return <CustomTextField {...textFieldParams} />;
},
return <CustomTextField {...textFieldParams} />;
}}
/>
</LocalizationProvider>
Expand Down
2 changes: 1 addition & 1 deletion frontend/packages/shared/src/configs/materialUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const theme = createTheme({
},
},
},
MuiDateCalendar: {
MuiCalendarPicker: {
styleOverrides: {
root: {
'& .MuiTypography-caption': {
Expand Down
9 changes: 7 additions & 2 deletions frontend/packages/vkt/src/routers/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,20 @@ export const AppRouter: FC = () => {
const translateCommon = useCommonTranslation();
const appTitle = translateCommon('appTitle');

useAPIErrorToast();

const createTitle = (title: string) =>
translateCommon('pageTitle.' + title) + ' - ' + appTitle;

const ErrorToast = () => {
useAPIErrorToast();

return <></>;
};

const Root = (
<div className="app">
<NotifierContextProvider>
<Header />
<ErrorToast />
<Notifier />
<ScrollToTop />
<PersistGate persistor={persistor} />
Expand Down
7 changes: 6 additions & 1 deletion frontend/packages/yki/src/routers/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,17 @@ export const AppRouter: FC = () => {
}
}, [dispatch, sessionStatus]);

useAPIErrorToast();
const ErrorToast = () => {
useAPIErrorToast();

return <></>;
};

const Root = (
<div className="app">
<NotifierContextProvider>
<Header />
<ErrorToast />
<Notifier />
<ScrollToTop />
<main className="content" id="main-content">
Expand Down
Loading

0 comments on commit 985b03d

Please sign in to comment.