-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into master-merge-up
- Loading branch information
Showing
20 changed files
with
305 additions
and
32 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
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
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 +1,4 @@ | ||
{} | ||
{ | ||
"testFiles": "**/*spec.{ts,tsx}", | ||
"video": false | ||
} |
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,67 @@ | ||
import * as React from 'react' | ||
import { mount } from '@cypress/react' | ||
|
||
const styles = ` | ||
body { | ||
margin: 0; | ||
} | ||
#wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
height: 100vh; | ||
} | ||
#body { | ||
flex-grow: 1; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
#header, #footer { | ||
height: 50px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
background: silver; | ||
} | ||
` | ||
|
||
const Layout: React.FC = () => { | ||
return ( | ||
<div id='wrapper'> | ||
<div id='header'>Header</div> | ||
<div id='body'>Body</div> | ||
<div id='footer'>Footer</div> | ||
</div> | ||
) | ||
} | ||
|
||
describe('screenshot', () => { | ||
it('takes a standard screenshot', () => { | ||
cy.viewport(500, 500) | ||
mount(<Layout />, { | ||
styles, | ||
}) | ||
|
||
cy.screenshot('percy/component_testing_takes_a_screenshot') | ||
}) | ||
|
||
it('takes a screenshot with a custom viewport', () => { | ||
cy.viewport(750, 750) | ||
mount(<Layout />, { | ||
styles, | ||
}) | ||
|
||
cy.screenshot('percy/component_testing_screenshot_custom_viewport_screenshot') | ||
}) | ||
|
||
// TODO: This will technically pass, but the screenshot is not correct. | ||
// AUT transform appears to be buggy for extreme viewports. | ||
xit('screenshot with a really long viewport', () => { | ||
cy.viewport(200, 2000) | ||
mount(<Layout />, { | ||
styles, | ||
}) | ||
|
||
cy.screenshot('percy/component_testing_screenshot_long_viewport') | ||
}) | ||
}) |
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
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,60 @@ | ||
import * as React from 'react' | ||
import { runInAction } from 'mobx' | ||
import EventManager from '../lib/event-manager' | ||
import State from '../lib/state' | ||
|
||
/** | ||
* SplitPane hierarchy looks like this: | ||
* ```jsx | ||
* <div class="SplitPane"> | ||
* <div class="Pane vertical Pane1 ">..</div> | ||
* <span role="presentation" class="Resizer vertical ">...</span> | ||
* </div> | ||
*``` | ||
* we need to set these to display: none during cy.screenshot. | ||
*/ | ||
export function useScreenshotHandler ({ eventManager, state, splitPaneRef } : { | ||
eventManager: typeof EventManager, state: State, splitPaneRef: React.MutableRefObject<{ splitPane: HTMLDivElement }> | ||
}) { | ||
const showPane = () => { | ||
if (!splitPaneRef.current) { | ||
return | ||
} | ||
|
||
splitPaneRef.current.splitPane.firstElementChild.classList.remove('d-none') | ||
splitPaneRef.current.splitPane.querySelector('[role="presentation"]').classList.remove('d-none') | ||
} | ||
|
||
const hidePane = () => { | ||
if (!splitPaneRef.current) { | ||
return | ||
} | ||
|
||
splitPaneRef.current.splitPane.firstElementChild.classList.add('d-none') | ||
splitPaneRef.current.splitPane.querySelector('[role="presentation"]').classList.add('d-none') | ||
} | ||
|
||
React.useEffect(() => { | ||
eventManager.on('before:screenshot', (config) => { | ||
runInAction(() => { | ||
state.setScreenshotting(true) | ||
hidePane() | ||
}) | ||
}) | ||
|
||
const revertFromScreenshotting = () => { | ||
runInAction(() => { | ||
state.setScreenshotting(false) | ||
showPane() | ||
}) | ||
} | ||
|
||
eventManager.on('after:screenshot', (config) => { | ||
revertFromScreenshotting() | ||
}) | ||
|
||
eventManager.on('run:start', () => { | ||
revertFromScreenshotting() | ||
}) | ||
}, []) | ||
} |
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.