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): Update E2E tests for recent permissions changes #2247

Merged
merged 5 commits into from
Oct 2, 2023

Conversation

DafyddLlyr
Copy link
Contributor

@DafyddLlyr DafyddLlyr commented Sep 29, 2023

What does this PR do?

  • Unskips and fixes E2E tests
  • Resolves a few user store issues hit along the way

What was the issue?

email was added to the JWT in the API, but not in the e2e tests - commit 56e91c9 has a quick fix for this.

email was only added to the token to make things less noisy in another PR - I've just made the update to rely on the ID by using the user.getById() method introduced here - theopensystemslab/planx-core#143

Apologies for the commit with linting issues - I'll take a look at Husky today and try to work out what the issues is here.

@DafyddLlyr DafyddLlyr changed the title Dp/unskip permission e2e tests fix(e2e): Update E2E tests for recent permissions changes Sep 29, 2023
@DafyddLlyr DafyddLlyr force-pushed the dp/unskip-permission-e2e-tests branch from a34982e to ac363db Compare September 29, 2023 10:40
@@ -73,5 +72,11 @@
},
"settings": {
"jest": { "version": 27 }
}
},
"overrides": [
Copy link
Contributor Author

@DafyddLlyr DafyddLlyr Sep 29, 2023

Choose a reason for hiding this comment

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

This config update means that these linting rules will only apply to test files - I was getting a linting error from testing-library/react for using the client.user.getById() which shares a name with a testing-library function.

Docs: https://github.com/testing-library/eslint-plugin-testing-library#eslint-overrides

email: string;
isPlatformAdmin: boolean;
teams: UserTeams[];
user?: User
Copy link
Contributor Author

@DafyddLlyr DafyddLlyr Sep 29, 2023

Choose a reason for hiding this comment

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

I consolidated these into a single user because of a side effect of merging our Zustand stores I was hitting up against.

FlowId is also called id in the stores which then overwrites userId which we wouldn't expect.

image

`,
variables: { email },
});
if (this.getUser()) return;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Checking this means we now don't run this query on each route change, just on initial page load.

@github-actions
Copy link

github-actions bot commented Sep 29, 2023

Removed vultr server and associated DNS entries

@DafyddLlyr DafyddLlyr marked this pull request as ready for review September 29, 2023 13:48
});
});
});

it("returns an error for an invalid email address", async () => {
mockGetByEmail.mockResolvedValueOnce(null);
mockGetById.mockResolvedValueOnce(null);

await supertest(app)
.get("/me")
.set(authHeader({ role: "teamEditor" }))
Copy link
Member

Choose a reason for hiding this comment

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

👍

- Remove redundant email from JWT, rely on ID
- Update API tests
- Update /me route
- Only init user store once
- Update Header to use store for username
- Avoid zustand namespace clashes in user store
@DafyddLlyr DafyddLlyr force-pushed the dp/unskip-permission-e2e-tests branch from c52982b to aca10fd Compare October 2, 2023 08:04
@DafyddLlyr DafyddLlyr merged commit 758ea99 into main Oct 2, 2023
12 checks passed
@DafyddLlyr DafyddLlyr deleted the dp/unskip-permission-e2e-tests branch October 2, 2023 08:28
DafyddLlyr added a commit to theopensystemslab/planx-core that referenced this pull request Oct 2, 2023
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.

2 participants