Skip to content

Commit

Permalink
#2490 Add a test for theme preference
Browse files Browse the repository at this point in the history
  • Loading branch information
dwalizer committed Jun 21, 2024
1 parent 2c9c7d2 commit 2f8be2e
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions e2e-tests/cypress/e2e/settings_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1621,5 +1621,44 @@ describe('Settings Tests', () => {
cy.get('[data-cy=saveSettingsBtn]')
.should('be.enabled');
});

it('Theme preference can be toggled and remains on refresh', () => {
cy.intercept('POST', '/app/userInfo/**')
.as('saveUserInfo');
cy.intercept('GET', '/app/userInfo/**')
.as('loadUserInfo');
cy.intercept('/app/projects')
.as('loadProjects');
cy.intercept('/api/myProgressSummary')
.as('loadMyProgressSummary');

cy.visit('/administrator/');
cy.navToSettings();
cy.get('[data-cy="nav-Preferences"]').click();

cy.get('[data-cy="enableDarkMode"]').should('exist');
cy.get('[data-cy="enableDarkMode"]').contains('Off');
cy.get('[data-cy="enableDarkModeSwitch"]').click();
cy.get('[data-cy="enableDarkMode"]').contains('On');
cy.get('[data-cy=userPrefsSettingsSave]').should('be.enabled');
cy.get('[data-cy=userPrefsSettingsSave]').click();
cy.get('[data-cy="nav-System"]').click();

cy.get('[data-cy="nav-Preferences"]').click();
cy.get('[data-cy="enableDarkMode"]').should('exist');
cy.get('[data-cy="enableDarkMode"]').contains('On');
cy.get('[data-cy=userPrefsSettingsSave]').should('not.be.enabled');

cy.reload();

cy.get('[data-cy="enableDarkMode"]').should('exist');
cy.get('[data-cy="enableDarkMode"]').contains('On');
cy.get('[data-cy=userPrefsSettingsSave]').should('not.be.enabled');

cy.get('[data-cy="nav-Preferences"]').click();
cy.get('[data-cy="enableDarkModeSwitch"]').click();
cy.get('[data-cy="enableDarkMode"]').contains('Off');
cy.get('[data-cy=userPrefsSettingsSave]').should('be.enabled');
});
});

0 comments on commit 2f8be2e

Please sign in to comment.