Skip to content

Commit c7feabc

Browse files
committed
E2E insuree workflow 1
1 parent 3cf8c24 commit c7feabc

5 files changed

Lines changed: 258 additions & 2079 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ node_modules/
99
cypress/screenshots/
1010
cypress/downloads/
1111
cypress/fixtures/tmp_individuals.csv
12+
yarn.lock
13+
package-lock.json

cypress.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = defineConfig({
5151
e2e: {
5252
projectId: "q6gc25", // Cypress Cloud, needed for recording
5353
baseUrl: 'http://localhost',
54-
defaultCommandTimeout: 15000,
54+
defaultCommandTimeout: 200000,
5555
taskTimeout: timeoutMinutes * 60 * 1000 + 10,
5656
downloadsFolder: 'cypress/downloads',
5757
setupNodeEvents(on, config) {

cypress/e2e/insuree.cy.js

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
// =====================================================
2+
// 🔹 CONSTANTS / TEST DATA
3+
// =====================================================
4+
export const insureeHead = {
5+
chfId: '697547030',
6+
firstName: 'Sylvie',
7+
lastName: 'Chineze',
8+
gender: 'F',
9+
phone: '602111111',
10+
email: 'sylvie@example.com',
11+
passport: 'AB7654321',
12+
profession: '2',
13+
education: '2',
14+
typeOfId: 'D',
15+
dobDay: '15'
16+
};
17+
18+
export const insureeMember = {
19+
chfId: '692651197',
20+
firstName: 'Paul',
21+
lastName: 'Sandjong',
22+
gender: 'M',
23+
phone: '602000000',
24+
email: 'paul@example.com',
25+
passport: 'AB1234567',
26+
profession: '2',
27+
education: '2',
28+
typeOfId: 'D',
29+
dobDay: '18'
30+
};
31+
32+
export const family = {
33+
location: 'R1D1M1V1',
34+
familyType: 'H',
35+
confirmationNo: 'CONF-001',
36+
address: 'Douala, Cameroun'
37+
};
38+
39+
// =====================================================
40+
// 🔹 NAVIGATION HELPERS
41+
// =====================================================
42+
export function goToInsureesPage() {
43+
cy.get('[data-cy="InsureeMainMenu"]').click();
44+
cy.get('[href="/front/insuree/insurees"]').click();
45+
}
46+
47+
export function goToFamiliesPage() {
48+
cy.get('[data-cy="InsureeMainMenu"]').click();
49+
cy.get('[href="/front/insuree/families"]').click();
50+
}
51+
52+
export function goToFamilyForm(familyChfId) {
53+
if (familyChfId) {
54+
goToFamiliesPage();
55+
verifyFamilyExists({ chfId: familyChfId });
56+
selectSearcherRow(familyChfId);
57+
return;
58+
}
59+
cy.get('[data-cy="InsureeMainMenu"]').click();
60+
cy.get('[href="/front/insuree/family"]').click();
61+
}
62+
63+
// =====================================================
64+
// 🔹 FORM HELPERS
65+
// =====================================================
66+
export function fillInsureeForm(insuree) {
67+
cy.get('[data-cy="insuree-chf-id-input"] input').clear().type(insuree.chfId);
68+
cy.get('[data-cy="insuree-other-names-input"] input').clear().type(insuree.firstName);
69+
cy.get('[data-cy="insuree-last-name-input"] input').clear().type(insuree.lastName);
70+
71+
// Date of Birth
72+
cy.get('button[type="button"] > svg[data-testid="CalendarIcon"]')
73+
.first()
74+
.parent()
75+
.click();
76+
cy.get('[data-cy="insuree-dob-day"]').contains(insuree.dobDay).click();
77+
78+
// Gender
79+
cy.get('[data-cy="insuree-gender-picker"]').click();
80+
cy.get(`[data-value='\"${insuree.gender}\"']`).click();
81+
82+
// Contacts
83+
cy.get('[data-cy="insuree-phone-input"] input').clear().type(insuree.phone);
84+
cy.get('[data-cy="insuree-email-input"] input').clear().type(insuree.email);
85+
cy.get('[data-cy="insuree-passport-input"] input').clear().type(insuree.passport);
86+
87+
// Pickers
88+
cy.get('[data-cy="insuree-profession-picker"]').click();
89+
cy.get(`[data-value="${insuree.profession}"]`).click();
90+
cy.get('[data-cy="insuree-education-picker"]').click();
91+
cy.get(`[data-value="${insuree.education}"]`).click();
92+
cy.get('[data-cy="insuree-type-of-id-picker"]').click();
93+
cy.get(`[data-value='\"${insuree.typeOfId}\"']`).click();
94+
}
95+
96+
export function fillFamilyForm(familyData) {
97+
cy.get('[data-cy="location-V-picker"] input').first().click().type(familyData.location);
98+
cy.get('[role="listbox"]').should('be.visible').find('[role="option"]').first().click();
99+
100+
cy.get('[data-cy="family-type-picker"]').click();
101+
cy.get(`[data-value='\"${familyData.familyType}\"']`).click();
102+
103+
cy.get('[data-cy="family-confirmation-type-picker"]').click();
104+
cy.get('[role="option"]').eq(0).click(); // confirmation type index
105+
106+
cy.get('[data-cy="family-confirmation-no-input"] input').clear().type(familyData.confirmationNo);
107+
108+
cy.get('[data-cy="family-address-textarea"] textarea').clear().type(familyData.address);
109+
}
110+
111+
// =====================================================
112+
// 🔹 ACTION HELPERS
113+
// =====================================================
114+
export function clickCreateInsuree() {
115+
cy.get('[data-cy="create-insuree-button"]').click();
116+
}
117+
118+
export function clickSave() {
119+
cy.get("button[data-cy='save-button']").click();
120+
}
121+
122+
export function addExistingInsureeIntoFamily(member, head) {
123+
goToFamilyForm(head.chfId);
124+
cy.get('[data-cy="family-add-existing-insuree-button"]').click();
125+
cy.get('[data-cy="insuree-chf-id-picker"] input').clear().type(member.chfId);
126+
127+
cy.get('td div').filter((index, div) => {
128+
const input = div.querySelector('input[type="text"]');
129+
return input && input.value.includes(member.chfId);
130+
}).first().rightclick();
131+
132+
cy.get('[data-cy="change-insuree-family-dialog-cancel-policies-button"]').click();
133+
}
134+
135+
export function removeExistingInsureeFromFamily(member, head) {
136+
goToFamilyForm(head.chfId);
137+
cy.get('[data-cy="family-insuree-seacher-open-button"]').click();
138+
cy.get('[data-cy="family-insurees-search-chfId"] input').clear().type(member.chfId);
139+
cy.get('[data-cy="family-remove-insuree-button"]').first().click();
140+
cy.get('[data-cy="remove-insuree-from-family-cancel-policies-btn"]').click();
141+
}
142+
143+
export function selectSearcherRow(data) {
144+
cy.contains(data).parents('tr, div').first().dblclick();
145+
}
146+
147+
// =====================================================
148+
// 🔹 ASSERTION HELPERS
149+
// =====================================================
150+
export function verifyInsureeExists(insuree) {
151+
goToInsureesPage();
152+
cy.get('[data-cy="insuree-chf-id-filter"] input').clear().type(insuree.chfId);
153+
cy.scrollTo('right');
154+
cy.get('[data-cy="searcher-refresh"]').click({ force: true });
155+
cy.contains(insuree.lastName);
156+
cy.contains(insuree.chfId);
157+
cy.contains(insuree.phone);
158+
}
159+
160+
export function verifyFamilyExists(head) {
161+
goToFamiliesPage();
162+
cy.get('[data-cy="head-insuree-chf-id-filter"] input').first().clear().type(head.chfId);
163+
cy.scrollTo('right');
164+
cy.get('[data-cy="searcher-refresh"]').scrollIntoView().click({ force: true });
165+
cy.contains(head.lastName);
166+
cy.contains(head.chfId);
167+
cy.contains(head.phone);
168+
}
169+
170+
// =====================================================
171+
// 🔹 TEST CASE
172+
// =====================================================
173+
describe('Full Family & Insuree Workflow', () => {
174+
it('Should run the full flow using variables', () => {
175+
// ------------------ LOGIN ------------------
176+
cy.login();
177+
178+
// ------------------ CREATE INSUREE MEMBER ------------------
179+
cy.goToInsureesPage();
180+
clickCreateInsuree();
181+
fillInsureeForm(insureeMember);
182+
clickSave();
183+
verifyInsureeExists(insureeMember);
184+
185+
// ------------------ CREATE FAMILY WITH HEAD INSUREE ------------------
186+
goToFamilyForm();
187+
fillFamilyForm(family);
188+
fillInsureeForm(insureeHead); // chef de famille
189+
clickSave();
190+
verifyFamilyExists({ ...insureeHead, confirmationNo: family.confirmationNo });
191+
192+
// ------------------ MODIFY INSUREE MEMBER ------------------
193+
verifyInsureeExists(insureeMember);
194+
selectSearcherRow(insureeMember.lastName);
195+
196+
cy.get('button[type="button"] > svg[data-testid="CalendarIcon"]')
197+
.first()
198+
.parent()
199+
.click();
200+
cy.get('[data-cy="insuree-dob-day"]').contains(insureeMember.dobDay).click();
201+
clickSave();
202+
203+
// ------------------ MODIFY FAMILY ------------------
204+
verifyFamilyExists(insureeHead);
205+
selectSearcherRow(insureeHead.lastName);
206+
207+
cy.get('[data-cy="family-confirmation-no-input"] input')
208+
.clear()
209+
.type('CONF-002');
210+
clickSave();
211+
212+
// ------------------ ADD MEMBER TO FAMILY ------------------
213+
addExistingInsureeIntoFamily(insureeMember, insureeHead);
214+
215+
// ------------------ REMOVE MEMBER FROM FAMILY ------------------
216+
removeExistingInsureeFromFamily(insureeMember, insureeHead);
217+
218+
// ------------------ DELETE INSUREE MEMBER ------------------
219+
verifyInsureeExists(insureeMember);
220+
cy.get('[data-cy="delete-insuree-button"]').first().click({ force: true });
221+
cy.get('[data-cy="dialog-confirm-button"]').click({ force: true });
222+
223+
// ------------------ DELETE FAMILY ------------------
224+
verifyFamilyExists(insureeHead);
225+
cy.get('[data-cy="delete-family-button"]').first().click({ force: true });
226+
cy.get('[data-cy="delete-family-and-insurees-button"]').click({ force: true });
227+
});
228+
});

cypress/support/commands.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,3 +685,30 @@ Cypress.Commands.add('getItemCount', (itemName) => {
685685
return parseInt(match?.[1], 10);
686686
});
687687
});
688+
689+
690+
import {
691+
fillFamilyForm,
692+
fillInsureeForm,
693+
clickCreateInsuree,
694+
clickSave,
695+
goToFamiliesPage,
696+
goToFamilyForm,
697+
goToInsureesPage,
698+
verifyFamilyExists,
699+
verifyInsureeExists,
700+
selectSearcherRow,
701+
addExistingInsureeIntoFamily
702+
} from '../e2e/insuree.cy';
703+
704+
Cypress.Commands.add('fillFamilyForm', fillFamilyForm);
705+
Cypress.Commands.add('fillInsureeForm', fillInsureeForm);
706+
Cypress.Commands.add('clickCreateInsuree', clickCreateInsuree);
707+
Cypress.Commands.add('clickSave', clickSave);
708+
Cypress.Commands.add('goToFamiliesPage', goToFamiliesPage);
709+
Cypress.Commands.add('goToFamilyForm', goToFamilyForm);
710+
Cypress.Commands.add('goToInsureesPage', goToInsureesPage);
711+
Cypress.Commands.add('verifyFamilyExists', verifyFamilyExists);
712+
Cypress.Commands.add('verifyInsureeExists', verifyInsureeExists);
713+
Cypress.Commands.add('selectSearcherRow', selectSearcherRow);
714+
Cypress.Commands.add('addExistingInsureeIntoFamily', addExistingInsureeIntoFamily);

0 commit comments

Comments
 (0)