Skip to content

Commit

Permalink
fix: registration data loading
Browse files Browse the repository at this point in the history
  • Loading branch information
web-mi committed Mar 21, 2024
1 parent ce47426 commit 378aa37
Show file tree
Hide file tree
Showing 54 changed files with 1,522 additions and 2,358 deletions.
7 changes: 1 addition & 6 deletions cypress/e2e/login.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,13 @@ describe('Login', () => {
cy.get('#appRoot').should('exist');
});

it.skip('displays the login at the root', () => {
it('displays the login at the root', () => {
cy.visit('/');
cy.contains('Login');
cy.contains('Impressum');
cy.contains('Datenschutzerklärung');
});

it('displays the consultingtype page at the root', () => {
cy.visit('/');
cy.contains('Willkommen bei der Online-Beratung');
});

it('displays the login for resorts', () => {
cy.visit('/suchtberatung');
cy.contains('Login');
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/registration/topic.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ let consultingTypes, agencies, topics;

describe('Registration', () => {
before(() => {
Cypress.env('TENANT_ENABLED', '1');
startWebSocketServer();
});

Expand Down
5 changes: 0 additions & 5 deletions cypress/support/commands/api/agencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ const agenciesApi = (cy, getWillReturn, setWillReturn) => {
cy.intercept('GET', `${endpoints.agencyServiceBase}*`, (req) => {
const searchParams = new URL(req.url).searchParams;
let agencies = getWillReturn('agencies');
console.log(
agencies,
searchParams.get('topicId'),
searchParams.get('consultingType')
);
if (searchParams.has('topicId')) {
agencies = agencies.filter((a) =>
a.topicIds?.includes(parseInt(searchParams.get('topicId')))
Expand Down
2 changes: 0 additions & 2 deletions cypress/support/commands/helper/fastLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ const fastLoginCommand = (getWillReturn, setWillReturn) =>
cy.wait('@usersData');
cy.wait('@settings');
cy.wait('@consultingTypeServiceBaseBasic');
cy.wait('@patchUsersData');
cy.wait('@fetchMyKeys');
if (userId === USER_ASKER) {
cy.wait('@askerSessions');
} else {
Expand Down
29 changes: 4 additions & 25 deletions cypress/support/commands/mockApi.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
import merge from 'lodash.merge';
import {
generateAskerSession,
generateConsultantSession,
generateMessage,
generateMessagesReply,
sessionsReply
} from '../sessions';
import { generateAskerSession, generateConsultantSession } from '../sessions';
import { endpoints } from '../../../src/resources/scripts/endpoints';
import {
getAskerSessions,
setAskerSessions,
updateAskerSession
} from './helper/askerSessions';
import {
getConsultantSessions,
setConsultantSessions,
updateConsultantSession
} from './helper/consultantSessions';
import { deepMerge } from '../helpers';
import { decodeUsername } from '../../../src/utils/encryptionHelpers';
import { getMessages, setMessages } from './helper/messages';
import {
SETTING_E2E_ENABLE,
SETTING_FILEUPLOAD_MAXFILESIZE,
SETTING_MESSAGE_MAXALLOWEDSIZE
} from '../../../src/api/apiRocketChatSettingsPublic';
import { setAskerSessions } from './helper/askerSessions';
import { setConsultantSessions } from './helper/consultantSessions';
import { setMessages } from './helper/messages';
import { config } from '../../../src/resources/scripts/config';
import usersChatApi from './api/users/chat';
import usersConsultantsApi from './api/users/consultants';
Expand Down
4 changes: 4 additions & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import 'cypress-file-upload';
import './commands';

before(() => {
Cypress.env('TENANT_ENABLED', '1');
});

beforeEach(() => {
window.localStorage.setItem('locale', 'de');
window.localStorage.setItem('showDevTools', '0');
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,19 @@
"dev": "node scripts/start.js",
"dev:server": "nodemon",
"build": "node scripts/build.js",
"test": "cross-env FAST_REFRESH=false BROWSER=none REACT_APP_API_URL=http://127.0.0.1:9001 HTTPS=0 PORT=9001 WDS_SOCKET_PORT=9001 concurrently --kill-others --success first \"npm run dev\" \"wait-on http://127.0.0.1:9001 && cypress run\"",
"test": "cross-env NODE_ENV=development FAST_REFRESH=false BROWSER=none REACT_APP_API_URL=http://127.0.0.1:9001 HTTPS=0 PORT=9001 WDS_SOCKET_PORT=9001 concurrently --kill-others --success first \"npm run dev\" \"wait-on http://127.0.0.1:9001 && cypress run\"",
"test:components": "NODE_ENV=development cypress run --component --headed",
"test:build": "cross-env FAST_REFRESH=false BROWSER=none PORT=9001 CYPRESS_WS_URL=http://127.0.0.1:9002 REACT_APP_API_URL=http://127.0.0.1:9001 concurrently --kill-others --success first \"npm run start\" \"wait-on http://127.0.0.1:9001 && cypress run\"",
"test:build": "cross-env NODE_ENV=production FAST_REFRESH=false BROWSER=none PORT=9001 CYPRESS_WS_URL=http://127.0.0.1:9002 REACT_APP_API_URL=http://127.0.0.1:9001 concurrently --kill-others --success first \"npm run start\" \"wait-on http://127.0.0.1:9001 && cypress run\"",
"release": "standard-version",
"lint": "npm run lint:scripts && npm run lint:style",
"lint:scripts": "eslint src && tsc",
"lint:style": "stylelint src/**/*.scss",
"lint:style:fix": "stylelint --fix src/**/*.scss",
"cypress": "run-p cypress:*",
"cypress:start-cra": "NODE_ENV=production BROWSER=none PORT=9001 WDS_SOCKET_PORT=9001 CYPRESS_WS_URL=http://127.0.0.1:9002 REACT_APP_API_URL=http://127.0.0.1:9001 npm run dev",
"cypress:start-cra": "NODE_ENV=development BROWSER=none PORT=9001 WDS_SOCKET_PORT=9001 CYPRESS_WS_URL=http://127.0.0.1:9002 REACT_APP_API_URL=http://127.0.0.1:9001 npm run dev",
"cypress:wait-and-open": "run-s cypress:wait-and-open:open cypress:wait-and-open:wait-on-cra",
"cypress:wait-and-open:wait-on-cra": "wait-on http://127.0.0.1:9001",
"cypress:wait-and-open:open": "cross-env NODE_ENV=production PORT=9001 CYPRESS_WS_URL=http://127.0.0.1:9002 REACT_APP_API_URL=http://127.0.0.1:9001 cypress open",
"cypress:wait-and-open:open": "cross-env NODE_ENV=development PORT=9001 CYPRESS_WS_URL=http://127.0.0.1:9002 REACT_APP_API_URL=http://127.0.0.1:9001 cypress open",
"dtsgen": "ts-node dtsgen.ts",
"prepare": "husky install",
"browserstack": "browserstack-cypress run --sync --env BROWSER=none,REACT_APP_API_URL=http://127.0.0.1:9001,HTTPS=0,PORT=9001,WDS_SOCKET_PORT=9001",
Expand Down
2 changes: 1 addition & 1 deletion src/api/apiAgencySelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const apiAgencySelection = async (
...params
}: {
postcode?: string;
consultingType?: number | undefined;
consultingType?: number;
topicId?: number;
age?: number;
gender?: string;
Expand Down
4 changes: 2 additions & 2 deletions src/api/apiGetTopicGroups.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TopicGroup } from '../globalState/interfaces/TopicGroups';
import { TopicGroup } from '../globalState/interfaces';
import { endpoints } from '../resources/scripts/endpoints';
import { fetchData, FETCH_ERRORS, FETCH_METHODS } from './fetchData';

Expand All @@ -7,7 +7,7 @@ export const apiGetTopicGroups = async (): Promise<{
}> => {
return fetchData({
url: endpoints.topicGroups,
responseHandling: [FETCH_ERRORS.EMPTY],
responseHandling: [FETCH_ERRORS.EMPTY, FETCH_ERRORS.NO_MATCH],
method: FETCH_METHODS.GET
});
};
56 changes: 28 additions & 28 deletions src/components/input/input.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { useState, useEffect, useRef } from 'react';
import { TextField, Typography } from '@mui/material';
import { InputBaseComponentProps, TextField, Typography } from '@mui/material';
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
import CancelIcon from '@mui/icons-material/Cancel';
import { useTranslation } from 'react-i18next';
Expand All @@ -22,6 +22,7 @@ export interface InputProps {
endAdornment?: JSX.Element;
isValueValid?(value: string): Promise<boolean>;
inputType?: 'number' | 'tel' | 'text' | 'password';
inputProps?: InputBaseComponentProps;
info?: string;
autoComplete?: string;
errorMessage?: string;
Expand All @@ -40,6 +41,7 @@ export const Input = ({
endAdornment,
isValueValid,
inputType,
inputProps,
info,
inputMode,
errorMessage,
Expand Down Expand Up @@ -143,19 +145,20 @@ export const Input = ({
label={label}
autoComplete={autoComplete}
inputProps={{
inputMode: inputMode
inputMode: inputMode,
...inputProps
}}
sx={{
'&[type=number]': {
'-moz-appearance': 'textfield'
MozAppearance: 'textfield'
},
'&::-webkit-outer-spin-button': {
'-webkit-appearance': 'none',
'margin': 0
WebkitAppearance: 'none',
margin: 0
},
'&::-webkit-inner-spin-button': {
'-webkit-appearance': 'none',
'margin': 0
WebkitAppearance: 'none',
margin: 0
},
'mt': '24px',
'& legend': {
Expand Down Expand Up @@ -205,7 +208,7 @@ export const Input = ({
setShrink(true);
}}
onBlur={handleBlur}
></TextField>
/>
{info && !inputError && !showSuccessMessage && (
<Typography
variant="body2"
Expand Down Expand Up @@ -245,26 +248,23 @@ export const Input = ({
{successMesssage}
</Typography>
)}
{multipleCriteria &&
multipleCriteria.map((criteria) => {
return (
<Typography
variant="body2"
sx={{
mt: '8px',
fontSize: '16px',
lineHeight: '16px',
color: getMultipleCriteriaDesign(criteria)
.color,
display: 'flex',
alignItems: 'center'
}}
>
{getMultipleCriteriaDesign(criteria).icon}{' '}
{t(criteria.info)}
</Typography>
);
})}
{multipleCriteria?.map((criteria) => (
<Typography
key={criteria.info}
variant="body2"
sx={{
mt: '8px',
fontSize: '16px',
lineHeight: '16px',
color: getMultipleCriteriaDesign(criteria).color,
display: 'flex',
alignItems: 'center'
}}
>
{getMultipleCriteriaDesign(criteria).icon}{' '}
{t(criteria.info)}
</Typography>
))}
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { UrlParamsContext } from '../../../globalState/provider/UrlParamsProvide
import { VALID_POSTCODE_LENGTH } from '../../../components/agencySelection/agencySelectionHelpers';

interface AgenciesForRegistrationArgs {
consultingType: ConsultingTypeInterface;
consultingType?: ConsultingTypeInterface;
postcode: string;
topic: TopicsDataInterface;
}
Expand Down Expand Up @@ -59,7 +59,7 @@ export const useAgenciesForRegistration = ({

const allAgencies = useMemo(() => {
// As long as no consulting type or topic is selected we can't show any agencies
if (!consultingType || topicsEnabledAndUnSelected) {
if (!consultingType && topicsEnabledAndUnSelected) {
return [];
}

Expand Down Expand Up @@ -131,8 +131,9 @@ export const useAgenciesForRegistration = ({
apiAgencySelection(
{
...(autoSelectPostcode ? {} : { postcode }),
consultingType: consultingType?.id,
topicId: topic?.id,
// API will ignore consultingType if topicId isset but its required to be send
consultingType: topic?.id || consultingType?.id,
fetchConsultingTypeDetails: true
},
abortController.signal
Expand Down
51 changes: 0 additions & 51 deletions src/extensions/components/app/app.tsx

This file was deleted.

This file was deleted.

Loading

0 comments on commit 378aa37

Please sign in to comment.