-
Notifications
You must be signed in to change notification settings - Fork 2
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
test: Setup E2E tests for user roles #2220
Conversation
Removed vultr server and associated DNS entries |
To be implemented in theopensystemslab/planx-new#2220 to help tear down permission-based tests.
1152ca7
to
3c6e8db
Compare
/** | ||
* Error handling boilerplate for client functions | ||
*/ | ||
export function safely<T extends () => ReturnType<T>>(callback: T) { |
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.
One thing this highlighted was that the planx-core
client doesn't always return consistent values for success/failure. Sometimes it's a null
, or false
, or an error is thrown.
Taking a bit of inspiration from useSWR
it would be super nice if it just always returned a consistent result object of some sort which we could check for errors.
import { User, Role } from "@opensystemslab/planx-core/types"; | ||
import { $admin } from "./client"; | ||
|
||
// This code is copied from api.planx.uk/modules/auth/service.ts |
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.
Not an ideal solution - another candidate for functionality that could move to planx-core
possibly?
@@ -0,0 +1,7 @@ | |||
import { INSERT_FLOW_QUERY } from "./flows"; | |||
|
|||
export const queries = { |
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 PR is just setup. I envision the next PR will be just be adding a bunch of queries here (and maybe a few additional setup/cleanup steps)
Then they have access | ||
|
||
Examples: | ||
| TABLE | ACTION | |
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.
I did consider adding a DATA
and COLUMNS
column here and templating out standard CRUD GraphQL queries.
At least initially hardcoding queries is simpler (if slightly more tedious).
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.
Looks good & seems like a very solid start - thanks for these initial tooling decisions, setup, and documentation !
I'm sure I'll have more thoughts once I start writing tests myself, but don't see any blockers to this going in now 👍
- `setup()`: This function sets up the necessary environment or configurations required for the test scenario. | ||
- `cleanup()`: This function performs cleanup tasks after the test scenario is executed, such as resetting the environment to its initial state. | ||
|
||
- `steps.ts` file: This file contains the step definitions for your Gherkin scenarios. Each step definition maps a step in the `.feature` file to a function that performs the corresponding action and assertion in your test. We aim to keep these steps as readable as possible, with the majority of the logic being contained within `helpers.ts`. |
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.
💯
- Update planx-core - Move shared helpers - Scope test lifecycle hooks - Add JWT helper methods
f456bcb
to
794d305
Compare
What does this PR do?