Skip to content

Commit 2e9ab47

Browse files
committed
Fixing more menu testing.
1 parent df153ad commit 2e9ab47

File tree

4 files changed

+55
-52
lines changed

4 files changed

+55
-52
lines changed

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

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,28 @@ export class NavigationMenuPage {
88

99
// Template controls
1010
public collapseTemplates(index: number) {
11-
cy.get('#menuTemplate').eq(index).find('.mat-expansion-indicator').click();
11+
cy.get('.menuTemplate').eq(index).find('.mat-expansion-indicator').click();
1212
cy.wait(2000); // Wait for menu to open/close
1313
}
1414

1515
// Menu Items
1616
public getMenuItems() {
17-
return cy.get('#menuItems');
17+
return cy.get('.menu_item');
1818
}
1919

2020
public getMenuItemsCount() {
21-
return cy.get('#menuItems').its('length');
21+
return cy.get('.menu_item').its('length');
2222
}
2323

2424
// Create operations
2525
public createMenuItemFromTemplate(templateIndex: number) {
2626
const dragHandle = cy.get(`#dragHandle0_${templateIndex}`);
2727
const target = cy.get('mat-card > mat-accordion').first();
28-
28+
2929
dragHandle
3030
.trigger('mousedown', { button: 0, bubbles: true })
3131
.trigger('mousemove', { pageX: 10, pageY: 0 });
32-
32+
3333
target
3434
.trigger('mousemove', { position: 'top' })
3535
.trigger('mouseup', { button: 0, bubbles: true });
@@ -77,7 +77,7 @@ export class NavigationMenuPage {
7777

7878
// Edit operations
7979
public openEditMenuItem(index: number) {
80-
cy.get('#menuItems').eq(index).find('#editBtn').click();
80+
cy.get('.menu_item').eq(index).find('#editBtn').click();
8181
cy.get('#editItemSaveBtn').should('be.visible');
8282
}
8383

@@ -157,13 +157,13 @@ export class NavigationMenuPage {
157157

158158
// Delete operations
159159
public deleteElementFromMenuItems(index: number) {
160-
cy.get('#menuItems').eq(index).find('#deleteBtn').scrollIntoView().click();
160+
cy.get('.menu_item').eq(index).find('#deleteBtn').scrollIntoView().click();
161161
cy.wait(500);
162162
cy.get('#menuItemDeleteBtn').should('be.visible').click();
163163
}
164164

165165
public deleteElementFromDropdown(dropdownIndex: number, itemIndex: number) {
166-
cy.get('#menuItems').eq(dropdownIndex)
166+
cy.get('.menu_item').eq(dropdownIndex)
167167
.find('#dropdownBody>*').eq(itemIndex)
168168
.find('#deleteBtn').scrollIntoView().click();
169169
cy.wait(500);
@@ -175,27 +175,27 @@ export class NavigationMenuPage {
175175

176176
// Dropdown operations
177177
public collapseMenuItemDropdown(index: number) {
178-
cy.get('#menuItems').eq(index).find('.mat-expansion-indicator').click();
178+
cy.get('.menu_item').eq(index).find('.mat-expansion-indicator').click();
179179
}
180180

181181
public getDropdownBodyChilds(dropdownIndex: number) {
182-
return cy.get('#menuItems').eq(dropdownIndex).find('#dropdownBody>*');
182+
return cy.get('.menu_item').eq(dropdownIndex).find('#dropdownBody>*');
183183
}
184184

185185
public dragTemplateOnElementInCreatedDropdown(templateIndex: number, dropdownIndex: number) {
186186
this.collapseTemplates(0);
187-
187+
188188
const dragHandle = cy.get(`#dragHandle0_${templateIndex}`);
189-
const dropdownBody = cy.get('#menuItems').eq(dropdownIndex).find('#dropdownBody');
189+
const dropdownBody = cy.get('.menu_item').eq(dropdownIndex).find('#dropdownBody');
190190

191191
dragHandle
192192
.trigger('mousedown', { button: 0, bubbles: true })
193193
.trigger('mousemove', { pageX: 10, pageY: 0 });
194-
194+
195195
dropdownBody
196196
.trigger('mousemove', { position: 'center' })
197197
.trigger('mouseup', { button: 0, bubbles: true });
198-
198+
199199
cy.wait(500);
200200
this.collapseTemplates(0);
201201
}
@@ -205,10 +205,10 @@ export class NavigationMenuPage {
205205
indexDropdownInMenu: number;
206206
translations_array: string[];
207207
}) {
208-
cy.get('#menuItems').eq(data.indexDropdownInMenu)
208+
cy.get('.menu_item').eq(data.indexDropdownInMenu)
209209
.find('#dropdownBody>*').eq(data.indexChildDropdown)
210210
.find('#editBtn').click();
211-
211+
212212
cy.get('#editItemSaveBtn').should('be.visible');
213213

214214
data.translations_array.forEach((translation, idx) => {
@@ -231,11 +231,11 @@ export class NavigationMenuPage {
231231
fromHandle
232232
.trigger('mousedown', { button: 0, bubbles: true })
233233
.trigger('mousemove', { pageX: 10, pageY: 0 });
234-
234+
235235
toHandle
236236
.trigger('mousemove', { position: 'center' })
237237
.trigger('mouseup', { button: 0, bubbles: true });
238-
238+
239239
cy.wait(2000);
240240
}
241241

@@ -273,14 +273,18 @@ export class NavigationMenuPage {
273273
}
274274

275275
public resetMenu() {
276-
cy.wait(1100);
277-
cy.wait(1200);
278-
cy.wait(1400);
276+
// cy.wait(1100);
277+
// cy.wait(1200);
278+
// cy.wait(1400);
279279
cy.get('#resetBtn').scrollIntoView().click();
280280
cy.wait(500);
281+
cy.intercept('POST', '**/api/navigation-menu/reset').as('resetMenu');
282+
cy.intercept('GET', '**/api/navigation-menu').as('getMenuAfterReset');
281283
cy.get('#deleteWorkerDeleteBtn').should('be.visible').click();
284+
cy.wait('@resetMenu', { timeout: 30000 });
285+
cy.wait('@getMenuAfterReset', { timeout: 30000 });
282286
// Note: Tests should intercept POST /api/navigation-menu/reset and wait for it instead
283-
cy.wait(500);
287+
// cy.wait(500);
284288
}
285289

286290
// Helper methods - DEPRECATED: Use API intercepts in tests instead

eform-client/cypress/e2e/c/navigation-menu.create-item.spec.cy.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,33 @@ describe('Navigation menu - Create item', function () {
1515
navigationMenuPage.getMenuItems().its('length').then(initialCount => {
1616
navigationMenuPage.collapseTemplates(0);
1717
navigationMenuPage.createMenuItemFromTemplate(0);
18-
18+
1919
// Wait for DOM update after drag-and-drop (matching WDIO test behavior)
2020
cy.wait(500);
2121

2222
// Verify count increased
23-
navigationMenuPage.getMenuItems().should('have.length', initialCount + 1);
24-
23+
navigationMenuPage.getMenuItems().should('have.length', 4);
24+
2525
// Intercept save operation
26-
cy.intercept('POST', '**/api/navigation-menu').as('saveMenu');
26+
cy.intercept('PUT', '**/api/navigation-menu').as('saveMenu');
2727
navigationMenuPage.clickSaveMenuBtn();
2828
cy.wait('@saveMenu', { timeout: 30000 });
29-
29+
3030
navigationMenuPage.openEditMenuItem(0);
31-
31+
3232
// Verify link field
3333
cy.get('#editLinkInput').should('have.value', '/');
34-
34+
3535
// Verify translations
3636
cy.get('#editItemTranslation0_0_0').should('have.value', 'My eForms');
3737
cy.get('#editItemTranslation0_0_1').should('have.value', 'Mine eForms');
3838
cy.get('#editItemTranslation0_0_2').should('have.value', 'Meine eForms');
39-
39+
4040
// Intercept edit save operation
41-
cy.intercept('POST', '**/api/navigation-menu').as('saveMenuEdit');
41+
// cy.intercept('PUT', '**/api/navigation-menu').as('saveMenuEdit');
4242
navigationMenuPage.editItemSave();
43-
cy.wait('@saveMenuEdit', { timeout: 30000 });
44-
43+
// cy.wait('@saveMenuEdit', { timeout: 30000 });
44+
4545
navigationMenuPage.collapseTemplates(0);
4646
});
4747
});
@@ -56,15 +56,15 @@ describe('Navigation menu - Create item', function () {
5656
navigationMenuPage.getMenuItems().its('length').then(initialCount => {
5757
navigationMenuPage.collapseTemplates(1);
5858
navigationMenuPage.createCustomLink(customLink);
59-
59+
6060
// Wait for DOM update after creating custom link (matching WDIO test behavior)
6161
cy.wait(1000);
6262

6363
// Verify count increased
6464
navigationMenuPage.getMenuItems().should('have.length', initialCount + 1);
65-
65+
6666
// Intercept save operation
67-
cy.intercept('POST', '**/api/navigation-menu').as('saveMenu');
67+
cy.intercept('PUT', '**/api/navigation-menu').as('saveMenu');
6868
navigationMenuPage.clickSaveMenuBtn();
6969
cy.wait('@saveMenu', { timeout: 30000 });
7070

@@ -83,9 +83,9 @@ describe('Navigation menu - Create item', function () {
8383
});
8484

8585
// Intercept edit save operation
86-
cy.intercept('POST', '**/api/navigation-menu').as('saveMenuEdit');
86+
// cy.intercept('PUT', '**/api/navigation-menu').as('saveMenuEdit');
8787
navigationMenuPage.editItemSave();
88-
cy.wait('@saveMenuEdit', { timeout: 30000 });
88+
// cy.wait('@saveMenuEdit', { timeout: 30000 });
8989
});
9090
});
9191
});
@@ -99,15 +99,15 @@ describe('Navigation menu - Create item', function () {
9999
navigationMenuPage.getMenuItems().its('length').then(initialCount => {
100100
navigationMenuPage.collapseTemplates(1);
101101
navigationMenuPage.createCustomDropdown(dropdown);
102-
102+
103103
// Wait for DOM update after creating dropdown (matching WDIO test behavior)
104104
cy.wait(1500);
105105

106106
// Verify count increased
107107
navigationMenuPage.getMenuItems().should('have.length', initialCount + 1);
108-
108+
109109
// Intercept save operation
110-
cy.intercept('POST', '**/api/navigation-menu').as('saveMenu');
110+
cy.intercept('PUT', '**/api/navigation-menu').as('saveMenu');
111111
navigationMenuPage.clickSaveMenuBtn();
112112
cy.wait('@saveMenu', { timeout: 30000 });
113113

@@ -123,9 +123,9 @@ describe('Navigation menu - Create item', function () {
123123
});
124124

125125
// Intercept edit save operation
126-
cy.intercept('POST', '**/api/navigation-menu').as('saveMenuEdit');
126+
// cy.intercept('PUT', '**/api/navigation-menu').as('saveMenuEdit');
127127
navigationMenuPage.editItemSave();
128-
cy.wait('@saveMenuEdit', { timeout: 30000 });
128+
// cy.wait('@saveMenuEdit', { timeout: 30000 });
129129
});
130130
});
131131
});
@@ -139,15 +139,15 @@ describe('Navigation menu - Create item', function () {
139139
navigationMenuPage.getMenuItems().its('length').then(initialCount => {
140140
navigationMenuPage.collapseTemplates(1);
141141
navigationMenuPage.createCustomDropdown(dropdown);
142-
142+
143143
// Wait for DOM update after creating dropdown (matching WDIO test behavior)
144144
cy.wait(1500);
145145

146146
// Verify count increased
147147
navigationMenuPage.getMenuItems().should('have.length', initialCount + 1);
148-
148+
149149
// Intercept save operation
150-
cy.intercept('POST', '**/api/navigation-menu').as('saveMenu');
150+
cy.intercept('PUT', '**/api/navigation-menu').as('saveMenu');
151151
navigationMenuPage.clickSaveMenuBtn();
152152
cy.wait('@saveMenu', { timeout: 30000 });
153153

@@ -168,9 +168,9 @@ describe('Navigation menu - Create item', function () {
168168
});
169169

170170
// Intercept edit save operation
171-
cy.intercept('POST', '**/api/navigation-menu').as('saveMenuEdit');
171+
// cy.intercept('PUT', '**/api/navigation-menu').as('saveMenuEdit');
172172
navigationMenuPage.editItemSave();
173-
cy.wait('@saveMenuEdit', { timeout: 30000 });
173+
// cy.wait('@saveMenuEdit', { timeout: 30000 });
174174
});
175175
});
176176
});

eform-client/src/app/modules/advanced/modules/navigation-menu/components/menu-custom/navigation-menu-custom/navigation-menu-custom.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<mat-expansion-panel class="mt-2" id="menuTemplate">
1+
<mat-expansion-panel class="mt-2" class="menuTemplate">
22
<mat-expansion-panel-header>
33
<mat-panel-title>
44
{{ 'Custom' | translate }}

eform-client/src/app/modules/advanced/modules/navigation-menu/components/navigation-menu-page/navigation-menu-page.component.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<mat-accordion multi="true" displayMode="flat" class="mr-2">
2424
<mat-expansion-panel *ngFor="
2525
let menuTemplate of navigationMenuModel.menuTemplates;
26-
let templateIndex = index" id="menuTemplate">
26+
let templateIndex = index" class="menuTemplate">
2727
<mat-expansion-panel-header>
2828
<mat-panel-title>
2929
{{ menuTemplate.name }}
@@ -69,8 +69,7 @@
6969
let firstLevelIndex = index"
7070
[hideToggle]="menuItem.type !== menuItemTypes.Dropdown"
7171
cdkDrag
72-
class="dragula-item"
73-
id="menuItems"
72+
class="menu_item"
7473
>
7574
<mat-expansion-panel-header>
7675
<mat-panel-title>

0 commit comments

Comments
 (0)