Repository navigation
Docs snippets tests - #538
techwritermat wants to merge 8 commits into
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
- Added a new test to verify occupant visibility through channel groups in presence.ts, addressing potential timing issues in CI. - Refactored exitWhenIdle function in cli.ts to provide clearer error messages when the event loop remains busy, and introduced a new describeHandles function to detail active handles and resources.
…tions - Updated the exitWhenIdle function in cli.ts to provide clearer warnings when only timers are keeping the event loop busy. - Added unref() calls in wait.ts to ensure abandoned timers do not prevent process exit after tests complete.
The presence fixture now waits until each channel group (cg1, my_channel_group) and the ch1 plus cg1 combination list the occupant. A group read resolves the group's member channels first and can lag the per-channel reads, which made hereNowBasicUsage fail in CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Five steps read back what the docs sample just wrote, from another client, in one shot. App Context reads lag behind writes, and on the fast CI runner setMembershipBasicUsage read an empty list. The same assertions now run inside eventually(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Introduced a new script `snippet-summary.cjs` to generate a Markdown summary of snippet results per ID for GitHub Actions. - Updated `package.json` to include a new command for running the summary script. - Modified GitHub Actions workflows to utilize the new summary script and adjusted checkout actions for consistency. - Enhanced error handling in `mocha-entry.ts` to ensure all keysets are processed, even if some fail. This improves visibility into snippet test results and ensures comprehensive reporting in CI runs.
- Revised multiple snippets and README entries to specify that React and React Native sources cannot be run in this repository due to the absence of necessary dependencies. - Adjusted comments and documentation to reflect that the snippets are retained for documentation purposes only and are type-checked but not executed. - Enhanced clarity in various files regarding the environment setup and execution context for the snippets. This improves the accuracy of documentation and helps users understand the limitations of running certain snippets.
| live: ${{ steps.diff.outputs.live }} | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 |
There was a problem hiding this comment.
this is brutal. We actually can at least trust official GitHub account to deliver stable products.
Current checkout is v7
| # of its own role only. The janitor step after them needs every role, so it keeps all of them. | ||
| - name: Shard open | ||
| id: open | ||
| if: success() || failure() |
There was a problem hiding this comment.
so, we will still run this step event previous setup steps failed? Does it really make sense?
| function SubscribedComponent() { | ||
| useEffect(() => { | ||
| const channel = pubnub.channel('my_channel'); | ||
| const subscription = channel.subscription({ | ||
| receivePresenceEvents: true, | ||
| }); | ||
| subscription.subscribe(); | ||
|
|
||
| return () => { | ||
| subscription.unsubscribe(); | ||
| }; | ||
| }, []); | ||
|
|
||
| return <div>Subscribed to my_channel</div>; | ||
| } |
There was a problem hiding this comment.
Subscription is asynchronous process and it won't be really truthful to report Subscribed to my_channel right away.
| function SubscribedComponent() { | |
| useEffect(() => { | |
| const channel = pubnub.channel('my_channel'); | |
| const subscription = channel.subscription({ | |
| receivePresenceEvents: true, | |
| }); | |
| subscription.subscribe(); | |
| return () => { | |
| subscription.unsubscribe(); | |
| }; | |
| }, []); | |
| return <div>Subscribed to my_channel</div>; | |
| } | |
| function SubscribedComponent() { | |
| const [isSubscribed, setIsSubscribed] = useState(false); | |
| useEffect(() => { | |
| const channel = pubnub.channel('my_channel'); | |
| const subscription = channel.subscription({ | |
| receivePresenceEvents: true, | |
| }); | |
| subscription.onStatus = (statusEvent) => { | |
| if (statusEvent.category === 'PNConnectedCategory') { | |
| setIsSubscribed(true); | |
| } | |
| }; | |
| subscription.subscribe(); | |
| return () => { | |
| subscription.unsubscribe(); | |
| }; | |
| }, []); | |
| if (!isSubscribed) { | |
| return <div>Connecting to channel...</div>; | |
| } | |
| return <div>Subscribed to my_channel</div>; | |
| } |
| setPresenceState(); | ||
| }, []); | ||
|
|
||
| return <div>User with presence state</div>; |
There was a problem hiding this comment.
Should it show progress as it has been shown with react-subscribe.jsx?
| const channel = pubnub.channel('hello_world'); | ||
| const subscription = channel.subscription(); |
There was a problem hiding this comment.
Should we show it in the following way:
| const channel = pubnub.channel('hello_world'); | |
| const subscription = channel.subscription(); | |
| const subscription = pubnub.channel('hello_world').subscription(); |
| <head> | ||
| <meta charset="utf-8" /> | ||
| <title>PubNub quickstart</title> | ||
| <script src="https://cdn.pubnub.com/sdk/javascript/pubnub.13.1.3.js"></script> |
There was a problem hiding this comment.
This could become invalid really soon.
Version bumping available through the release process but it requires modification in this file.
| // snippet.hide | ||
| // @ts-expect-error the shipped types lack subscriptionWorkerUrl (SDK bug, STATUS.md) | ||
| // snippet.show | ||
| subscriptionWorkerUrl: 'https://www.my-domain.com/static/js/pubnub.worker.9.6.0.js', |
There was a problem hiding this comment.
There is no need in separate .d.ts especially when it can't be used directly inside of HTML page.
Not minified version from the CDN has a JSDoc for functions and they list field.
WebStorm IDE were able to assist me:
Currently we have whole codebase written with TypeScript, so other environments see types without any issues.
So I don't know why SDK bug. It was intentional decision.
| // have proper html element to display the file | ||
| const myImageTag = document.createElement('img'); | ||
| // snippet.hide | ||
| // @ts-expect-error the shipped types declare toFile(): Promise<void>, the browser returns a File (SDK bug, STATUS.md) |

No description provided.