feat: findMentionsInIssue uses Issue obj
ci/woodpecker/push/woodpecker Pipeline was successful Details

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 => {