Skip to content
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 user is mentioned #231

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions e2e/tests/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,22 @@ test ('switching bots', async ({ page }) => {
// With correct message
await expect(page.getByText(responseTestText)).toBeVisible();
})

test('bot mention', async ({ page }) => {
const url = mattermost.url()
await login(page, url, "regularuser", "regularuser");;
await openAIMock.addCompletionMock(responseTest);

await page.getByTestId('post_textbox').click();
await page.getByTestId('post_textbox').fill('`@mock` TestBotMention1');
await page.getByTestId('post_textbox').press('Enter');
await expect(page.getByText("reply")).not.toBeVisible();

await page.getByTestId('post_textbox').fill('```\n@mock\n``` TestBotMention2');
await page.getByTestId('post_textbox').press('Enter');
await expect(page.getByText("reply")).not.toBeVisible();

await page.getByTestId('post_textbox').fill('@mock TestBotMention3');
await page.getByTestId('post_textbox').press('Enter');
await expect(page.getByText("1 reply")).toBeVisible();
})
2 changes: 1 addition & 1 deletion server/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func (p *Plugin) GetBotMentioned(text string) *Bot {
defer p.botsLock.RUnlock()

for _, bot := range p.bots {
if userIsMentioned(text, bot.mmBot.Username) {
if userIsMentionedMarkdown(text, bot.mmBot.Username) {
return bot
}
}
Expand Down