Skip to content

Commit 70f5b2a

Browse files
committed
Fixing a lot of tests.
1 parent f2c4a2f commit 70f5b2a

File tree

4 files changed

+59
-51
lines changed

4 files changed

+59
-51
lines changed

eform-client/cypress/e2e/MyEforms.page.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,10 @@ class MyEformsPage extends PageWithNavbarPage {
165165
// Table has rows, delete them
166166
cy.get('.eform-id').its('length').then((rowCount) => {
167167
for (let i = 1; i <= rowCount; i++) {
168-
const eformsRowObject = this.getEformRowObj(1, false); // Always delete first row
169-
if (
170-
eformsRowObject &&
171-
eformsRowObject.deleteBtn
172-
) {
173-
eformsRowObject.deleteBtn.should('be.visible').click();
174-
cy.wait(500);
168+
cy.get('#delete-eform-btn-0').click();
169+
cy.intercept('DELETE' , '**/api/templates/delete/*').as('deleteEform');
175170
cy.get('#eFormDeleteDeleteBtn').should('be.visible').click();
176-
cy.wait(500);
177-
}
171+
cy.wait('@deleteEform', {timeout: 50000});
178172
}
179173
});
180174
}
@@ -299,7 +293,7 @@ class MyEformsRowObject {
299293

300294
getRow(rowNum) {
301295
const currentPosition = rowNum - 1;
302-
this.element = cy.get('#mainPageEFormsTableBody tr.mat-row').eq(currentPosition);
296+
this.element = cy.get('#mainPageEFormsTableBody tbody tr').eq(currentPosition);
303297
cy.get(`#eform-id-${currentPosition}`)
304298
.eq(0)
305299
.invoke('text')

eform-client/cypress/e2e/Navbar.page.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,11 @@ export class Navbar {
195195
}
196196

197197
public goToMyEForms() {
198+
cy.intercept('POST', '**/api/templates/index').as('getTemplates');
199+
cy.intercept('GET', '**/api/tags/index').as('getTags');
198200
this.myEformsBtn().click();
201+
cy.wait('@getTemplates', { timeout: 60000 });
202+
cy.wait('@getTags', { timeout: 60000 });
199203
// Note: Tests should intercept appropriate API calls after navigation
200204
}
201205

eform-client/cypress/e2e/j/eform-visual-editor.create-eform.spec.cy.ts

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ describe('Visual editor - Create eForm', () => {
3434
const eformDescription = generateRandmString();
3535

3636
// Set main checklist name and description
37-
cy.get('#mainCheckListNameTranslation_0').clear().type(eformName);
38-
cy.get('#mainCheckListDescriptionTranslation_0').clear().type(eformDescription);
37+
cy.get('#mainCheckListNameTranslation_1').clear().type(eformName);
38+
cy.get('#mainCheckListDescriptionTranslation_1').clear().type(eformDescription);
3939

4040
// Save the eForm without adding any fields
4141
cy.intercept('POST', '**/api/template-visual-editor/').as('saveeForm');
@@ -52,8 +52,8 @@ describe('Visual editor - Create eForm', () => {
5252
cy.get('#edit-eform-btn-0').click();
5353
cy.wait('@geteForm', { timeout: 60000 });
5454

55-
cy.get('#mainCheckListNameTranslation_0').should('have.value', eformName);
56-
cy.get('#mainCheckListDescriptionTranslation_0').should('have.value', eformDescription);
55+
cy.get('#mainCheckListNameTranslation_1').should('have.value', eformName);
56+
cy.get('#mainCheckListDescriptionTranslation_1').should('have.value', eformDescription);
5757

5858
// No fields should be present
5959
cy.get('#fields_0').should('not.exist');
@@ -66,8 +66,8 @@ describe('Visual editor - Create eForm', () => {
6666
const fieldDescription = generateRandmString();
6767

6868
// Set main checklist name and description
69-
cy.get('#mainCheckListNameTranslation_0').clear().type(eformName);
70-
cy.get('#mainCheckListDescriptionTranslation_0').clear().type(eformDescription);
69+
cy.get('#mainCheckListNameTranslation_1').clear().type(eformName);
70+
cy.get('#mainCheckListDescriptionTranslation_1').clear().type(eformDescription);
7171

7272
// Add a field (Info element/None type)
7373
cy.get('#initialFieldCreateBtn').click();
@@ -93,8 +93,8 @@ describe('Visual editor - Create eForm', () => {
9393
cy.get('#edit-eform-btn-0').click();
9494
cy.wait('@geteForm', { timeout: 60000 });
9595

96-
cy.get('#mainCheckListNameTranslation_0').should('have.value', eformName);
97-
cy.get('#mainCheckListDescriptionTranslation_0').should('have.value', eformDescription);
96+
cy.get('#mainCheckListNameTranslation_1').should('have.value', eformName);
97+
cy.get('#mainCheckListDescriptionTranslation_1').should('have.value', eformDescription);
9898

9999
// Verify field exists with correct properties
100100
cy.get('#fieldSection0').should('exist');
@@ -108,8 +108,8 @@ describe('Visual editor - Create eForm', () => {
108108
const fieldDescription = generateRandmString();
109109

110110
// Set main checklist name and description
111-
cy.get('#mainCheckListNameTranslation_0').clear().type(eformName);
112-
cy.get('#mainCheckListDescriptionTranslation_0').clear().type(eformDescription);
111+
cy.get('#mainCheckListNameTranslation_1').clear().type(eformName);
112+
cy.get('#mainCheckListDescriptionTranslation_1').clear().type(eformDescription);
113113

114114
// Add a PDF field
115115
cy.get('#initialFieldCreateBtn').click();
@@ -140,7 +140,7 @@ describe('Visual editor - Create eForm', () => {
140140
cy.get('#edit-eform-btn-0').click();
141141
cy.wait('@geteForm', { timeout: 60000 });
142142

143-
cy.get('#mainCheckListNameTranslation_0').should('have.value', eformName);
143+
cy.get('#mainCheckListNameTranslation_1').should('have.value', eformName);
144144
cy.get('#fieldSection0').should('contain', fieldName);
145145
});
146146

@@ -150,8 +150,8 @@ describe('Visual editor - Create eForm', () => {
150150
const fieldName = generateRandmString();
151151

152152
// Set main checklist name and description
153-
cy.get('#mainCheckListNameTranslation_0').clear().type(eformName);
154-
cy.get('#mainCheckListDescriptionTranslation_0').clear().type(eformDescription);
153+
cy.get('#mainCheckListNameTranslation_1').clear().type(eformName);
154+
cy.get('#mainCheckListDescriptionTranslation_1').clear().type(eformDescription);
155155

156156
// Add a field
157157
cy.get('#initialFieldCreateBtn').click();
@@ -200,8 +200,8 @@ describe('Visual editor - Create eForm', () => {
200200
const decimalCount = 0;
201201

202202
// Set main checklist name and description
203-
cy.get('#mainCheckListNameTranslation_0').clear().type(eformName);
204-
cy.get('#mainCheckListDescriptionTranslation_0').clear().type(eformDescription);
203+
cy.get('#mainCheckListNameTranslation_1').clear().type(eformName);
204+
cy.get('#mainCheckListDescriptionTranslation_1').clear().type(eformDescription);
205205

206206
// Add a Number field
207207
cy.get('#initialFieldCreateBtn').click();
@@ -234,7 +234,7 @@ describe('Visual editor - Create eForm', () => {
234234
cy.get('#edit-eform-btn-0').click();
235235
cy.wait('@geteForm', { timeout: 60000 });
236236

237-
cy.get('#mainCheckListNameTranslation_0').should('have.value', eformName);
237+
cy.get('#mainCheckListNameTranslation_1').should('have.value', eformName);
238238
cy.get('#fieldSection0').should('contain', fieldName);
239239
});
240240

@@ -243,7 +243,7 @@ describe('Visual editor - Create eForm', () => {
243243
const fieldName = generateRandmString();
244244

245245
// Set main checklist name
246-
cy.get('#mainCheckListNameTranslation_0').clear().type(eformName);
246+
cy.get('#mainCheckListNameTranslation_1').clear().type(eformName);
247247

248248
// Add a field
249249
cy.get('#initialFieldCreateBtn').click();
@@ -280,7 +280,7 @@ describe('Visual editor - Create eForm', () => {
280280
const nestedFieldName = generateRandmString();
281281

282282
// Set main checklist name
283-
cy.get('#mainCheckListNameTranslation_0').clear().type(eformName);
283+
cy.get('#mainCheckListNameTranslation_1').clear().type(eformName);
284284

285285
// Add a field group
286286
cy.get('#initialFieldCreateBtn').click();
@@ -340,7 +340,7 @@ describe('Visual editor - Create eForm', () => {
340340
const nestedFieldName = generateRandmString();
341341

342342
// Set main checklist name
343-
cy.get('#mainCheckListNameTranslation_0').clear().type(eformName);
343+
cy.get('#mainCheckListNameTranslation_1').clear().type(eformName);
344344

345345
// Add a field group
346346
cy.get('#initialFieldCreateBtn').click();
@@ -399,7 +399,7 @@ describe('Visual editor - Create eForm', () => {
399399
const nestedChecklist2Name = generateRandmString();
400400

401401
// Set main checklist name
402-
cy.get('#mainCheckListNameTranslation_0').clear().type(eformName);
402+
cy.get('#mainCheckListNameTranslation_1').clear().type(eformName);
403403

404404
// Add first nested checklist
405405
cy.get('#initialChecklistCreateBtn').click();
@@ -424,7 +424,7 @@ describe('Visual editor - Create eForm', () => {
424424
cy.get('#edit-eform-btn-0').click();
425425
cy.wait('@geteForm', { timeout: 60000 });
426426

427-
cy.get('#mainCheckListNameTranslation_0').should('have.value', eformName);
427+
cy.get('#mainCheckListNameTranslation_1').should('have.value', eformName);
428428
});
429429

430430
it('should create visual template with one nested checklist and with some fields', () => {
@@ -434,7 +434,7 @@ describe('Visual editor - Create eForm', () => {
434434
const fieldName = generateRandmString();
435435

436436
// Set main checklist name
437-
cy.get('#mainCheckListNameTranslation_0').clear().type(eformName);
437+
cy.get('#mainCheckListNameTranslation_1').clear().type(eformName);
438438

439439
// Add first nested checklist
440440
cy.get('#initialChecklistCreateBtn').click();
@@ -467,7 +467,7 @@ describe('Visual editor - Create eForm', () => {
467467
cy.get('#edit-eform-btn-0').click();
468468
cy.wait('@geteForm', { timeout: 60000 });
469469

470-
cy.get('#mainCheckListNameTranslation_0').should('have.value', eformName);
470+
cy.get('#mainCheckListNameTranslation_1').should('have.value', eformName);
471471
});
472472

473473
it('should create visual template with one nested checklist and with pdfField', () => {
@@ -477,7 +477,7 @@ describe('Visual editor - Create eForm', () => {
477477
const fieldName = generateRandmString();
478478

479479
// Set main checklist name
480-
cy.get('#mainCheckListNameTranslation_0').clear().type(eformName);
480+
cy.get('#mainCheckListNameTranslation_1').clear().type(eformName);
481481

482482
// Add first nested checklist
483483
cy.get('#initialChecklistCreateBtn').click();
@@ -515,7 +515,7 @@ describe('Visual editor - Create eForm', () => {
515515
cy.get('#edit-eform-btn-0').click();
516516
cy.wait('@geteForm', { timeout: 60000 });
517517

518-
cy.get('#mainCheckListNameTranslation_0').should('have.value', eformName);
518+
cy.get('#mainCheckListNameTranslation_1').should('have.value', eformName);
519519
});
520520

521521
it('should create visual template and change order field (not nested)', () => {
@@ -524,27 +524,32 @@ describe('Visual editor - Create eForm', () => {
524524
const field2Name = generateRandmString();
525525

526526
// Set main checklist name
527-
cy.get('#mainCheckListNameTranslation_0').clear().type(eformName);
527+
cy.get('#mainCheckListNameTranslation_1').clear().type(eformName);
528528

529529
// Add first field
530530
cy.get('#initialFieldCreateBtn').click();
531531
cy.get('#fieldTypeSelector input').clear().type('Info');
532-
selectValueInNgSelectorNoSelector('Info element');
532+
selectValueInNgSelectorNoSelector('Info');
533533
cy.get('#fieldNameTranslation_0').clear().type(field1Name);
534534
cy.get('#changeFieldSaveBtn').click();
535535
cy.wait(1000);
536536

537537
// Add second field
538538
cy.get('#initialFieldCreateBtn').click();
539539
cy.get('#fieldTypeSelector input').clear().type('Info');
540-
selectValueInNgSelectorNoSelector('Info element');
540+
selectValueInNgSelectorNoSelector('Info');
541541
cy.get('#fieldNameTranslation_0').clear().type(field2Name);
542542
cy.get('#changeFieldSaveBtn').click();
543543
cy.wait(1000);
544544

545-
// Change field order using drag and drop
546-
cy.get('#fieldSection1').trigger('dragstart');
547-
cy.get('#fieldSection0').trigger('drop');
545+
cy.get('#fieldSection0') // draggable
546+
.trigger('mousedown', { button: 0, bubbles: true })
547+
.trigger('mousemove', { pageX: 10, pageY: 0 });
548+
549+
cy.get('#fieldSection1') // droppable
550+
551+
.trigger('mousemove', { position: 'center' })
552+
.trigger('mouseup', { button: 0, bubbles: true });
548553
cy.wait(1000);
549554

550555
// Save the eForm
@@ -553,7 +558,7 @@ describe('Visual editor - Create eForm', () => {
553558
cy.wait('@saveeForm', { timeout: 60000 });
554559

555560
// Verify field order when edited
556-
cy.get('#spinner-animation').should('not.exist');
561+
// cy.get('#spinner-animation').should('not.exist');
557562
cy.intercept('GET', '**/api/template-visual-editor/**').as('geteForm');
558563
cy.get('#edit-eform-btn-0').click();
559564
cy.wait('@geteForm', { timeout: 60000 });
@@ -570,7 +575,7 @@ describe('Visual editor - Create eForm', () => {
570575
const field2Name = generateRandmString();
571576

572577
// Set main checklist name
573-
cy.get('#mainCheckListNameTranslation_0').clear().type(eformName);
578+
cy.get('#mainCheckListNameTranslation_1').clear().type(eformName);
574579

575580
// Add nested checklist
576581
cy.get('#initialChecklistCreateBtn').click();
@@ -581,22 +586,27 @@ describe('Visual editor - Create eForm', () => {
581586
// Add first field to nested checklist
582587
cy.get('#addNewNestedField0').click();
583588
cy.get('#fieldTypeSelector input').clear().type('Info');
584-
selectValueInNgSelectorNoSelector('Info element');
589+
selectValueInNgSelectorNoSelector('Info');
585590
cy.get('#fieldNameTranslation_0').clear().type(field1Name);
586591
cy.get('#changeFieldSaveBtn').click();
587592
cy.wait(1000);
588593

589594
// Add second field to nested checklist
590595
cy.get('#addNewNestedField0').click();
591596
cy.get('#fieldTypeSelector input').clear().type('Info');
592-
selectValueInNgSelectorNoSelector('Info element');
597+
selectValueInNgSelectorNoSelector('Info');
593598
cy.get('#fieldNameTranslation_0').clear().type(field2Name);
594599
cy.get('#changeFieldSaveBtn').click();
595600
cy.wait(1000);
596601

597602
// Change nested field order using drag and drop
598-
cy.get('#fields_0 #fieldSection1').trigger('dragstart');
599-
cy.get('#fields_0 #fieldSection0').trigger('drop');
603+
cy.get('#fieldSection1') // draggable
604+
.trigger('mousedown', { button: 0, bubbles: true })
605+
.trigger('mousemove', { pageX: 10, pageY: 0 });
606+
607+
cy.get('#fieldSection0') // droppable
608+
.trigger('mousemove', { position: 'center' })
609+
.trigger('mouseup', { button: 0, bubbles: true });
600610
cy.wait(1000);
601611

602612
// Save the eForm
@@ -605,12 +615,12 @@ describe('Visual editor - Create eForm', () => {
605615
cy.wait('@saveeForm', { timeout: 60000 });
606616

607617
// Verify nested field order when edited
608-
cy.get('#spinner-animation').should('not.exist');
618+
// cy.get('#spinner-animation').should('not.exist');
609619
cy.intercept('GET', '**/api/template-visual-editor/**').as('geteForm');
610620
cy.get('#edit-eform-btn-0').click();
611621
cy.wait('@geteForm', { timeout: 60000 });
612622

613-
cy.get('#mainCheckListNameTranslation_0').should('have.value', eformName);
623+
cy.get('#mainCheckListNameTranslation_1').should('have.value', eformName);
614624
});
615625

616626
it('should correct read created eform from xml', () => {
@@ -682,7 +692,7 @@ describe('Visual editor - Create eForm', () => {
682692
cy.wait('@geteForm', { timeout: 60000 });
683693

684694
// Verify eForm created from XML has correct properties
685-
cy.get('#mainCheckListNameTranslation_0').should('have.value', eformName);
695+
cy.get('#mainCheckListNameTranslation_1').should('have.value', eformName);
686696
cy.get('#fieldSection0').should('contain', 'Number 2');
687697
});
688698

eform-client/src/app/modules/eforms/eform-visual-editor/components/eform-visual-editor-elements/field/visual-editor-field/visual-editor-field.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<mat-icon
1414
class="dragula-handle align-middle"
1515
style="cursor: pointer"
16-
[id]="fieldIsNested ? 'moveNestedFieldBtn' : 'moveFieldBtn'"
16+
[id]="fieldIsNested ? 'moveNestedFieldBtn'+fieldIndex : 'moveFieldBtn'+fieldIndex"
1717
>
1818
menu
1919
</mat-icon>

0 commit comments

Comments
 (0)