Skip to content

Commit

Permalink
test: fix e2e tests (#2578)
Browse files Browse the repository at this point in the history
# Summary

Fix broken E2E iOS tests

## Test Plan

CI should be green
  • Loading branch information
jakex7 authored Dec 16, 2024
1 parent d497830 commit a9e702c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
working-directory: [paper-example]
fail-fast: false
env:
DEVICE: iPhone 16 Pro
DEVICE: iPhone 15 Pro
steps:
- name: Checkout Git repository
uses: actions/checkout@v4
Expand Down
12 changes: 9 additions & 3 deletions apps/common/example/e2e/TestingView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const TestingView = () => {
const [renderedContent, setRenderedContent] =
useState<React.ReactElement | null>();
const [readyToSnapshot, setReadyToSnapshot] = useState(false);
const [resolution, setResolution] = useState([0, 0]); // placeholder value, later updated by incoming render requests
const [resolution, setResolution] = useState({width: 0, height: 0}); // placeholder value, later updated by incoming render requests
const [message, setMessage] = useState('⏳ Connecting to Jest server...');

const connect = useCallback(() => {
Expand Down Expand Up @@ -48,7 +48,8 @@ export const TestingView = () => {
const message = JSON.parse(rawMessage);
if (message.type == 'renderRequest') {
setMessage(`✅ Rendering tests, please don't close this tab.`);
setResolution([message.width, message.height]);
const {width, height} = message;
setResolution({width, height});
setRenderedContent(
createElementFromObject(
message.data.type || 'SvgFromXml',
Expand All @@ -67,6 +68,11 @@ export const TestingView = () => {
`✅ Connection to Jest server has been closed. You can close this tab safely. (${event.code})`,
);
};

return () => {
setWsClient(null);
client.close();
};
}, [wsClient]);

// Create initial connection when rendering the view
Expand All @@ -93,7 +99,7 @@ export const TestingView = () => {
<Text style={{marginLeft: 'auto', marginRight: 'auto'}}>{message}</Text>
<ViewShot
ref={wrapperRef}
style={{width: resolution[0], height: resolution[1]}}
style={{...resolution}}
options={{result: 'base64'}}>
{renderedContent}
</ViewShot>
Expand Down
3 changes: 1 addition & 2 deletions apps/common/example/e2e/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {icon} from './icon';
import {TestingView} from './TestingView';
import {TestingView as component} from './TestingView';

const component = TestingView;
export {component, icon};
2 changes: 1 addition & 1 deletion apps/common/example/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import React from 'react';
import {ActivityIndicator, Platform, View} from 'react-native';
import {GestureHandlerRootView} from 'react-native-gesture-handler';
import {ListScreen} from './ListScreen';
import * as E2e from './e2e/index.macos';
import * as E2e from './e2e/index';
import {examples} from './examples';
import * as FilterImage from './examples/FilterImage';
import * as Filters from './examples/Filters';
Expand Down

0 comments on commit a9e702c

Please sign in to comment.