Skip to content

fix: Bump up realtime; add integration tests #1395

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

Merged
merged 2 commits into from
May 9, 2025
Merged

Conversation

filipecabaco
Copy link
Member

What kind of change does this PR introduce?

Bump up realtime; add integration tests

@filipecabaco filipecabaco force-pushed the fix/bump-realtime-js branch from 657faf3 to a4dc846 Compare April 22, 2025 13:48
@vilnius1998
Copy link

Hey, do we have an estimated time when this will be merged? Thanks!

@filipecabaco
Copy link
Member Author

We're doing some integration testing to ensure we don't break things but hopefully this should get merged in the next couple of weeks

@BrandontMitchell
Copy link

following 👀 looking forward to using!

@filipecabaco filipecabaco changed the base branch from master to next May 8, 2025 15:00
@filipecabaco filipecabaco force-pushed the fix/bump-realtime-js branch 6 times, most recently from 52f2599 to 9fe5d21 Compare May 8, 2025 15:57
@filipecabaco filipecabaco force-pushed the fix/bump-realtime-js branch from 9fe5d21 to 16aaa21 Compare May 8, 2025 16:00
@filipecabaco filipecabaco requested a review from Copilot May 8, 2025 16:06
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR bumps the realtime dependency version and adds comprehensive integration tests for Supabase functionality. Key changes include:

  • Implementation of integration tests covering PostgREST, authentication, and realtime channels.
  • Migration scripts for setting up todos tables and realtime RLS policies.
  • Updates to helper methods (renaming stripTrailingSlash to cleanUrl) and test commands in package.json and README.
  • CI workflow now includes Supabase CLI setup.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/integration.test.ts Added integration tests for multiple Supabase functionalities
test/helper.test.ts Updated tests to use the new cleanUrl function
supabase/seed/seed_todos.sql Added seed data for the todos table
supabase/migrations/20250423000000_realtime_rls_setup.sql Added migration for realtime RLS policies
supabase/migrations/20250422000000_create_todos_table.sql Added migration to create todos table
supabase/.temp/cli-latest Updated Supabase CLI version in temporary file
supabase/.branches/_current_branch Confirmed branch configuration
src/lib/helpers.ts Renamed stripTrailingSlash to cleanUrl and updated its functionality
src/SupabaseClient.ts Updated to use cleanUrl instead of stripTrailingSlash
package.json Modified test commands and bumped realtime-js version
README.md Added documentation for running integration tests
.github/workflows/ci.yml Added step to set up Supabase CLI in CI

@filipecabaco filipecabaco force-pushed the fix/bump-realtime-js branch from f1dc0a7 to e73383f Compare May 8, 2025 16:13
@filipecabaco filipecabaco requested a review from Copilot May 8, 2025 16:18
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR bumps the realtime library version and adds integration tests while refactoring URL cleaning logic. The key changes include:

  • Adding comprehensive integration tests for Supabase functionalities.
  • Replacing the stripTrailingSlash function with a more robust cleanUrl implementation.
  • Updating package.json and CI workflow to support integration tests and the new realtime version.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/integration.test.ts Adds integration tests for PostgREST, authentication, and realtime functionality.
test/helper.test.ts Updates tests to validate the new cleanUrl behavior for trimming URLs.
supabase/seed/seed_todos.sql Adds seed data for the todos table.
supabase/migrations/*.sql Introduces new migration scripts for realtime RLS setup and todos table creation.
supabase/.temp/cli-latest Updates the Supabase CLI version.
supabase/.branches/_current_branch Confirms the current branch.
src/lib/helpers.ts Refactors the URL cleaning function from stripTrailingSlash to cleanUrl.
src/SupabaseClient.ts Updates usage of the URL cleaning function.
package.json Updates realtime-js version and adjusts test scripts for integration testing.
README.md Adds documentation for running unit and integration tests.
.github/workflows/ci.yml Adds steps to set up the Supabase CLI in the CI workflow.

@@ -9,8 +9,8 @@ export function uuid() {
})
}

Copy link
Preview

Copilot AI May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated cleanUrl function now removes both trailing slashes and whitespace. Consider adding a docstring to clarify its enhanced behavior compared to the old stripTrailingSlash implementation.

Suggested change
/**
* Cleans a URL by removing trailing slashes and whitespace.
*
* This function enhances the behavior of the old `stripTrailingSlash` implementation
* by also removing any trailing whitespace in addition to slashes.
*
* @param url - The URL string to clean.
* @returns The cleaned URL string without trailing slashes or whitespace.
*/

Copilot uses AI. Check for mistakes.


// Wait for subscription
while (!subscribed) {
if (attempts > 50) throw new Error('Timeout waiting for subscription')
Copy link
Preview

Copilot AI May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The loop uses a magic number (50) for the subscription timeout. Extract this value into a named constant to improve readability and maintainability.

Suggested change
if (attempts > 50) throw new Error('Timeout waiting for subscription')
if (attempts > SUBSCRIPTION_TIMEOUT_ATTEMPTS) throw new Error('Timeout waiting for subscription')

Copilot uses AI. Check for mistakes.


// Wait on message
while (!receivedMessage) {
if (attempts > 50) throw new Error('Timeout waiting for message')
Copy link
Preview

Copilot AI May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The message waiting loop also uses the magic number (50) for timeout. Consider refactoring to use a named constant for this timeout threshold for clarity.

Suggested change
if (attempts > 50) throw new Error('Timeout waiting for message')
if (attempts > TIMEOUT_THRESHOLD) throw new Error('Timeout waiting for message')

Copilot uses AI. Check for mistakes.

@filipecabaco filipecabaco merged commit 8c12584 into next May 9, 2025
2 checks passed
@filipecabaco filipecabaco deleted the fix/bump-realtime-js branch May 9, 2025 10:51
grdsdev added a commit that referenced this pull request May 20, 2025
* fix: Bump up realtime; add integration tests (#1395)

* fix: bump up realtime-js (#1409)

* fix: bump up realtime-js; await on token change (#1411)

* fix: prevent async calls in _listenForAuthEvents (#1412)

* fix: bump up realtime-js (#1413)

* bump up realtime-js (#1419)

* resolve conflict

---------

Co-authored-by: Guilherme Souza <[email protected]>
Co-authored-by: Guilherme Souza <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants