Skip to content

Commit 83b8a4d

Browse files
authored
Merge pull request #7168 from microting/copilot/migrate-profile-settings-tests
Migrate Profile Settings Language Tests to Cypress
2 parents 652d1f7 + 0ba310f commit 83b8a4d

File tree

4 files changed

+125
-9
lines changed

4 files changed

+125
-9
lines changed

WDIO_TO_CYPRESS_MIGRATION.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ This document tracks the migration of WebDriverIO (wdio) e2e tests to Cypress te
77
## Current Status
88

99
- **Total wdio tests**: 38
10-
- **Cypress tests implemented**: 49
11-
- **Tests remaining to migrate**: 1
10+
- **Cypress tests implemented**: 50
11+
- **Tests remaining to migrate**: 0
1212

1313
## Tests Already Migrated to Cypress ✓
1414

@@ -44,6 +44,9 @@ The following wdio tests have been successfully migrated to Cypress:
4444
### Password Settings
4545
- ✓ password-settings.change-password.spec.ts (cypress/e2e/e/)
4646

47+
### Profile Settings
48+
- ✓ profile-settings.language.spec.cy.ts (cypress/e2e/e/)
49+
4750
### User Administration
4851
- ✓ user-administration.name-change.spec.ts (cypress/e2e/e/)
4952

@@ -230,14 +233,15 @@ Tests migrated:
230233

231234
---
232235

233-
### 8. Profile Settings (1 test)
236+
### 8. Profile Settings (1 test)
234237

235238
**Category**: User Profile Settings
236239
**Priority**: Medium
237-
**Location**: e2e/Tests/profile-settings/
240+
**Location**: e2e/Tests/profile-settings/
241+
**Migrated to**: cypress/e2e/e/
238242

239-
Tests to migrate:
240-
- [ ] profile-settings.language.spec.ts
243+
Tests migrated:
244+
- profile-settings.language.spec.cy.ts
241245

242246
**Description**: Tests for changing user interface language preferences.
243247

@@ -415,13 +419,13 @@ Use this section to track overall migration progress:
415419
- [x] Folders - Folder Child (3 tests) ✓
416420
- [x] Navigation Menu (4 tests) ✓
417421
- [x] Password Settings (1 test) ✓
418-
- [ ] Profile Settings (1 test)
422+
- [x] Profile Settings (1 test)
419423
- [x] Searchable Lists (3 tests) ✓
420424
- [x] Selectable Lists (4 tests) ✓
421425
- [x] User Administration (1 test) ✓
422426
- [x] Workers (2 tests) ✓
423427

424-
**Total Progress**: 26/28 tests migrated (92.9%)
428+
**Total Progress**: 28/28 tests migrated (100.0%)
425429

426430
## Notes
427431

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { PageWithNavbarPage } from './PageWithNavbar.page';
2+
3+
class ProfileSettingsPage extends PageWithNavbarPage {
4+
languageSelector() {
5+
return cy.get('#ProfileLanguageSelector');
6+
}
7+
8+
saveBtn() {
9+
return cy.get('#ProfileSettingsSaveBtn');
10+
}
11+
12+
saveProfileSettings() {
13+
cy.intercept('PUT', '**/api/user-settings').as('updateUserSettings');
14+
this.saveBtn().should('be.visible').should('be.enabled').click();
15+
cy.wait('@updateUserSettings', { timeout: 10000 });
16+
cy.get('#spinner-animation').should('not.exist');
17+
cy.wait(500);
18+
}
19+
20+
chooseLanguage(language: string) {
21+
// Click on the language selector
22+
this.languageSelector().should('be.visible').click();
23+
cy.wait(500);
24+
// Type the language name into the input field
25+
cy.get('#ProfileLanguageSelector input').type(language);
26+
cy.wait(200);
27+
// Press Enter to select the option
28+
cy.get('body').type('{enter}');
29+
cy.wait(500);
30+
}
31+
}
32+
33+
const profileSettingsPage = new ProfileSettingsPage();
34+
export default profileSettingsPage;
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import loginPage from '../Login.page';
2+
import profileSettingsPage from '../ProfileSettings.page';
3+
import { expect } from 'chai';
4+
5+
const translationsEFormsPageEng: Array<{ selector: string; value: string }> = [
6+
{ selector: 'eform-new-subheader h2', value: 'My eForms' },
7+
];
8+
9+
const translationsEFormsPageDan: Array<{ selector: string; value: string }> = [
10+
{ selector: 'eform-new-subheader h2', value: 'Mine eForms' },
11+
];
12+
13+
describe('Profile Settings - Language', function () {
14+
before(() => {
15+
cy.visit('http://localhost:4200');
16+
loginPage.login();
17+
});
18+
19+
it('should set language to English', () => {
20+
// Navigate to profile settings
21+
profileSettingsPage.Navbar.goToProfileSettings();
22+
cy.get('#ProfileLanguageSelector').should('be.visible');
23+
24+
// Choose English language
25+
profileSettingsPage.chooseLanguage('English');
26+
profileSettingsPage.saveProfileSettings();
27+
28+
// Navigate to My eForms to verify language change
29+
profileSettingsPage.Navbar.goToMyEForms();
30+
cy.get('#newEFormBtn').should('be.visible');
31+
32+
// Verify UI is in English
33+
for (const translation of translationsEFormsPageEng) {
34+
cy.get(translation.selector)
35+
.invoke('text')
36+
.then(text => {
37+
expect(text.trim()).to.equal(
38+
translation.value,
39+
`element with selector ${translation.selector} must be = ${translation.value}, but element text = ${text.trim()}. Language = English`
40+
);
41+
});
42+
}
43+
});
44+
45+
it('should set language to Dansk', () => {
46+
// Navigate to profile settings
47+
profileSettingsPage.Navbar.goToProfileSettings();
48+
cy.get('#ProfileLanguageSelector').should('be.visible');
49+
50+
// Choose Danish language
51+
profileSettingsPage.chooseLanguage('Dansk');
52+
profileSettingsPage.saveProfileSettings();
53+
54+
// Navigate to My eForms to verify language change
55+
profileSettingsPage.Navbar.goToMyEForms();
56+
cy.get('#newEFormBtn').should('be.visible');
57+
58+
// Verify UI is in Danish
59+
for (const translation of translationsEFormsPageDan) {
60+
cy.get(translation.selector)
61+
.invoke('text')
62+
.then(text => {
63+
expect(text.trim()).to.equal(
64+
translation.value,
65+
`element with selector ${translation.selector} must be = ${translation.value}, but element text = ${text.trim()}. Language = Dansk`
66+
);
67+
});
68+
}
69+
});
70+
71+
after(() => {
72+
// Reset to English after tests
73+
profileSettingsPage.Navbar.goToProfileSettings();
74+
cy.get('#ProfileLanguageSelector').should('be.visible');
75+
profileSettingsPage.chooseLanguage('English');
76+
profileSettingsPage.saveProfileSettings();
77+
});
78+
});

migration-issues/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This directory contains detailed specifications for each sub-issue in the wdio t
1515
| 07 | [Searchable Lists](07-searchable-lists.md) | 🟡 MEDIUM | 3 | ✅ Complete |
1616
| 08 | [Selectable Lists](08-selectable-lists.md) | 🟡 MEDIUM | 4 | ✅ Complete |
1717
| 09 | [Workers](09-workers.md) | 🟡 MEDIUM | 2 | ✅ Complete |
18-
| 10 | [Profile Settings](10-profile-settings.md) | 🟡 MEDIUM | 1 | ⏳ Pending |
18+
| 10 | [Profile Settings](10-profile-settings.md) | 🟡 MEDIUM | 1 | ✅ Complete |
1919
| 11 | [eForm Visual Editor - Create](11-eform-visual-editor-create.md) | 🔴 HIGH | 1 | ✅ Complete |
2020
| | **TOTAL** | | **28** | **89% Complete** |
2121

0 commit comments

Comments
 (0)