forked from n8n-io/n8n
-
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(editor): Improve formatting of expired trial error message (n8n-i…
- Loading branch information
Ivan Atanasov
authored
Nov 14, 2024
1 parent
a91abee
commit 8a0ad0f
Showing
4 changed files
with
168 additions
and
3 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { describe, it, expect, vi, beforeEach } from 'vitest'; | ||
import { useToast } from './useToast'; | ||
import { createPinia, setActivePinia } from 'pinia'; | ||
import { ElNotification as Notification } from 'element-plus'; | ||
|
||
vi.mock('element-plus', async () => { | ||
const original = await vi.importActual('element-plus'); | ||
return { | ||
...original, | ||
ElNotification: vi.fn(), | ||
ElTooltip: vi.fn(), | ||
}; | ||
}); | ||
|
||
describe('useToast', () => { | ||
let toast: ReturnType<typeof useToast>; | ||
|
||
beforeEach(() => { | ||
setActivePinia(createPinia()); | ||
|
||
toast = useToast(); | ||
}); | ||
|
||
afterEach(() => { | ||
vi.restoreAllMocks(); | ||
}); | ||
|
||
it('should show a message', () => { | ||
const messageData = { message: 'Test message', title: 'Test title' }; | ||
toast.showMessage(messageData); | ||
|
||
expect(Notification).toHaveBeenCalledWith( | ||
expect.objectContaining({ | ||
message: 'Test message', | ||
title: 'Test title', | ||
}), | ||
); | ||
}); | ||
|
||
it('should sanitize message and title', () => { | ||
const messageData = { | ||
message: '<script>alert("xss")</script>', | ||
title: '<script>alert("xss")</script>', | ||
}; | ||
|
||
toast.showMessage(messageData); | ||
|
||
expect(Notification).toHaveBeenCalledWith( | ||
expect.objectContaining({ | ||
message: 'alert("xss")', | ||
title: 'alert("xss")', | ||
}), | ||
); | ||
}); | ||
}); |