-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(e2e): Update E2E tests for recent permissions changes (#2247)
* fix(e2e): Quick fix of failing e2e tests * fix(e2e): Uncomment skipped e2e tests - Remove redundant email from JWT, rely on ID - Update API tests - Update /me route * fix: Update frontend - Only init user store once - Update Header to use store for username - Avoid zustand namespace clashes in user store * fix: Linting * fix: Update API tests
- Loading branch information
1 parent
4cc16e3
commit 758ea99
Showing
32 changed files
with
208 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ import { userContext } from "../auth/middleware"; | |
|
||
const getStoreMock = jest.spyOn(userContext, "getStore"); | ||
|
||
const mockGetByEmail = jest.fn().mockResolvedValue({ | ||
id: 36, | ||
const mockGetById = jest.fn().mockResolvedValue({ | ||
id: 123, | ||
firstName: "Albert", | ||
lastName: "Einstein", | ||
email: "[email protected]", | ||
|
@@ -27,7 +27,7 @@ jest.mock("@opensystemslab/planx-core", () => { | |
return { | ||
CoreDomainClient: jest.fn().mockImplementation(() => ({ | ||
user: { | ||
getByEmail: () => mockGetByEmail(), | ||
getById: () => mockGetById(), | ||
}, | ||
})), | ||
}; | ||
|
@@ -38,7 +38,6 @@ describe("/me endpoint", () => { | |
getStoreMock.mockReturnValue({ | ||
user: { | ||
sub: "123", | ||
email: "[email protected]", | ||
jwt: getJWT({ role: "teamEditor" }), | ||
}, | ||
}); | ||
|
@@ -58,8 +57,7 @@ describe("/me endpoint", () => { | |
it("returns an error for invalid user context", async () => { | ||
getStoreMock.mockReturnValue({ | ||
user: { | ||
sub: "123", | ||
email: undefined, | ||
sub: undefined, | ||
jwt: getJWT({ role: "teamEditor" }), | ||
}, | ||
}); | ||
|
@@ -70,21 +68,21 @@ describe("/me endpoint", () => { | |
.expect(400) | ||
.then((res) => { | ||
expect(res.body).toEqual({ | ||
error: "User email missing from request", | ||
error: "User ID missing from request", | ||
}); | ||
}); | ||
}); | ||
|
||
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" })) | ||
.expect(400) | ||
.then((res) => { | ||
expect(res.body).toEqual({ | ||
error: "Unable to locate user with email [email protected]", | ||
error: "Unable to locate user with ID 123", | ||
}); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,6 @@ describe("TeamService", () => { | |
getStoreMock.mockReturnValue({ | ||
user: { | ||
sub: "123", | ||
email: "[email protected]", | ||
jwt: getJWT({ role: "teamEditor" }), | ||
}, | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
{ | ||
"extends": ["../../.eslintrc", "plugin:playwright/playwright-test"], | ||
"rules": { | ||
"playwright/no-skipped-test": "off" | ||
} | ||
"extends": ["../../.eslintrc", "plugin:playwright/playwright-test"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
editor.planx.uk/src/@planx/components/FileUploadAndLabel/Editor.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.