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

test: fix e2e tests #2578

Merged
merged 4 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading