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

E2E testing should be able to query the DB to work on actual data and not hard coded mocks. #6638

Open
lucasbordeau opened this issue Aug 16, 2024 · 8 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@lucasbordeau
Copy link
Contributor

lucasbordeau commented Aug 16, 2024

Scope & Context

E2E testing

Expected behavior

We want our e2e testing package to be able to launch graphQL Queries against the URL set in its .env.

That way we can for example test that when we login we see the first names that are in the DB for Companies.

And other tests that would require to know what's in the DB to make the relevant assertions.

For now we can set the authorization token in an env var.

@lucasbordeau lucasbordeau added the good first issue Good for newcomers label Aug 16, 2024
@BOHEUS
Copy link
Contributor

BOHEUS commented Aug 16, 2024

I'm working on it, please assign me to it

@shwetd19
Copy link

Hey @lucasbordeau

To address this, We can update the e2e testing configuration to include the GraphQL endpoint in the .env file. Then we can modify the test setup to fetch the endpoint URL from the .env file and implement queries against it. This will allow us to test various cases, such as verifying the display of user data after login. Ensuring that authorization tokens and other necessary configurations are correctly applied during tests to reflect real-world conditions.

Can I work on this ?

@lucasbordeau
Copy link
Contributor Author

@shwetd19 Can you please discuss this with @BOHEUS as he's taking the lead on E2E testing ?

@BOHEUS
Copy link
Contributor

BOHEUS commented Aug 20, 2024

In #6644 I modified the .env.example file to contain GraphQL URL (as well as REST API URL), for now it's commented and directing to local instance but it can easily changed to any other URL like Demo instance. The bigger problem is with storing the token as it's generated per workspace (so it's unique) and can't be mocked (or I don't know any way how to mock it properly). The solution for this would be probably using the global setup which runs before any tests with API (or maybe even before all tests? To be decided) and stores the token in the process.ENV

Reference: https://playwright.dev/docs/test-global-setup-teardown#teardown

I'll take care of that as it's not really hard to do.

@BOHEUS
Copy link
Contributor

BOHEUS commented Aug 21, 2024

@shwetd19 if you want, you can create all necessary GraphQL queries, it'll help a lot, just be aware how it's done as it's different compared to normal Web tests, I'm sending some documentation which I hope will help you understand.

FYI, queries must be mashed into one line in order to send them to API (check the blog post in second link).

Documentation:

@lucasbordeau
Copy link
Contributor Author

@BOHEUS Could we implement msw ? Like in stories ?

@BOHEUS
Copy link
Contributor

BOHEUS commented Aug 29, 2024

@lucasbordeau could you explain what does "msw" stand for? I'm not sure about the meaning behind this abbreviation

@lucasbordeau
Copy link
Contributor Author

Sure ! We use https://mswjs.io/ for mocking our GraphQL API in stories, this way we don't have to bother with mocking anything in the frontend code, we just mock the response for a specific request.

We use msw-storybook-addon, maybe there's one also for our use case.

Also it would help to think about how we could re-use what we already wrote for stories in a shared folder of msw mocks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants