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

Write unit tests for the SDK and integrate with Github actions #138

Open
yathindrak opened this issue Sep 19, 2022 · 7 comments · May be fixed by #263
Open

Write unit tests for the SDK and integrate with Github actions #138

yathindrak opened this issue Sep 19, 2022 · 7 comments · May be fixed by #263

Comments

@yathindrak
Copy link
Contributor

Is your suggestion related to an experience ? Please describe.

The SDK can simply become nonfunctional due to a single commit. Currently there is no automated way of verifying a pr. So it would be great to have unit tests and add a test execution job under github actions PR builder.

Describe the improvement

Additional context

@yathindrak yathindrak changed the title Add unit tests Write unit tests for the SDK and integrate with Github actions Sep 19, 2022
@pavinduLakshan pavinduLakshan self-assigned this Jul 9, 2023
@pavinduLakshan pavinduLakshan removed their assignment Aug 2, 2023
@pranshustuff
Copy link

Hi I'd like to work on this issue

@pavinduLakshan
Copy link
Contributor

hi @pranshustuff , I assigned this issue to you. before writing unit tests, we need to prepare a list of test cases. Then we need to decide the technologies we are going to use for test.

Let's begin with preparing the list of test cases. Get back if you need any help. Cheers!

@pranshustuff
Copy link

I'd like to take some time to understand the code base, as I'm a beginner, it would be very helpful if you give me pointers on how to go about it.

@pavinduLakshan
Copy link
Contributor

The first step is to explore the SDK on your own and get familiar with its functionalities. Try integrating the React SDK with a single-page React app and utilize its features to better understand its capabilities. The API documentation provides all the methods you'll need to write unit tests.

When preparing test cases, a deep understanding of the codebase is not necessary; a good grasp of the functionalities will suffice.

I'll publish a guide on the SDK architecture this weekend. In the meantime, I hope you can proceed with the information above :)

@pranshustuff
Copy link

pranshustuff commented Oct 20, 2024

Ok from just the docs I've come up with a few test cases that I feel are most important:

  1. SignIn():
    • correct credentials
    • wrong credentials
    • timeout/slow response
  2. Signout():
    • User signs out
  3. isAuthenticated():
    • if signed in, returns true
    • not signed in, returns false
  4. getBasicUserInfo():
    • email, name, username recived correctly
    • error message, otherwise
  5. refreshAccessToken():
    • new recieved before old expires
    • if not, error message
  6. secure App:
    • if signed in:
      • Authenticated component loads properly
      • show spinner while loading
    • if not signed in:
      • return to fallback (in this case, the login page)
  7. useAuthContext:
    • isAuthenticated is true then state is logged in
    • iAuth is false then state is logged out
    • tests for state loading and error.

For 1-5 I think Jest will suffice, for 6 and 7 we can use React Testing Library or Cypress.

Let me know what you think, I'll get started on a few of them :)

@pranshustuff
Copy link

Hi, so I've written a test for Sign in and I was trying to integrate it with github actions, my Jest test works perfectly, but the builder.yml is having trouble with a certain part of code outside my tests.

Screenshot (48)

so I'm not sure what to do here, I'll keep making the tests and adding them to github actions, I'll wait for you to respond here.

@pranshustuff
Copy link

The github integration part is not working my fork. Even the send notification test that works on your main branch is giving problems on my fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants