-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
1,778 additions
and
17 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
87 changes: 87 additions & 0 deletions
87
packages/backend/server/src/__tests__/utils/notification.ts
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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { PaginationInput } from '../../base/graphql/pagination'; | ||
import type { | ||
MentionInput, | ||
PaginatedNotificationObjectType, | ||
} from '../../core/notification/types'; | ||
import type { TestingApp } from './testing-app'; | ||
|
||
export async function listNotifications( | ||
app: TestingApp, | ||
pagination: PaginationInput | ||
): Promise<PaginatedNotificationObjectType> { | ||
const res = await app.gql( | ||
` | ||
query listNotifications($pagination: PaginationInput!) { | ||
currentUser { | ||
notifications(pagination: $pagination) { | ||
totalCount | ||
edges { | ||
cursor | ||
node { | ||
id | ||
type | ||
level | ||
read | ||
starred | ||
createdAt | ||
updatedAt | ||
body | ||
} | ||
} | ||
pageInfo { | ||
startCursor | ||
endCursor | ||
hasNextPage | ||
hasPreviousPage | ||
} | ||
} | ||
} | ||
} | ||
`, | ||
{ pagination } | ||
); | ||
return res.currentUser.notifications; | ||
} | ||
|
||
export async function getNotificationCount(app: TestingApp): Promise<number> { | ||
const res = await app.gql( | ||
` | ||
query notificationCount { | ||
currentUser { | ||
notificationCount | ||
} | ||
} | ||
` | ||
); | ||
return res.currentUser.notificationCount; | ||
} | ||
|
||
export async function mentionUser( | ||
app: TestingApp, | ||
input: MentionInput | ||
): Promise<boolean> { | ||
const res = await app.gql( | ||
` | ||
mutation mentionUser($input: MentionInput!) { | ||
mentionUser(input: $input) | ||
} | ||
`, | ||
{ input } | ||
); | ||
return res.mentionUser; | ||
} | ||
|
||
export async function readNotification( | ||
app: TestingApp, | ||
id: string | ||
): Promise<boolean> { | ||
const res = await app.gql( | ||
` | ||
mutation readNotification($id: String!) { | ||
readNotification(id: $id) | ||
} | ||
`, | ||
{ id } | ||
); | ||
return res.readNotification; | ||
} |
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.