-
Notifications
You must be signed in to change notification settings - Fork 952
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web): hide consumption toggle behind ff (#7314)
* feat(web): hide consumption toggle behind ff * tests(web): update cypress tests to have atom context
- Loading branch information
Showing
6 changed files
with
138 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,66 @@ | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { I18nextProvider } from 'react-i18next'; | ||
import i18n from 'translation/i18n'; | ||
|
||
import MapControls from './MapControls'; | ||
|
||
it('can change language', () => { | ||
cy.viewport(800, 500); | ||
cy.mount( | ||
<I18nextProvider i18n={i18n}> | ||
<MapControls /> | ||
</I18nextProvider> | ||
); | ||
cy.get('[data-test-id=language-selector-open-button]').click(); | ||
cy.contains('English').click(); | ||
cy.contains('country'); | ||
cy.contains('zone'); | ||
cy.contains('production'); | ||
cy.contains('consumption'); | ||
cy.get('[data-test-id=language-selector-open-button]').click(); | ||
cy.contains('Deutsch').click(); | ||
cy.contains('Produktion'); | ||
cy.contains('Verbrauch'); | ||
cy.get('[data-test-id=language-selector-open-button]').click(); | ||
cy.contains('Svenska').click(); | ||
cy.contains('produktion'); | ||
cy.contains('konsumtion'); | ||
cy.contains('land'); | ||
cy.contains('zon'); | ||
cy.get('[data-test-id=language-selector-open-button]').click(); | ||
cy.contains('English').click(); | ||
}); | ||
describe('MapControls', () => { | ||
const queryClient = new QueryClient(); | ||
|
||
it('can change theme', () => { | ||
cy.viewport(800, 500); | ||
cy.mount(<MapControls />); | ||
cy.get('[data-test-id=theme-selector-open-button]').click(); | ||
cy.contains('System'); | ||
cy.contains('Light') | ||
.click() | ||
.should(() => { | ||
expect(localStorage.getItem('theme')).to.eq('"light"'); | ||
}); | ||
cy.get('[data-test-id=theme-selector-open-button]').click(); | ||
cy.contains('Dark') | ||
.click() | ||
.should(() => { | ||
expect(localStorage.getItem('theme')).to.eq('"dark"'); | ||
beforeEach(() => { | ||
cy.intercept('/feature-flags', { | ||
body: { 'consumption-only': false }, | ||
}); | ||
}); | ||
|
||
it('can change language', () => { | ||
cy.viewport(800, 500); | ||
cy.mount( | ||
<QueryClientProvider client={queryClient}> | ||
<I18nextProvider i18n={i18n}> | ||
<MapControls /> | ||
</I18nextProvider> | ||
</QueryClientProvider> | ||
); | ||
cy.get('[data-test-id=language-selector-open-button]').click(); | ||
cy.contains('English').click(); | ||
cy.contains('country'); | ||
cy.contains('zone'); | ||
cy.contains('production'); | ||
cy.contains('consumption'); | ||
cy.get('[data-test-id=language-selector-open-button]').click(); | ||
cy.contains('Deutsch').click(); | ||
cy.contains('Produktion'); | ||
cy.contains('Verbrauch'); | ||
cy.get('[data-test-id=language-selector-open-button]').click(); | ||
cy.contains('Svenska').click(); | ||
cy.contains('produktion'); | ||
cy.contains('konsumtion'); | ||
cy.contains('land'); | ||
cy.contains('zon'); | ||
cy.get('[data-test-id=language-selector-open-button]').click(); | ||
cy.contains('English').click(); | ||
}); | ||
|
||
it('can change theme', () => { | ||
cy.viewport(800, 500); | ||
cy.mount( | ||
<QueryClientProvider client={queryClient}> | ||
<MapControls /> | ||
</QueryClientProvider> | ||
); | ||
cy.get('[data-test-id=theme-selector-open-button]').click(); | ||
cy.contains('System'); | ||
cy.contains('Light') | ||
.click() | ||
.should(() => { | ||
expect(localStorage.getItem('theme')).to.eq('"light"'); | ||
}); | ||
cy.get('[data-test-id=theme-selector-open-button]').click(); | ||
cy.contains('Dark') | ||
.click() | ||
.should(() => { | ||
expect(localStorage.getItem('theme')).to.eq('"dark"'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,64 @@ | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { I18nextProvider } from 'react-i18next'; | ||
|
||
import i18n from '../../translation/i18n'; | ||
import { SettingsModalContent } from './SettingsModal'; | ||
|
||
it('can change language', () => { | ||
cy.viewport(500, 500); | ||
cy.mount( | ||
<I18nextProvider i18n={i18n}> | ||
<SettingsModalContent /> | ||
</I18nextProvider> | ||
); | ||
cy.contains('Wind data is currently unavailable'); | ||
cy.contains('Solar data is currently unavailable'); | ||
cy.get('[data-test-id=language-selector-open-button]').click(); | ||
cy.contains('English').click(); | ||
cy.contains('country'); | ||
cy.contains('zone'); | ||
cy.contains('production'); | ||
cy.contains('consumption'); | ||
cy.get('[data-test-id=language-selector-open-button]').click(); | ||
cy.contains('Deutsch').click(); | ||
cy.contains('Produktion'); | ||
cy.contains('Verbrauch'); | ||
cy.get('[data-test-id=language-selector-open-button]').click(); | ||
cy.contains('Svenska').click(); | ||
cy.contains('produktion'); | ||
cy.contains('konsumtion'); | ||
cy.contains('land'); | ||
cy.contains('zon'); | ||
cy.get('[data-test-id=language-selector-open-button]').click(); | ||
cy.contains('English').click(); | ||
}); | ||
describe('SettingsModalContent', () => { | ||
const queryClient = new QueryClient(); | ||
|
||
it('can change language', () => { | ||
cy.viewport(500, 500); | ||
cy.mount( | ||
<QueryClientProvider client={queryClient}> | ||
<I18nextProvider i18n={i18n}> | ||
<SettingsModalContent /> | ||
</I18nextProvider> | ||
</QueryClientProvider> | ||
); | ||
cy.contains('Wind data is currently unavailable'); | ||
cy.contains('Solar data is currently unavailable'); | ||
cy.get('[data-test-id=language-selector-open-button]').click(); | ||
cy.contains('English').click(); | ||
cy.contains('country'); | ||
cy.contains('zone'); | ||
cy.contains('production'); | ||
cy.contains('consumption'); | ||
cy.get('[data-test-id=language-selector-open-button]').click(); | ||
cy.contains('Deutsch').click(); | ||
cy.contains('Produktion'); | ||
cy.contains('Verbrauch'); | ||
cy.get('[data-test-id=language-selector-open-button]').click(); | ||
cy.contains('Svenska').click(); | ||
cy.contains('produktion'); | ||
cy.contains('konsumtion'); | ||
cy.contains('land'); | ||
cy.contains('zon'); | ||
cy.get('[data-test-id=language-selector-open-button]').click(); | ||
cy.contains('English').click(); | ||
}); | ||
|
||
it('can change theme', () => { | ||
cy.viewport(500, 500); | ||
cy.mount( | ||
<I18nextProvider i18n={i18n}> | ||
<SettingsModalContent /> | ||
</I18nextProvider> | ||
); | ||
cy.get('[data-test-id=theme-selector-open-button]').click(); | ||
cy.contains('System'); | ||
cy.contains('Light') | ||
.click() | ||
.should(() => { | ||
expect(localStorage.getItem('theme')).to.eq('"light"'); | ||
}); | ||
cy.get('[data-test-id=theme-selector-open-button]').click(); | ||
cy.contains('Dark') | ||
.click() | ||
.should(() => { | ||
expect(localStorage.getItem('theme')).to.eq('"dark"'); | ||
}); | ||
it('can change theme', () => { | ||
cy.viewport(500, 500); | ||
cy.mount( | ||
<QueryClientProvider client={queryClient}> | ||
<I18nextProvider i18n={i18n}> | ||
<SettingsModalContent /> | ||
</I18nextProvider> | ||
</QueryClientProvider> | ||
); | ||
cy.get('[data-test-id=theme-selector-open-button]').click(); | ||
cy.contains('System'); | ||
cy.contains('Light') | ||
.click() | ||
.should(() => { | ||
expect(localStorage.getItem('theme')).to.eq('"light"'); | ||
}); | ||
cy.get('[data-test-id=theme-selector-open-button]').click(); | ||
cy.contains('Dark') | ||
.click() | ||
.should(() => { | ||
expect(localStorage.getItem('theme')).to.eq('"dark"'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters