Skip to content

Commit

Permalink
YKI(Frontend): Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
pkoivisto committed Feb 6, 2024
1 parent cf11eab commit b499bce
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { APIEndpoints } from 'enums/api';
import { onExamDetailsPage } from 'tests/cypress/support/page-objects/examDetailsPage';
import { examSessions } from 'tests/msw/fixtures/examSession';
import { onExamDetailsPage } from '../support/page-objects/examDetailsPage';

const examSessionResponse = examSessions.exam_sessions.find(
(es) => es.id === 999
Expand All @@ -19,6 +19,7 @@ const getInitRegistrationResponse = (is_strongly_identified: boolean) => {
if (is_strongly_identified) {
const { first_name, last_name, ssn, post_office, zip, street_address } =
expectedSuomiFiRegistrationDetails;

return {
is_strongly_identified,
exam_session: examSessionResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ class PublicRegistrationPage {
elements = {
filterByLanguage: () =>
cy.findByRole('combobox', { name: /Valitse kieli/ }),
filterByLevel: () =>
cy.findByRole('combobox', { name: /Valitse taso/ }),
filterByLevel: () => cy.findByRole('combobox', { name: /Valitse taso/ }),
resultBox: () =>
cy.findByTestId('public-registration-page__grid-container__result-box'),
showOnlyIfAvailablePlaces: () =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { create } from 'react-test-renderer';
import { PreloadedState } from '@reduxjs/toolkit';
import { create } from 'react-test-renderer';
import { APIResponseStatus } from 'shared/enums';

import { RootState } from 'configs/redux';
import { RegistrationKind } from 'enums/app';
Expand All @@ -8,7 +9,6 @@ import { ContentSelector } from 'pages/InitRegistrationPage';
import { initialState as initialRegistrationState } from 'redux/reducers/registration';
import { DefaultProviders } from 'tests/jest/utils/DefaultProviders';
import { examSessions } from 'tests/msw/fixtures/examSession';
import { APIResponseStatus } from 'shared/enums';
import { ExamSessionUtils } from 'utils/examSession';
import { SerializationUtils } from 'utils/serialization';

Expand All @@ -25,6 +25,7 @@ const renderPageWithSession = (examSession: ExamSession) => {
<ContentSelector />
</DefaultProviders>
).toJSON();

return tree;
};

Expand All @@ -39,6 +40,7 @@ describe('InitRegistrationPage', () => {
const examSession = sessions.find((es) => {
const { open, kind, availablePlaces } =
ExamSessionUtils.getEffectiveRegistrationPeriodDetails(es);

return (
open && kind === RegistrationKind.Admission && availablePlaces > 0
);
Expand All @@ -51,6 +53,7 @@ describe('InitRegistrationPage', () => {
const examSession = sessions.find((es) => {
const { open, kind, availablePlaces } =
ExamSessionUtils.getEffectiveRegistrationPeriodDetails(es);

return (
open && kind === RegistrationKind.PostAdmission && availablePlaces > 0
);
Expand All @@ -65,6 +68,7 @@ describe('InitRegistrationPage', () => {
const examSession = sessions.find((es) => {
const { open, availablePlaces, availableQueue } =
ExamSessionUtils.getEffectiveRegistrationPeriodDetails(es);

return open && availablePlaces === 0 && availableQueue;
}) as ExamSession;
const tree = renderPageWithSession(examSession);
Expand All @@ -77,6 +81,7 @@ describe('InitRegistrationPage', () => {
const examSession = sessions.find((es) => {
const { open, availablePlaces, availableQueue } =
ExamSessionUtils.getEffectiveRegistrationPeriodDetails(es);

return open && availablePlaces === 0 && !availableQueue;
}) as ExamSession;
const tree = renderPageWithSession(examSession);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import dayjs from 'dayjs';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom';
import renderer from 'react-test-renderer';
Expand Down
22 changes: 11 additions & 11 deletions frontend/packages/yki/src/tests/msw/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { APIEndpoints } from 'enums/api';
import { evaluationOrderPostResponse } from 'tests/msw/fixtures/evaluationOrder';
import { evaluationPeriods } from 'tests/msw/fixtures/evaluationPeriods';
import { examSessions } from 'tests/msw/fixtures/examSession';
import { maatJaValtiot2Response } from './fixtures/maatjavaltiot2';
import { SuomiFiAuthenticatedSessionResponse } from './fixtures/identity';
import { SuomiFiAuthenticatedSessionResponse } from 'tests/msw/fixtures/identity';
import { maatJaValtiot2Response } from 'tests/msw/fixtures/maatjavaltiot2';

const notFound = () => new HttpResponse(null, { status: 404 });

Expand Down Expand Up @@ -39,15 +39,15 @@ export const handlers = [
return notFound();
}
}),
http.get(APIEndpoints.User, () => {
return HttpResponse.json(SuomiFiAuthenticatedSessionResponse);
}),
http.post(APIEndpoints.EvaluationOrder, () => {
return HttpResponse.json(evaluationOrderPostResponse);
}),
http.get(APIEndpoints.CountryCodes, () => {
return HttpResponse.json(maatJaValtiot2Response);
}),
http.get(APIEndpoints.User, () =>
HttpResponse.json(SuomiFiAuthenticatedSessionResponse)
),
http.post(APIEndpoints.EvaluationOrder, () =>
HttpResponse.json(evaluationOrderPostResponse)
),
http.get(APIEndpoints.CountryCodes, () =>
HttpResponse.json(maatJaValtiot2Response)
),
http.post(APIEndpoints.SubmitRegistration, () => {
return HttpResponse.json({ success: true });
}),
Expand Down

0 comments on commit b499bce

Please sign in to comment.