-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1430 from guardian/jsh/correct-preview-for-CODE
Correct preview for code
- Loading branch information
Showing
8 changed files
with
1,644 additions
and
1,690 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
99 changes: 99 additions & 0 deletions
99
fronts-client/src/components/FrontsEdit/__tests__/FrontSection.spec.tsx
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 |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { theme } from 'constants/theme'; | ||
import { frontsConfig } from 'fixtures/frontsConfig'; | ||
import state from 'fixtures/initialStateForOpenFronts'; | ||
import React from 'react'; | ||
import 'jest-dom/extend-expect'; | ||
import { Provider } from 'react-redux'; | ||
import { getByText, render } from 'react-testing-library'; | ||
import { ThemeProvider } from 'styled-components'; | ||
import configureStore from 'util/configureStore'; | ||
import FrontSection from '../FrontSection'; | ||
|
||
describe('FrontSection component', () => { | ||
const defaultProps = { | ||
frontId: 'editorialFront', | ||
selectedFront: frontsConfig.data.fronts.editorialFront, | ||
isOverviewOpen: false, | ||
frontsActions: { | ||
fetchLastPressed: jest.fn(), | ||
editorCloseFront: jest.fn(), | ||
updateCollection: jest.fn(), | ||
changeBrowsingStage: jest.fn(), | ||
updateFrontMetadata: jest.fn(), | ||
setFrontHiddenState: jest.fn(), | ||
}, | ||
isEditions: false, | ||
}; | ||
|
||
it('should give the correct preview link for DEV', () => { | ||
const store = configureStore({ | ||
...state, | ||
config: { | ||
...state.config, | ||
dev: true, | ||
env: 'code', | ||
}, | ||
}); | ||
|
||
const { container } = render( | ||
<Provider store={store}> | ||
<ThemeProvider theme={theme}> | ||
<FrontSection {...defaultProps} /> | ||
</ThemeProvider> | ||
</Provider> | ||
); | ||
|
||
expect(getByText(container, 'Preview').closest('a')).toHaveAttribute( | ||
'href', | ||
'https://m.code.dev-theguardian.com/editorialFront' | ||
); | ||
}); | ||
|
||
it('should give the correct preview link for CODE', () => { | ||
const store = configureStore({ | ||
...state, | ||
config: { | ||
...state.config, | ||
dev: false, | ||
env: 'code', | ||
}, | ||
}); | ||
|
||
const { container } = render( | ||
<Provider store={store}> | ||
<ThemeProvider theme={theme}> | ||
<FrontSection {...defaultProps} /> | ||
</ThemeProvider> | ||
</Provider> | ||
); | ||
|
||
expect(getByText(container, 'Preview').closest('a')).toHaveAttribute( | ||
'href', | ||
'https://m.code.dev-theguardian.com/editorialFront' | ||
); | ||
}); | ||
|
||
it('should give the correct preview link for PROD', () => { | ||
const store = configureStore({ | ||
...state, | ||
config: { | ||
...state.config, | ||
dev: false, | ||
env: 'prod', | ||
}, | ||
}); | ||
|
||
const { container } = render( | ||
<Provider store={store}> | ||
<ThemeProvider theme={theme}> | ||
<FrontSection {...defaultProps} /> | ||
</ThemeProvider> | ||
</Provider> | ||
); | ||
|
||
expect(getByText(container, 'Preview').closest('a')).toHaveAttribute( | ||
'href', | ||
'https://preview.gutools.co.uk/responsive-viewer/https://preview.gutools.co.uk/editorialFront' | ||
); | ||
}); | ||
}); |
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,3 +1,4 @@ | ||
import { Config } from 'types/Config'; | ||
import type { State } from 'types/State'; | ||
|
||
const fronts = { | ||
|
@@ -205,9 +206,8 @@ const fronts = { | |
lastPressed: {}, | ||
collectionVisibility: { draft: {}, live: {} }, | ||
}; | ||
const config = { | ||
const config: Config = { | ||
dev: true, | ||
stage: 'CODE', | ||
env: 'code', | ||
editions: ['uk', 'us', 'au'], | ||
email: '[email protected]', | ||
|
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
Oops, something went wrong.