fix: Fix ts errors in editor part2 (no-changelog) (#9566)

This commit is contained in:
Tomi Turtiainen 2024-05-31 13:02:21 +03:00 committed by GitHub
parent 4b6e5f09e6
commit 400c005866
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 19 additions and 24 deletions

View file

@ -18,9 +18,12 @@ vi.mock('@/stores/rbac.store', () => ({
describe('RBAC', () => { describe('RBAC', () => {
it('renders default slot when hasScope is true', async () => { it('renders default slot when hasScope is true', async () => {
vi.mocked(useRBACStore).mockImplementation(() => ({ vi.mocked(useRBACStore).mockImplementation(
hasScope: () => true, () =>
})); ({
hasScope: () => true,
}) as unknown as ReturnType<typeof useRBACStore>,
);
const wrapper = renderComponent({ const wrapper = renderComponent({
props: { scope: 'worfklow:list' }, props: { scope: 'worfklow:list' },
@ -34,9 +37,12 @@ describe('RBAC', () => {
}); });
it('renders fallback slot when hasScope is false', async () => { it('renders fallback slot when hasScope is false', async () => {
vi.mocked(useRBACStore).mockImplementation(() => ({ vi.mocked(useRBACStore).mockImplementation(
hasScope: () => false, () =>
})); ({
hasScope: () => false,
}) as unknown as ReturnType<typeof useRBACStore>,
);
const wrapper = renderComponent({ const wrapper = renderComponent({
props: { scope: 'worfklow:list' }, props: { scope: 'worfklow:list' },

View file

@ -1,20 +1,17 @@
import { import {
DEFAULT_SETUP, DEFAULT_SETUP,
MAPPING_COLUMNS_RESPONSE, MAPPING_COLUMNS_RESPONSE,
NODE_PARAMETER_VALUES,
UPDATED_SCHEMA, UPDATED_SCHEMA,
} from './utils/ResourceMapper.utils'; } from './utils/ResourceMapper.utils';
import { useNodeTypesStore } from '@/stores/nodeTypes.store'; import { useNodeTypesStore } from '@/stores/nodeTypes.store';
import { waitAllPromises } from '@/__tests__/utils'; import { waitAllPromises } from '@/__tests__/utils';
import * as workflowHelpers from '@/composables/useWorkflowHelpers';
import ResourceMapper from '@/components/ResourceMapper/ResourceMapper.vue'; import ResourceMapper from '@/components/ResourceMapper/ResourceMapper.vue';
import userEvent from '@testing-library/user-event'; import userEvent from '@testing-library/user-event';
import { createComponentRenderer } from '@/__tests__/render'; import { createComponentRenderer } from '@/__tests__/render';
import type { SpyInstance } from 'vitest'; import type { MockInstance } from 'vitest';
let nodeTypeStore: ReturnType<typeof useNodeTypesStore>; let nodeTypeStore: ReturnType<typeof useNodeTypesStore>;
let fetchFieldsSpy: SpyInstance; let fetchFieldsSpy: MockInstance;
let resolveParameterSpy: SpyInstance;
const renderComponent = createComponentRenderer(ResourceMapper, DEFAULT_SETUP); const renderComponent = createComponentRenderer(ResourceMapper, DEFAULT_SETUP);
@ -24,9 +21,6 @@ describe('ResourceMapper.vue', () => {
fetchFieldsSpy = vi fetchFieldsSpy = vi
.spyOn(nodeTypeStore, 'getResourceMapperFields') .spyOn(nodeTypeStore, 'getResourceMapperFields')
.mockResolvedValue(MAPPING_COLUMNS_RESPONSE); .mockResolvedValue(MAPPING_COLUMNS_RESPONSE);
resolveParameterSpy = vi
.spyOn(workflowHelpers, 'resolveRequiredParameters')
.mockReturnValue(NODE_PARAMETER_VALUES);
}); });
afterEach(() => { afterEach(() => {
@ -198,7 +192,7 @@ describe('ResourceMapper.vue', () => {
}); });
it('should render correct fields based on saved schema', async () => { it('should render correct fields based on saved schema', async () => {
const { getByTestId, queryAllByTestId } = renderComponent( const { getByTestId } = renderComponent(
{ {
props: { props: {
node: { node: {

View file

@ -67,7 +67,7 @@ describe('RunDataSearch', () => {
}, },
}); });
const input = getByRole('textbox'); const input = getByRole<HTMLInputElement>('textbox');
await userEvent.click(input); await userEvent.click(input);
expect(emitted().focus).toHaveLength(1); expect(emitted().focus).toHaveLength(1);

View file

@ -1,4 +1,4 @@
import { vi } from 'vitest'; import type { Mock, MockInstance } from 'vitest';
import { createPinia, setActivePinia } from 'pinia'; import { createPinia, setActivePinia } from 'pinia';
import { waitFor } from '@testing-library/vue'; import { waitFor } from '@testing-library/vue';
import type { ExecutionSummary } from 'n8n-workflow'; import type { ExecutionSummary } from 'n8n-workflow';
@ -11,8 +11,8 @@ const renderComponent = createComponentRenderer(WorkflowPreview);
let pinia: ReturnType<typeof createPinia>; let pinia: ReturnType<typeof createPinia>;
let executionsStore: ReturnType<typeof useExecutionsStore>; let executionsStore: ReturnType<typeof useExecutionsStore>;
let postMessageSpy: vi.SpyInstance; let postMessageSpy: Mock;
let consoleErrorSpy: vi.SpyInstance; let consoleErrorSpy: MockInstance;
const sendPostMessageCommand = (command: string) => { const sendPostMessageCommand = (command: string) => {
window.postMessage(`{"command":"${command}"}`, '*'); window.postMessage(`{"command":"${command}"}`, '*');

View file

@ -154,7 +154,6 @@ export const MAPPING_COLUMNS_RESPONSE: ResourceMapperFields = {
{ {
id: 'First name', id: 'First name',
displayName: 'First name', displayName: 'First name',
match: false,
required: true, required: true,
defaultMatch: false, defaultMatch: false,
display: true, display: true,
@ -164,7 +163,6 @@ export const MAPPING_COLUMNS_RESPONSE: ResourceMapperFields = {
{ {
id: 'Last name', id: 'Last name',
displayName: 'Last name', displayName: 'Last name',
match: false,
required: true, required: true,
defaultMatch: false, defaultMatch: false,
display: true, display: true,
@ -174,7 +172,6 @@ export const MAPPING_COLUMNS_RESPONSE: ResourceMapperFields = {
{ {
id: 'Username', id: 'Username',
displayName: 'Username', displayName: 'Username',
match: false,
required: false, required: false,
defaultMatch: false, defaultMatch: false,
display: true, display: true,
@ -184,7 +181,6 @@ export const MAPPING_COLUMNS_RESPONSE: ResourceMapperFields = {
{ {
id: 'Address', id: 'Address',
displayName: 'Address', displayName: 'Address',
match: false,
required: false, required: false,
defaultMatch: false, defaultMatch: false,
display: true, display: true,
@ -194,7 +190,6 @@ export const MAPPING_COLUMNS_RESPONSE: ResourceMapperFields = {
{ {
id: 'id', id: 'id',
displayName: 'id', displayName: 'id',
match: true,
required: true, required: true,
defaultMatch: true, defaultMatch: true,
display: true, display: true,