-
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
fix(e2e): Update E2E tests for recent permissions changes #2247
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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", | ||
}); | ||
}); | ||
}); | ||
|
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" }), | ||
}, | ||
}); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
"extends": [ | ||
"eslint:recommended", | ||
"plugin:jsx-a11y/recommended", | ||
"plugin:testing-library/react", | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier", | ||
"plugin:jest/recommended" | ||
|
@@ -73,5 +72,11 @@ | |
}, | ||
"settings": { | ||
"jest": { "version": 27 } | ||
} | ||
}, | ||
"overrides": [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Docs: https://github.com/testing-library/eslint-plugin-testing-library#eslint-overrides |
||
{ | ||
"files": ["**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)"], | ||
"extends": ["plugin:testing-library/react"] | ||
} | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
👍