Skip to content

Commit 82a4257

Browse files
committed
working tests
1 parent 2e7df03 commit 82a4257

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

cypress/e2e/new-system/04-system-reset.spec.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ describe('04 - System Reset', () => {
2525
const manualLogin = () => {
2626
cy.clearCookies();
2727
cy.clearLocalStorage();
28-
const password = Cypress.env('newSystemAdminPassword') || adminCredentials.password;
28+
// Admin password is 'changeme'. After a DB reset NeedPasswordChange=true,
29+
// which forces a redirect to /changepassword on first login.
30+
const password = adminCredentials.password;
2931
cy.visit('/login');
3032
cy.get('input[name=User]', { timeout: 15000 }).type(adminCredentials.username);
3133
cy.get('input[name=Password]').type(password);
@@ -34,16 +36,15 @@ describe('04 - System Reset', () => {
3436
// Give the session time to establish
3537
cy.wait(1000);
3638

37-
// After a DB reset the admin has NeedPasswordChange=true; complete the forced form if needed
39+
// After a DB reset the admin has NeedPasswordChange=true; complete the forced form if needed.
40+
// The forced form uses button[type=submit] (login-box layout, not card layout).
3841
cy.url().then((url) => {
3942
if (url.includes('/changepassword')) {
40-
const newPassword = 'Cypress@01!';
4143
cy.get('#OldPassword').type(password);
42-
cy.get('#NewPassword1').type(newPassword);
43-
cy.get('#NewPassword2').type(newPassword);
44+
cy.get('#NewPassword1').type('Cypress@01!');
45+
cy.get('#NewPassword2').type('Cypress@01!');
4446
cy.get('button[type=submit]').click();
4547
cy.contains('Password Changed', { timeout: 10000 }).should('be.visible');
46-
Cypress.env('newSystemAdminPassword', newPassword);
4748
}
4849
});
4950
};
@@ -84,10 +85,6 @@ describe('04 - System Reset', () => {
8485
it('should reset the database via API', () => {
8586
manualLogin();
8687

87-
// After reset the DB reverts to admin/changeme with NeedPasswordChange=true.
88-
// Clear the tracked password so manualLogin() uses 'changeme' on the next call.
89-
Cypress.env('newSystemAdminPassword', null);
90-
9188
// Perform reset via API
9289
cy.request({
9390
method: 'DELETE',
@@ -135,14 +132,18 @@ describe('04 - System Reset', () => {
135132
});
136133

137134
it('should login with default credentials after reset', () => {
138-
// Fresh login after reset (no session caching)
135+
// manualLogin() uses 'changeme', detects forced /changepassword redirect,
136+
// and completes it — leaving password as 'Cypress@01!' with NeedPasswordChange=false.
139137
manualLogin();
140138

141-
// After reset NeedPasswordChange=true, so manualLogin() completes the forced change
142-
// and lands on the success page; accept either that or the admin dashboard.
143-
cy.url().should('satisfy', (url) => {
144-
return url.includes('/admin') || url.includes('/changepassword') || url.includes('/v2/');
145-
});
139+
// Now change it back to 'changeme' so Steps 10d/10e can login cleanly.
140+
// NeedPasswordChange=false so this shows the voluntary form (input[type=submit]).
141+
cy.visit('/v2/user/current/changepassword');
142+
cy.get('#OldPassword').type('Cypress@01!');
143+
cy.get('#NewPassword1').type('changeme');
144+
cy.get('#NewPassword2').type('changeme');
145+
cy.get('input[type=submit]').click();
146+
cy.contains('Password Change Successful', { timeout: 10000 }).should('be.visible');
146147
});
147148
});
148149

0 commit comments

Comments
 (0)