mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
fix(editor): Source control workflow diff release (#17974)
Co-authored-by: r00gm <raul00gm@gmail.com>
This commit is contained in:
@@ -7,6 +7,8 @@ import { useSourceControlStore } from '@/stores/sourceControl.store';
|
||||
import { mockedStore } from '@/__tests__/utils';
|
||||
import { waitFor } from '@testing-library/dom';
|
||||
import { reactive } from 'vue';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { defaultSettings } from '@/__tests__/defaults';
|
||||
|
||||
const eventBus = createEventBus();
|
||||
|
||||
@@ -21,6 +23,7 @@ const mockRoute = reactive({
|
||||
vi.mock('vue-router', () => ({
|
||||
useRoute: () => mockRoute,
|
||||
useRouter: () => ({
|
||||
back: vi.fn(),
|
||||
push: vi.fn(),
|
||||
replace: vi.fn(),
|
||||
go: vi.fn(),
|
||||
@@ -31,6 +34,14 @@ vi.mock('vue-router', () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock('@/composables/useLoadingService', () => ({
|
||||
useLoadingService: () => ({
|
||||
startLoading: vi.fn(),
|
||||
stopLoading: vi.fn(),
|
||||
setLoadingText: vi.fn(),
|
||||
}),
|
||||
}));
|
||||
|
||||
// Mock the toast composable to prevent Element Plus DOM errors
|
||||
vi.mock('@/composables/useToast', () => ({
|
||||
useToast: () => ({
|
||||
@@ -47,6 +58,7 @@ const DynamicScrollerStub = {
|
||||
minItemSize: Number,
|
||||
class: String,
|
||||
style: [String, Object],
|
||||
itemClass: String,
|
||||
},
|
||||
template:
|
||||
'<div><template v-for="(item, index) in items" :key="index"><slot v-bind="{ item, index, active: false }"></slot></template></div>',
|
||||
@@ -80,13 +92,14 @@ const renderModal = createComponentRenderer(SourceControlPullModalEe, {
|
||||
</div>
|
||||
`,
|
||||
},
|
||||
EnvFeatureFlag: {
|
||||
template: '<div><slot></slot></div>',
|
||||
},
|
||||
N8nIconButton: {
|
||||
template: '<button><slot></slot></button>',
|
||||
props: ['icon', 'type', 'class'],
|
||||
},
|
||||
'router-link': {
|
||||
template: '<a><slot /></a>',
|
||||
props: ['to'],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -116,18 +129,29 @@ const sampleFiles = [
|
||||
|
||||
describe('SourceControlPullModal', () => {
|
||||
let sourceControlStore: ReturnType<typeof mockedStore<typeof useSourceControlStore>>;
|
||||
let settingsStore: ReturnType<typeof mockedStore<typeof useSettingsStore>>;
|
||||
let pinia: ReturnType<typeof createTestingPinia>;
|
||||
|
||||
beforeEach(() => {
|
||||
createTestingPinia();
|
||||
vi.clearAllMocks();
|
||||
|
||||
// Setup store with default mock to prevent automatic data loading
|
||||
pinia = createTestingPinia();
|
||||
sourceControlStore = mockedStore(useSourceControlStore);
|
||||
sourceControlStore.getAggregatedStatus = vi.fn().mockResolvedValue([]);
|
||||
sourceControlStore.pullWorkfolder = vi.fn().mockResolvedValue([]);
|
||||
|
||||
settingsStore = mockedStore(useSettingsStore);
|
||||
settingsStore.settings.enterprise = defaultSettings.enterprise;
|
||||
});
|
||||
|
||||
it('mounts', () => {
|
||||
const { getByText } = renderModal({
|
||||
pinia,
|
||||
props: {
|
||||
data: {
|
||||
eventBus,
|
||||
status: [],
|
||||
status: [], // Provide initial status to prevent auto-loading
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -136,6 +160,7 @@ describe('SourceControlPullModal', () => {
|
||||
|
||||
it('should renders the changes', () => {
|
||||
const { getAllByTestId } = renderModal({
|
||||
pinia,
|
||||
props: {
|
||||
data: {
|
||||
eventBus,
|
||||
@@ -150,7 +175,9 @@ describe('SourceControlPullModal', () => {
|
||||
});
|
||||
|
||||
it('should force pull', async () => {
|
||||
// Use the existing store instance from beforeEach
|
||||
const { getByTestId } = renderModal({
|
||||
pinia,
|
||||
props: {
|
||||
data: {
|
||||
eventBus,
|
||||
|
||||
Reference in New Issue
Block a user