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

Implement JS Client tests #8109

Merged
merged 24 commits into from Apr 30, 2024
Merged

Implement JS Client tests #8109

merged 24 commits into from Apr 30, 2024

Conversation

hannahblair
Copy link
Collaborator

@hannahblair hannahblair commented Apr 23, 2024

Description

Adds tests for @gradio/client

  • client
  • duplicate
  • init_helpers.ts (resolve_root, get_jwt, map_names_to_ids, determine_protocol)
  • data.ts (walk_and_store_blobs, update_object, skip_queue, post_message)
  • api_info.ts (handle_message, get_description, get_type, process_endpoint)
  • view_api.ts
  • spaces.ts (set_space_timeout, get_space_hardware, check_space_status, discussions_enabled)
  • upload_files.ts
  • post_data.ts

Tests new and deprecated syntax:

  • await Client.connect()
  • deprecated await client()
  • Client.duplicate()
  • deprecated duplicate
  • Client class overrides

To test separately:

  • stream.ts
  • submit.ts
  • predict.ts

I'd like to write tests in a separate PR for these because 1) there are lots of tests to write for submit() 2) testing SSE events is a little complicated (but doable) 3) I'd also like to see if we can test with a local spun up demo as we do in the Python client in that PR

Implicitly tested and could do with unit tests:

  • resolve_config
  • handle_blob.ts

Closes: #4658

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Tests

  1. PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests: bash scripts/run_all_tests.sh

  2. You may need to run the linters: bash scripts/format_backend.sh and bash scripts/format_frontend.sh

@hannahblair hannahblair changed the title Add JS Client tests Implement JS Client tests Apr 23, 2024
@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Apr 23, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/f9395788452e6354aeed0ad4b06368989e705dde/gradio-4.28.3-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@f9395788452e6354aeed0ad4b06368989e705dde#subdirectory=client/python"

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Apr 23, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/app minor
@gradio/client minor
gradio minor
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Implement JS Client tests

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@hannahblair hannahblair marked this pull request as ready for review April 29, 2024 10:11
Copy link
Member

@pngwn pngwn left a comment

Choose a reason for hiding this comment

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

Looks great to me! Just left a small question.

Thanks so much for taking care of this @hannahblair! Writing this many tests at once is not much fun!

We can add some e2e tests in a follow up and maybe think about a node/ happy-dom matrix.

client/js/src/test/data.test.ts Show resolved Hide resolved
client/js/src/test/init.test.ts Show resolved Hide resolved
@hannahblair hannahblair merged commit bed2f82 into main Apr 30, 2024
9 checks passed
@hannahblair hannahblair deleted the js-client-tests branch April 30, 2024 16:50
@pngwn pngwn mentioned this pull request Apr 30, 2024
dawoodkhan82 pushed a commit that referenced this pull request May 6, 2024
* add msw setup and initialisation tests

* add changeset

* add walk_and_store_blobs improvements and add tests

* add changeset

* api_info tests

* add direct space URL link tests

* fix tests

* add view_api tests

* add post_message test

* tweak

* add spaces tests

* jwt and protocol tests

* add post_data tests

* test tweaks

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
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.

js client unit tests
3 participants