Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test - Switching themes #1308

Merged
merged 3 commits into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions apps/sensenet/cypress/integration/ui/themeSwitcher.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { pathWithQueryParams } from '../../../src/services/query-string-builder'

describe('Switching themes', () => {
beforeEach(() => {
cy.login()
cy.visit(pathWithQueryParams({ path: '/', newParams: { repoUrl: Cypress.env('repoUrl') } }))
})

it('should be set to light by default', () => {
cy.get('[data-test="user-menu-button"]').click()
cy.get('[data-test="theme-status"]').should('have.text', 'Dark theme')
cy.get('[data-test="theme-switcher"]')
.should('be.visible')
.parent()
.find('.MuiSwitch-input')
.should('not.be.checked')
})

it('should switch theme to dark on click', () => {
cy.get('[data-test="user-menu-button"]').click()
cy.get('[data-test="theme-switcher"]').click()

cy.get('[data-test="theme-status"]').should('have.text', 'Light theme')
cy.get('[data-test="theme-switcher"]').should('be.visible').parent().find('.MuiSwitch-input').should('be.checked')
})
})
9 changes: 7 additions & 2 deletions apps/sensenet/src/components/appbar/desktop-nav-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export const DesktopNavMenu: FunctionComponent = () => {
}}
/>
<IconButton
data-test="user-menu-button"
aria-label={localization.topMenu.openUserMenu}
aria-controls={openUserMenu ? 'menu-list-grow' : undefined}
aria-haspopup="true"
Expand Down Expand Up @@ -167,11 +168,15 @@ export const DesktopNavMenu: FunctionComponent = () => {
<MenuItem>
<Typography component="div" className={classes.themeSwitcher}>
<Grid component="label" container alignItems="center" spacing={1}>
<Grid item style={{ paddingRight: '32px' }}>
<Grid item style={{ paddingRight: '32px' }} data-test="theme-status">
{personalSettings.theme === 'dark' ? 'Light theme' : 'Dark theme'}
</Grid>
<Grid item>
<Switch checked={personalSettings.theme === 'dark'} onChange={switchTheme()} />
<Switch
data-test="theme-switcher"
checked={personalSettings.theme === 'dark'}
onChange={switchTheme()}
/>
</Grid>
</Grid>
</Typography>
Expand Down