Added react native tests#1473
Conversation
Greptile SummaryThis PR adds a browser-based Playwright test harness for the React Native SDK, including a Rollup bundling pipeline that shims
Confidence Score: 3/5Not safe to merge — the realtime endpoint misconfiguration will cause CI test failures. One P1 finding: the hardcoded tests/languages/react-native/browser.js — the Important Files Changed
Reviews (6): Last reviewed commit: "fix: skip non-spec WebSocket third arg o..." | Re-trigger Greptile |
| }); | ||
| page.on('pageerror', err => { | ||
| console.log('PAGE ERROR: ' + err.message); |
There was a problem hiding this comment.
Page errors don't affect exit code
pageerror events are logged via console.log, which means they'll appear in captured output but won't cause the process to exit with a non-zero code. The current approach relies entirely on PHP's expected-output comparison to catch page-level JS errors. This is consistent with the web SDK test pattern, but worth noting that if an unhandled page error produces no console output (e.g., a thrown but uncaught promise in a non-async context), it could silently swallow failures.
|
@copilot Fix the failing react native test |
@rollup/plugin-typescript requires the TypeScript compiler's outDir to sit inside the directory of the Rollup output file. Without an explicit outDir the plugin inferred a path outside dist/ and refused to render the bundle, leaving the playwright runner with nothing to load. Also: drop the redundant serve-handler from the no-save install (it is already a dev dependency), and replace the hard 20s timeout with page.waitForFunction so a fast-failing test exits sooner. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The PING_RESPONSE assertion in ReactNativeTest hit a TypeError because the generated Client had no ping(); the test runner aborted before any SDK call landed, which cascaded into the whole expected-output diff. Mirrors the web template's existing helper (templates/web/src/client.ts.twig:864). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The React Native realtime template called the WebSocket constructor with three arguments (url, protocols, headers) — a React Native runtime extension that the React Native test bundle (which aliases react-native to react-native-web) cannot service via the browser's native WebSocket. Newer Chromium dispatched an immediate error event, the subscribe() promise rejected, and the test runner aborted before any of the foo/bar calls landed. When Platform.OS reports 'web' the SDK is running in a browser host, so the browser already attaches its own Origin header and no third argument is needed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| console.log(Query.between('name', 'Anna', 'Brad')); | ||
| console.log(Query.startsWith('name', 'Ann')); | ||
| console.log(Query.endsWith('name', 'nne')); | ||
| console.log(Query.select(['name', 'age'])); |
There was a problem hiding this comment.
Wrong realtime endpoint points to production instead of the mock server
setEndpointRealtime('wss://cloud.appwrite.io/v1') sends WebSocket traffic to the real Appwrite cloud, not the mock API container. Within the mockapi Docker network, cloud.appwrite.io does not resolve to mockapi, so the WS connection will either reach the real cloud (which won't emit WS:/v1/realtime:passed) or fail DNS resolution. Either way, responseRealtime and responseRealtimeWithQueries stay as 'Realtime failed!', causing the PHP assertions for REALTIME_RESPONSES[0] and REALTIME_RESPONSES[1] to fail.
The mock server is reachable as ws://mockapi/v1. A simple fix is to drop the explicit call (since setEndpoint auto-derives endpointRealtime from the HTTP endpoint), or set it explicitly to the mock address:
| console.log(Query.select(['name', 'age'])); | |
| client.setEndpointRealtime('ws://mockapi/v1'); |
What does this PR do?
(Provide a description of what this PR does.)
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)
Related PRs and Issues
(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)
Have you read the Contributing Guidelines on issues?
(Write your answer here.)