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

fix: (e2e) API surveys after icons changed #2225

Merged
merged 1 commit into from
Mar 13, 2024

Conversation

ShubhamPalriwala
Copy link
Member

What does this PR do?

Fix End-to-End tests that were failing in copying the API keys after the Copy icon changed.

How should this be tested?

  • Test A
  • Test B

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read How we Code at Formbricks
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand bits
  • Ran pnpm build
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Formbricks Docs if changes were necessary

Copy link

vercel bot commented Mar 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Updated (UTC)
formbricks-cloud ⬜️ Ignored (Inspect) Mar 13, 2024 6:54am
formbricks-com ⬜️ Ignored (Inspect) Mar 13, 2024 6:54am

Copy link
Contributor

Thank you for following the naming conventions for pull request titles! 🙏

Copy link
Contributor

apps/web/playwright/api/management/survey.spec.ts

There are multiple instances where the same headers are being used for API requests. It would be more efficient and maintainable to define these headers once and reuse them in all the requests. This way, if there's a need to change the headers in the future, you only need to do it in one place.
Create Issue
See the diff
Checkout the fix

    const API_HEADERS = {
      "Content-Type": "application/json",
      "x-api-key": apiKey,
    };

    // Then use it in the requests like this:
    const response = await request.post(`/api/v1/management/surveys`, {
      headers: API_HEADERS,
      data: {
        environmentId: environmentId,
        type: "link",
        name: "My new Survey from API",
      },
    });
git fetch origin && git checkout -b ReviewBot/Impro-c0pej6u origin/ReviewBot/Impro-c0pej6u

There are multiple instances where the same API endpoint is being used. It would be more efficient and maintainable to define this endpoint once and reuse it in all the requests. This way, if there's a need to change the endpoint in the future, you only need to do it in one place.
Create Issue
See the diff
Checkout the fix

    const SURVEY_API_ENDPOINT = `/api/v1/management/surveys`;

    // Then use it in the requests like this:
    const response = await request.post(SURVEY_API_ENDPOINT, {
      headers: {
        "Content-Type": "application/json",
        "x-api-key": apiKey,
      },
      data: {
        environmentId: environmentId,
        type: "link",
        name: "My new Survey from API",
      },
    });
git fetch origin && git checkout -b ReviewBot/Impro-ioifkn8 origin/ReviewBot/Impro-ioifkn8

Copy link
Member

@mattinannt mattinannt left a comment

Choose a reason for hiding this comment

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

@ShubhamPalriwala thanks for the fix :-)

@mattinannt mattinannt added this pull request to the merge queue Mar 13, 2024
Merged via the queue into main with commit 0aa468f Mar 13, 2024
16 checks passed
@mattinannt mattinannt deleted the shubham/fix-e2e-api-test-icon-changed branch March 13, 2024 09:07
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.

None yet

2 participants