forked from garageScript/c0d3-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Storyshot throw an error (garageScript#2257)
- Loading branch information
Showing
2 changed files
with
4 additions
and
179 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -522,183 +522,6 @@ describe('user profile test', () => { | |
await waitFor(() => expect(unlinkDiscordMock.result).toBeCalled()) | ||
}) | ||
|
||
test('should handle error when unlinking discord', async () => { | ||
expect.assertions(1) | ||
|
||
const session = { | ||
user: { | ||
id: 1, | ||
username: 'fakeusername', | ||
name: 'fake user', | ||
email: '[email protected]', | ||
isAdmin: true, | ||
discordUserId: 'fakeDiscordId', | ||
discordUsername: 'fakeDiscordUser', | ||
discordAvatarUrl: 'https://placeimg.com/640/480/any' | ||
}, | ||
submissions: [ | ||
{ | ||
id: 1, | ||
status: SubmissionStatus.Passed, | ||
mrUrl: '', | ||
diff: '', | ||
viewCount: 0, | ||
comment: '', | ||
order: 0, | ||
challengeId: 146, | ||
lessonId: 2, | ||
reviewer: { | ||
id: 1, | ||
username: 'fake reviewer' | ||
}, | ||
createdAt: '123', | ||
updatedAt: '123', | ||
comments: null, | ||
user: { | ||
id: 1 | ||
} | ||
}, | ||
{ | ||
id: 2, | ||
status: SubmissionStatus.Passed, | ||
mrUrl: '', | ||
diff: '', | ||
viewCount: 0, | ||
comment: '', | ||
order: 0, | ||
challengeId: 145, | ||
lessonId: 2, | ||
reviewer: { | ||
id: 1, | ||
username: 'fake reviewer' | ||
}, | ||
createdAt: '123', | ||
updatedAt: '123', | ||
comments: null, | ||
user: { | ||
id: 1 | ||
} | ||
} | ||
], | ||
lessonStatus: [ | ||
{ | ||
lessonId: 5, | ||
passedAt: new Date(), | ||
starGiven: null, | ||
starsReceived: [ | ||
{ | ||
id: 17, | ||
mentorId: 1, | ||
studentId: 6, | ||
lessonId: 5, | ||
student: { | ||
username: 'newbie', | ||
name: 'newbie newbie' | ||
}, | ||
lesson: { | ||
title: 'Foundations of JavaScript', | ||
order: 1 | ||
}, | ||
comment: 'Thanks for your halp!' | ||
} | ||
] | ||
}, | ||
{ | ||
lessonId: 2, | ||
passedAt: new Date(), | ||
starGiven: null, | ||
starsReceived: [ | ||
{ | ||
id: 17, | ||
mentorId: 1, | ||
studentId: 6, | ||
lessonId: 2, | ||
student: { | ||
username: 'newbie', | ||
name: 'newbie newbie' | ||
}, | ||
lesson: { | ||
title: 'Variables & Functions', | ||
order: 1 | ||
}, | ||
comment: 'Thanks for your halp!' | ||
} | ||
] | ||
}, | ||
{ | ||
lessonId: 1, | ||
passedAt: new Date(), | ||
starGiven: null, | ||
starsReceived: [ | ||
{ | ||
id: 17, | ||
mentorId: 1, | ||
studentId: 6, | ||
lessonId: 2, | ||
student: { | ||
username: 'anonymous', | ||
name: '' | ||
}, | ||
lesson: { | ||
title: 'Variables & Functions', | ||
order: 1 | ||
}, | ||
comment: '' | ||
} | ||
] | ||
} | ||
] | ||
} | ||
|
||
const unlinkDiscordMockWithError = { | ||
request: { | ||
query: UNLINK_DISCORD | ||
}, | ||
error: new Error('error') | ||
} | ||
|
||
const mocks = [ | ||
{ | ||
request: { query: GET_APP }, | ||
result: { | ||
data: { | ||
session, | ||
lessons: dummyLessonData, | ||
alerts: [] | ||
} | ||
} | ||
}, | ||
{ | ||
request: { | ||
query: USER_INFO, | ||
variables: { | ||
username: 'fake user' | ||
} | ||
}, | ||
result: { | ||
data: { | ||
userInfo: session | ||
} | ||
} | ||
}, | ||
unlinkDiscordMockWithError | ||
] | ||
|
||
const { findByRole, getByText, getByTestId } = render( | ||
<MockedProvider mocks={mocks} addTypename={false}> | ||
<UserProfile /> | ||
</MockedProvider> | ||
) | ||
|
||
await waitForElementToBeRemoved(() => getByText('Loading...')) | ||
await findByRole('heading', { name: /fakeDiscordUser/i }) | ||
|
||
await userEvent.click(getByText(/unlink discord/i)) | ||
await userEvent.click(getByTestId('unlink-discord-btn')) | ||
|
||
expect(Sentry.captureException).toBeCalled() | ||
}) | ||
|
||
test('should link discord to user account', async () => { | ||
expect.assertions(1) | ||
|
||
|
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