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

feat(MPDZBS-877): Switch to zmscitizenapi #125

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apigateway/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ spring:
maxAge: 3600
routes:
- id: backend
uri: "http://localhost:3001/"
uri: "http://zms.ddev.site/terminvereinbarung/api/citizen"
predicates:
- Path=/buergeransicht/api/backend/**
filters:
- RewritePath=/buergeransicht/api/backend/(?<segment>.*), /api/$\{segment}/
- RewritePath=/buergeransicht/api/backend/(?<segment>.*), /terminvereinbarung/api/citizen/$\{segment}
- RemoveResponseHeader=WWW-Authenticate
default-filters:
- RemoveResponseHeader=Expires
Expand All @@ -41,4 +41,4 @@ spring:
server:
port: 8080
config:
map5xxto400: true
map5xxto400: true
20 changes: 10 additions & 10 deletions frontend/.env.example
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
VUE_APP_ZMS_API_BASE=http://localhost:8080
VUE_APP_ZMS_API_PROVIDERS_AND_SERVICES_ENDPOINT=/buergeransicht/api/backend/offices-and-services
VUE_APP_ZMS_API_CALENDAR_ENDPOINT=/buergeransicht/api/backend/available-days
VUE_APP_ZMS_API_AVAILABLE_TIME_SLOTS_ENDPOINT=/buergeransicht/api/backend/available-appointments
VUE_APP_ZMS_API_RESERVE_APPOINTMENT_ENDPOINT=/buergeransicht/api/backend/reserve-appointment
VUE_APP_ZMS_API_APPOINTMENT_ENDPOINT=/buergeransicht/api/backend/appointment
VUE_APP_ZMS_API_UPDATE_APPOINTMENT_ENDPOINT=/buergeransicht/api/backend/update-appointment
VUE_APP_ZMS_API_CONFIRM_RESERVATION_ENDPOINT=/buergeransicht/api/backend/confirm-appointment
VUE_APP_ZMS_API_CANCEL_APPOINTMENT_ENDPOINT=/buergeransicht/api/backend/cancel-appointment
VUE_APP_ZMS_API_PRECONFIRM_RESERVATION_ENDPOINT=/buergeransicht/api/backend/preconfirm-appointment
VUE_APP_ZMS_API_CAPTCHA_DETAILS_ENDPOINT=/buergeransicht/api/backend/captcha-details
VUE_APP_ZMS_API_PROVIDERS_AND_SERVICES_ENDPOINT=/buergeransicht/api/backend/offices-and-services/
VUE_APP_ZMS_API_CALENDAR_ENDPOINT=/buergeransicht/api/backend/available-days/
VUE_APP_ZMS_API_AVAILABLE_TIME_SLOTS_ENDPOINT=/buergeransicht/api/backend/available-appointments/
VUE_APP_ZMS_API_RESERVE_APPOINTMENT_ENDPOINT=/buergeransicht/api/backend/reserve-appointment/
VUE_APP_ZMS_API_APPOINTMENT_ENDPOINT=/buergeransicht/api/backend/appointment/
VUE_APP_ZMS_API_UPDATE_APPOINTMENT_ENDPOINT=/buergeransicht/api/backend/update-appointment/
VUE_APP_ZMS_API_CONFIRM_RESERVATION_ENDPOINT=/buergeransicht/api/backend/confirm-appointment/
VUE_APP_ZMS_API_CANCEL_APPOINTMENT_ENDPOINT=/buergeransicht/api/backend/cancel-appointment/
VUE_APP_ZMS_API_PRECONFIRM_RESERVATION_ENDPOINT=/buergeransicht/api/backend/preconfirm-appointment/
VUE_APP_ZMS_API_CAPTCHA_DETAILS_ENDPOINT=/buergeransicht/api/backend/captcha-details/
32 changes: 24 additions & 8 deletions frontend/__tests__/components/Calendar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,12 @@ describe('Calendar', () => {
const mockCallback = jest.fn(() => {
return new Promise((resolve, reject) => {
resolve({
'errorMessage': 'Something went wrong'
})
errors: [
{
errorMessage: 'Something went wrong'
}
]
});
})
})

Expand All @@ -246,8 +250,12 @@ describe('Calendar', () => {
const mockCallback = jest.fn(() => {
return new Promise((resolve, reject) => {
resolve({
'errorMessage': 'Something went wrong'
})
errors: [
{
errorMessage: 'Something went wrong'
}
]
});
})
})

Expand Down Expand Up @@ -293,8 +301,12 @@ describe('Calendar', () => {
const mockCallback = jest.fn((method, parameters) => {
return new Promise((resolve, reject) => {
resolve({
'errorMessage': 'Ooops. Something went wrong'
})
errors: [
{
errorMessage: 'Something went wrong'
}
]
});
})
})

Expand All @@ -316,8 +328,12 @@ describe('Calendar', () => {
if (method === 'API/reserveAppointment') {
return new Promise((resolve, reject) => {
resolve({
'error': 'Failed.'
})
errors: [
{
'error': 'Failed.'
}
]
});
})
}
})
Expand Down
24 changes: 14 additions & 10 deletions frontend/__tests__/store/actions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,22 @@ describe('Actions', () => {
const mockMethods = jest.fn(() => {
return new Promise((resolve) => {
resolve({
errorMessage: 'Not valid appointment'
})
})
})
store.dispatch = mockMethods

errors: [
{
errorMessage: 'Not valid appointment'
}
]
});
});
});
store.dispatch = mockMethods;

await actions.setUpAppointment(store, {
appointmentHash: 'eyJpZCI6IDEyMzQ1LCJhdXRoS2V5IjogImJiYmIifQ=='
})

expect(store.state.errorMessage).toBe('Not valid appointment')
})
});
expect(store.state.errorMessage).toBe('Not valid appointment');
});

it('setAppointmentFromResponse set up appointment in store', async () => {
const commitMethods = jest.fn()
Expand Down
38 changes: 19 additions & 19 deletions frontend/__tests__/store/modules/api/actions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ store.rootState = {
settings: {
endpoints: {
'VUE_APP_ZMS_API_BASE': 'http://localhost:8082',
'VUE_APP_ZMS_API_PROVIDERS_AND_SERVICES_ENDPOINT': '/api/backend/offices-and-services',
'VUE_APP_ZMS_API_CALENDAR_ENDPOINT': '/api/backend/available-days',
'VUE_APP_ZMS_API_AVAILABLE_TIME_SLOTS_ENDPOINT': '/api/backend/available-appointments',
'VUE_APP_ZMS_API_RESERVE_APPOINTMENT_ENDPOINT': '/api/backend/reserve-appointment',
'VUE_APP_ZMS_API_APPOINTMENT_ENDPOINT': '/api/backend/appointment',
'VUE_APP_ZMS_API_UPDATE_APPOINTMENT_ENDPOINT': '/api/backend/update-appointment',
'VUE_APP_ZMS_API_CONFIRM_RESERVATION_ENDPOINT': '/api/backend/confirm-appointment',
'VUE_APP_ZMS_API_CANCEL_APPOINTMENT_ENDPOINT': '/api/backend/cancel-appointment',
'VUE_APP_ZMS_API_PRECONFIRM_RESERVATION_ENDPOINT': '/api/backend/preconfirm-appointment',
'VUE_APP_ZMS_API_CAPTCHA_DETAILS_ENDPOINT': '/api/backend/captcha-details'
'VUE_APP_ZMS_API_PROVIDERS_AND_SERVICES_ENDPOINT': '/api/backend/offices-and-services/',
'VUE_APP_ZMS_API_CALENDAR_ENDPOINT': '/api/backend/available-days/',
'VUE_APP_ZMS_API_AVAILABLE_TIME_SLOTS_ENDPOINT': '/api/backend/available-appointments/',
'VUE_APP_ZMS_API_RESERVE_APPOINTMENT_ENDPOINT': '/api/backend/reserve-appointment/',
'VUE_APP_ZMS_API_APPOINTMENT_ENDPOINT': '/api/backend/appointment/',
'VUE_APP_ZMS_API_UPDATE_APPOINTMENT_ENDPOINT': '/api/backend/update-appointment/',
'VUE_APP_ZMS_API_CONFIRM_RESERVATION_ENDPOINT': '/api/backend/confirm-appointment/',
'VUE_APP_ZMS_API_CANCEL_APPOINTMENT_ENDPOINT': '/api/backend/cancel-appointment/',
'VUE_APP_ZMS_API_PRECONFIRM_RESERVATION_ENDPOINT': '/api/backend/preconfirm-appointment/',
'VUE_APP_ZMS_API_CAPTCHA_DETAILS_ENDPOINT': '/api/backend/captcha-details/'
}
}
}
Expand All @@ -32,7 +32,7 @@ describe('API actions', () => {
it('confirmReservation calls API to confirm reservation', async () => {
const res = await actions.confirmReservation(store, {processId: 'aaa', authKey: 'bbb'})
expect(fetch.mock.calls.length).toEqual(1);
expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/confirm-appointment')
expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/confirm-appointment/')
expect(fetch.mock.calls[0][1].body).toBe(JSON.stringify({
processId: 'aaa',
authKey: 'bbb'
Expand All @@ -42,7 +42,7 @@ describe('API actions', () => {
it('preconfirmReservation calls API to pre-confirm reservation', async () => {
const res = await actions.preconfirmReservation(store, {processId: 'aaa', authKey: 'bbb'})
expect(fetch.mock.calls.length).toEqual(1);
expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/preconfirm-appointment')
expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/preconfirm-appointment/')
expect(fetch.mock.calls[0][1].body).toBe(JSON.stringify({
processId: 'aaa',
authKey: 'bbb'
Expand All @@ -52,7 +52,7 @@ describe('API actions', () => {
it('cancelAppointment calls API to cancel reservation', async () => {
const res = await actions.cancelAppointment(store, {processId: 'aaa', authKey: 'bbb'})
expect(fetch.mock.calls.length).toEqual(1);
expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/cancel-appointment')
expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/cancel-appointment/')
expect(fetch.mock.calls[0][1].body).toBe(JSON.stringify({
processId: 'aaa',
authKey: 'bbb'
Expand All @@ -70,21 +70,21 @@ describe('API actions', () => {
})

expect(fetch.mock.calls.length).toEqual(1);
//expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/available-days?startDate=2020-5-13&endDate=2020-11-13&officeId=111&serviceId=111%2C222&serviceCount=1%2C2')
//expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/available-days/?startDate=2020-5-13&endDate=2020-11-13&officeId=111&serviceId=111%2C222&serviceCount=1%2C2')
})

it('fetchServicesAndProviders calls API to fetch services and providers', async () => {
const res = await actions.fetchServicesAndProviders(store)

expect(fetch.mock.calls.length).toEqual(1);
expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/offices-and-services')
expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/offices-and-services/')
})

it('fetchAppointment calls API to fetch appointment', async () => {
const res = await actions.fetchAppointment(store, {processId: 'aaa', authKey: 'bbb', scope: 'ccc'})

expect(fetch.mock.calls.length).toEqual(1);
expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/appointment?processId=aaa&authKey=bbb&scope=ccc')
expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/appointment/?processId=aaa&authKey=bbb&scope=ccc')
})

it('fetchAvailableTimeSlots calls API to fetch available time slots', async () => {
Expand All @@ -99,7 +99,7 @@ describe('API actions', () => {
})

expect(fetch.mock.calls.length).toEqual(1);
//expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/available-appointments?date=2023-3-1&officeId=111&serviceId=222%2C333&serviceCount=2%2C3')
//expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/available-appointments/?date=2023-3-1&officeId=111&serviceId=222%2C333&serviceCount=2%2C3')
})

it('updateAppointmentData calls API to update appointment data', async () => {
Expand All @@ -113,7 +113,7 @@ describe('API actions', () => {
})

expect(fetch.mock.calls.length).toEqual(1);
expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/update-appointment')
expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/update-appointment/')
expect(fetch.mock.calls[0][1].body).toBe(JSON.stringify({
"processId": 'aaa',
"authKey": 'bbb',
Expand All @@ -133,7 +133,7 @@ describe('API actions', () => {
})

expect(fetch.mock.calls.length).toEqual(1);
expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/reserve-appointment')
expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/reserve-appointment/')
expect(fetch.mock.calls[0][1].body).toBe(JSON.stringify({
"timestamp": 1589373217,
"serviceCount": [2],
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ export default {
this.$store.state.openedPanel = 3
this.$store.state.confirmedAppointment = true
})
.catch(error => {
if (error.errors && Array.isArray(error.errors)) {
this.dateError = error.errors[0]?.errorMessage || this.$t('applicationError');
} else {
this.dateError = this.$t('networkError');
}
});
}
this.$store.dispatch('setUpCaptchaDetails');
})
Expand All @@ -128,8 +135,8 @@ export default {
Promise.all(promises).then(() => {
this.stylesLoaded = true;
this.loadData();
}).catch((error) => {
console.error('Error loading styles:', error);
}).catch((errors) => {
console.error('Error loading styles:', errors);
});
}
},
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/components/AppointmentForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,13 @@ export default {
this.disabled = false
this.$store.state.confirmedAppointment = false
})
.catch(error => {
if (error.errors && Array.isArray(error.errors)) {
this.dateError = error.errors[0]?.errorMessage || this.$t('applicationError');
} else {
this.dateError = this.$t('networkError');
}
});
},
openPanel(step) {
this.$store.commit('goToStep', step)
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/components/CustomerInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,17 @@ export default {
this.$emit('next')
window.scrollTo(0, 0)
this.$v.$reset()
}, (error) => {
console.error(error)
}, (errors) => {
console.error(errors)
this.$store.state.error = 'tooManyAppointmentsWithSameMail'
})
.catch(error => {
if (error.errors && Array.isArray(error.errors)) {
this.dateError = error.errors[0]?.errorMessage || this.$t('applicationError');
} else {
this.dateError = this.$t('networkError');
}
});
},
validTelephoneFormat(value) {
const phoneRegex = /^\+?\d+$/;
Expand Down
Loading
Loading