mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import ChatEmbedModal from '@/components/ChatEmbedModal.vue';
|
|
import { createTestingPinia } from '@pinia/testing';
|
|
import { CHAT_EMBED_MODAL_KEY, STORES, WEBHOOK_NODE_TYPE } from '@/constants';
|
|
import { createComponentRenderer } from '@/__tests__/render';
|
|
import { waitFor } from '@testing-library/vue';
|
|
import { cleanupAppModals, createAppModals } from '@/__tests__/utils';
|
|
|
|
const renderComponent = createComponentRenderer(ChatEmbedModal, {
|
|
props: {
|
|
teleported: false,
|
|
appendToBody: false,
|
|
},
|
|
pinia: createTestingPinia({
|
|
initialState: {
|
|
[STORES.UI]: {
|
|
modalsById: {
|
|
[CHAT_EMBED_MODAL_KEY]: { open: true },
|
|
},
|
|
},
|
|
[STORES.WORKFLOWS]: {
|
|
workflow: {
|
|
nodes: [{ type: WEBHOOK_NODE_TYPE }],
|
|
},
|
|
},
|
|
},
|
|
}),
|
|
});
|
|
|
|
describe('ChatEmbedModal', () => {
|
|
beforeEach(() => {
|
|
createAppModals();
|
|
});
|
|
|
|
afterEach(() => {
|
|
cleanupAppModals();
|
|
});
|
|
it('should render correctly', async () => {
|
|
const { getByTestId } = renderComponent();
|
|
|
|
await waitFor(() => expect(getByTestId('chatEmbed-modal')).toBeInTheDocument());
|
|
|
|
const modalContainer = getByTestId('chatEmbed-modal');
|
|
const tabs = modalContainer.querySelectorAll('.n8n-tabs .tab');
|
|
const activeTab = modalContainer.querySelector('.n8n-tabs .tab.activeTab');
|
|
const editor = modalContainer.querySelector('.cm-editor');
|
|
|
|
expect(tabs).toHaveLength(4);
|
|
expect(activeTab).toBeVisible();
|
|
expect(activeTab).toHaveTextContent('CDN Embed');
|
|
expect(editor).toBeVisible();
|
|
});
|
|
});
|