mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
fix(editor): Improve formatting of expired trial error message (#11708)
This commit is contained in:
55
packages/editor-ui/src/composables/useToast.test.ts
Normal file
55
packages/editor-ui/src/composables/useToast.test.ts
Normal file
@@ -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")',
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user