-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add end to end test suite to test NextJS app in Edge runtime w/TS client #304
base: main
Are you sure you want to change the base?
Conversation
@@ -27,27 +31,68 @@ runs: | |||
uses: GuillaumeFalourd/clone-github-repo-action@main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note for the previous step: npm pack
packages up the existing code on the existing branch, so it'll run the code devs are proposing to merge in their PR, rather than whatever code is on npm
etc. This removes the need for us to merge things before testing them end to end.
exit 1 | ||
fi | ||
|
||
if [ "$match_count" -lt 1 ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where we assert on the response in CI
|
||
response=$(curl --silent --location --request POST "$API_URL" --header "PINECONE_API_KEY: $API_KEY") | ||
|
||
indexName=$(echo "$response" | jq -r '.indexName') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Index names are randomized in the app. We then save the index name to the GITHUB_ENV environment variable file, so that we can delete them later -- this ensures we can have simultaneous runs of this workflow, from creating the index to deleting it later
# Hop into ts-client-e2e-tests repo, install deps, link local ts-client repo, and start the Next.js server | ||
pushd "$dir/ts-client-e2e-tests" | ||
npm install | ||
npm link @pinecone-database/pinecone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will overwrite the portion in the app's package.json
that says "@pinecone-database/pinecone": "^3.0.4-rc.2024-10.0"
. Instead, it'll link to your local version.
You must run it after npm install
, or else npm install
will change package.json
back to "^3.0.4-rc.2024-10.0"
, since that's the latest version up on npm
as of this writing.
next dev | ||
popd | ||
|
||
#npm uninstall -g next # Can comment out if do not want to uninstall the global Next.js package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do have to install NextJS globally or else the next dev
command (to spin up the app on your localhost:3000
won't work when run from the ts-client
repo, which is where this bash file is being executed. If you don't want Next globally, you can uncomment line 54 and uninstall it.
Problem
We do not currently have a good way to test how our client behaves end to end in different environments. One of the chief problems our users have brought to our attention in the past is that some functionalities do not work in certain runtimes, e.g. Edge or Bun, and/or with certain frameworks, e.g. NextJS.
Solution
Build an external application in a runtime and framework known to have caused problems in the past and test our client from the end-user's perspective.
This PR introduces and end-to-end test suite that interacts with an external application written using the NextJS framework and the Edge runtime.
Note: the app is automagically run in
Edge
by way of it using middleware (middleware.ts
), and theHeaders()
API.Overview of changes
localhost:3000
. Once the app is up and running, they can hit the endpoint with cURL, Postman, etc.testing.yml
file that is run for each push to an open PR. In CI, the Github workflow and action hit the application's endpoint and assert on its response. In this environment, the Github action is hitting a version of the app that is hosted on Pinecone's Enterprise Vercel account. Note: if this app's Vercel deployment gets rolled back for any reason, the CI tests will fail.end-to-end
dir itself with more in depth information.Type of Change
Test Plan
If reviewers can pull down the code in this branch and try to run the end-to-end tests locally, that'd be great.
To Dos
I'll add a README and a CONTRIBUTING file to the external app