feat: findMentionsInIssue uses Issue obj
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Aravinth Manivannan 2023-09-19 05:45:35 +05:30
parent f5fe8a90e5
commit d43f1d29ca
Signed by: realaravinth
GPG key ID: F8F50389936984FF
2 changed files with 20 additions and 8 deletions

View file

@ -65,9 +65,23 @@ test("comments API ", async () => {
});
test("mentions in issue", async () => {
expect(await api.findMentionsInIssue(username, repo, 1)).toBe(true);
expect(await api.findMentionsInIssue(username, repo, 2)).toBe(true);
expect(await api.findMentionsInIssue(username, repo, 3)).toBe(true);
expect(await api.findMentionsInIssue(username, repo, 4)).toBe(true);
expect(await api.findMentionsInIssue(username, repo, 5)).toBe(false);
let issue = await api.getIssue(username, repo, 1);
issue = await api.getCommentsForIssue(issue);
expect(await api.findMentionsInIssue(issue)).toBe(true);
issue = await api.getIssue(username, repo, 2);
issue = await api.getCommentsForIssue(issue);
expect(await api.findMentionsInIssue(issue)).toBe(true);
issue = await api.getIssue(username, repo, 3);
issue = await api.getCommentsForIssue(issue);
expect(await api.findMentionsInIssue(issue)).toBe(true);
issue = await api.getIssue(username, repo, 4);
issue = await api.getCommentsForIssue(issue);
expect(await api.findMentionsInIssue(issue)).toBe(true);
issue = await api.getIssue(username, repo, 5);
issue = await api.getCommentsForIssue(issue);
expect(await api.findMentionsInIssue(issue)).toBe(false);
});

View file

@ -117,9 +117,7 @@ class Forgejo {
/**
* Check if logged in user is mentioned in the issue
*/
async findMentionsInIssue(owner: string, repo: string, id: number) {
let issue = await this.getIssue(owner, repo, id);
issue = await this.getCommentsForIssue(issue);
async findMentionsInIssue(issue: Issue) {
let unreadTime = this.lastReadTime(issue);
const mentionUtil = (str: string): boolean => {