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

Add Snapshot for each page on website #2313

Merged
merged 28 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9ae27b0
Add snapshot for Privacy page
aaronmgdr Dec 17, 2019
e1f8e93
Image stubs
aaronmgdr Dec 17, 2019
5341d6f
FAQ snap
aaronmgdr Dec 17, 2019
28db2ad
Add missing react
aaronmgdr Dec 17, 2019
7d88a9a
Add more tests
aaronmgdr Dec 18, 2019
ca24b96
WIP
aaronmgdr Dec 18, 2019
583e3d6
Merge branch 'master' into aaronmgdr/page-snaps
aaronmgdr Dec 18, 2019
42c78c9
Boom
aaronmgdr Dec 18, 2019
d10735d
Dont print prop type warning in test.
aaronmgdr Dec 18, 2019
08ac411
Merge branch 'master' into aaronmgdr/page-snaps
aaronmgdr Dec 18, 2019
7237f8c
Right on
aaronmgdr Dec 18, 2019
fc0e0ed
Add more snaps
aaronmgdr Dec 18, 2019
4b73b72
Add canvas mock for canvas uses
aaronmgdr Dec 18, 2019
d3d62f1
Add snapshots for brand kit
aaronmgdr Dec 18, 2019
a53a2e1
Clean up
aaronmgdr Dec 18, 2019
d7b4f21
Cleaning up and mocking
aaronmgdr Dec 18, 2019
9812b20
Toda
aaronmgdr Dec 19, 2019
ad07926
Merge branch 'master' into aaronmgdr/page-snaps
aaronmgdr Jan 2, 2020
6bd0cf4
Merge branch 'master' into aaronmgdr/page-snaps
aaronmgdr Jan 3, 2020
cc52bff
With ignore loader
aaronmgdr Jan 4, 2020
fb249af
Move page snaps out of pages directory
aaronmgdr Jan 6, 2020
b730431
Merge branch 'master' into aaronmgdr/page-snaps
aaronmgdr Jan 6, 2020
1439de9
Update snaps
aaronmgdr Jan 6, 2020
cf347df
Pages test all working
aaronmgdr Jan 6, 2020
13d2c04
Merge branch 'master' into aaronmgdr/page-snaps
aaronmgdr Jan 6, 2020
794774e
the trouble with yarn is...
aaronmgdr Jan 7, 2020
70ca9d4
Lint
aaronmgdr Jan 7, 2020
36e7c7f
Merge branch 'master' into aaronmgdr/page-snaps
aaronmgdr Jan 7, 2020
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
3 changes: 2 additions & 1 deletion packages/web/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"root": ["./"],
"alias": {
"src": "./src",
"server": "./server"
"server": "./server",
"pages": "./pages"
}
}
],
Expand Down
1 change: 1 addition & 0 deletions packages/web/__mocks__/ImageStub.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'image.png'
5 changes: 5 additions & 0 deletions packages/web/__mocks__/cross-fetch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default function FetchMock() {
return Promise.resolve({
json: () => [],
})
}
9 changes: 9 additions & 0 deletions packages/web/__mocks__/lottie-web.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
loadAnimation: function loadAnimation() {
return {
destroy: function destroy() {
return null
},
}
},
}
6 changes: 6 additions & 0 deletions packages/web/__mocks__/next/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default function getConfig() {
return {
publicRuntimeConfig: { FLAGS: {} },
serverRunTimeConfig: {},
}
}
8 changes: 8 additions & 0 deletions packages/web/__mocks__/next/router.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as React from 'react'
export const SingletonRouter = {}

export function withRouter(Component) {
return function Wrapped(props) {
return <Component router={{ pathName: '/test/' }} {...props} />
}
}
3 changes: 3 additions & 0 deletions packages/web/__mocks__/nuka-carousel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function MockCarousel({ children }) {
return children
}
7 changes: 7 additions & 0 deletions packages/web/__mocks__/react-lazyload-fadein.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function MockLazy({ children }) {
return children(funct)
}

function funct() {
return null
}
23 changes: 23 additions & 0 deletions packages/web/__mocks__/react-modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react'

interface Props {
id: string
isOpen: boolean
contentLabel: string
overlayClassName: string
className: any
parentSelector: any
shouldCloseOnOverlayClick(): void
onRequestClose(): void
onAfterOpen(): void
}

export default class MockReactModal extends React.Component<Props, any> {
static setAppElement() {
return null
}

render() {
return <div id={this.props.id}>{this.props.isOpen && this.props.children}</div>
}
}
5 changes: 4 additions & 1 deletion packages/web/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ module.exports = {
tsConfig: 'tsconfig.jest.json',
},
},
setupFiles: ['./jestSetup.js', 'jest-canvas-mock'],
moduleNameMapper: {
'\\.(png|jpg|jpeg)$': '<rootDir>/__mocks__/ImageStub.ts',
'pages/(.*)$': '<rootDir>/pages/$1',
'src/(.*)$': '<rootDir>/src/$1',
},
preset: 'react-native-web',
testEnvironment: 'node',
testEnvironment: 'jsdom',
}
17 changes: 17 additions & 0 deletions packages/web/jestSetup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const originalConsoleError = console.error

// proptype warnings make tests impossible to understand
console.error = (message) => {
if (/(Failed prop type)/.test(message)) {
return
}

originalConsoleError(message)
}

// ensure random is predictable
Math.random = function random() {
return 0.5
}

require('jest-fetch-mock').enableMocks()
6 changes: 5 additions & 1 deletion packages/web/next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const withSass = require('@zeit/next-sass')
const withImages = require('next-images')
const webpack = require('webpack')
const envConfig = require('./env-config')
const serverEnvConfig = require('./server-env-config')

Expand All @@ -26,6 +25,11 @@ module.exports = withImages(
config.resolve.alias['@sentry/node'] = '@sentry/browser'
}

config.module.rules.push({
loader: 'ignore-loader',
test: /\.test.ts$/,
})

return config
},
})
Expand Down
3 changes: 3 additions & 0 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@
"babel-plugin-react-native-web": "^0.11.7",
"cross-env": "^5.1.6",
"node-sass": "^4.13.0",
"jest-canvas-mock": "^2.2.0",
"jest-fetch-mock": "^3.0.0",
"nodemon": "^2.0.2",
"postcss-scss": "^2.0.0",
"react-native-svg": "^9.13.6",
"ignore-loader": "~0.1.2",
"webpack": "4.41.2"
}
}
Loading