chore: fix circleci on vite build (#10214)

- Switch to pnpm based build
- Switch circleci from docker to machine to have more memory
- Fix frontend and backend tests

Fixes
https://linear.app/chatwoot/issue/CW-3610/fix-circle-ci-for-vite-build
---------

Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
Co-authored-by: Pranav <pranavrajs@gmail.com>
Co-authored-by: Pranav <pranav@chatwoot.com>
This commit is contained in:
Vishnu Narayanan
2024-10-07 15:27:41 +05:30
committed by GitHub
parent 0677d8763d
commit ee02923ace
54 changed files with 1130 additions and 1334 deletions

View File

@@ -1,6 +1,8 @@
import Vue from 'vue';
import { shallowMount } from '@vue/test-utils';
import { useAlert } from 'dashboard/composables';
import fileUploadMixin from 'dashboard/mixins/fileUploadMixin';
import { checkFileSizeLimit } from 'shared/helpers/FileHelper';
import { reactive } from 'vue';
vi.mock('shared/helpers/FileHelper', () => ({
checkFileSizeLimit: vi.fn(),
@@ -17,61 +19,80 @@ vi.mock('dashboard/composables', () => ({
}));
describe('FileUploadMixin', () => {
let vm;
let wrapper;
let mockGlobalConfig;
let mockCurrentChat;
let mockCurrentUser;
beforeEach(() => {
vm = new Vue(fileUploadMixin);
vm.isATwilioSMSChannel = false;
vm.globalConfig = {
mockGlobalConfig = reactive({
directUploadsEnabled: true,
};
vm.accountId = 123;
vm.currentChat = {
});
mockCurrentChat = reactive({
id: 456,
};
vm.currentUser = {
});
mockCurrentUser = reactive({
access_token: 'token',
};
vm.$t = vi.fn(message => message);
vm.showAlert = vi.fn();
vm.attachFile = vi.fn();
});
wrapper = shallowMount({
mixins: [fileUploadMixin],
data() {
return {
globalConfig: mockGlobalConfig,
currentChat: mockCurrentChat,
currentUser: mockCurrentUser,
isATwilioSMSChannel: false,
};
},
methods: {
attachFile: vi.fn(),
showAlert: vi.fn(),
$t: msg => msg,
},
template: '<div />',
});
});
it('should call onDirectFileUpload when direct uploads are enabled', () => {
vm.onDirectFileUpload = vi.fn();
vm.onFileUpload({});
expect(vm.onDirectFileUpload).toHaveBeenCalledWith({});
wrapper.vm.onDirectFileUpload = vi.fn();
wrapper.vm.onFileUpload({});
expect(wrapper.vm.onDirectFileUpload).toHaveBeenCalledWith({});
});
it('should call onIndirectFileUpload when direct uploads are disabled', () => {
vm.globalConfig.directUploadsEnabled = false;
vm.onIndirectFileUpload = vi.fn();
vm.onFileUpload({});
expect(vm.onIndirectFileUpload).toHaveBeenCalledWith({});
wrapper.vm.globalConfig.directUploadsEnabled = false;
wrapper.vm.onIndirectFileUpload = vi.fn();
wrapper.vm.onFileUpload({});
expect(wrapper.vm.onIndirectFileUpload).toHaveBeenCalledWith({});
});
describe('onDirectFileUpload', () => {
it('returns early if no file is provided', () => {
const returnValue = vm.onDirectFileUpload(null);
const returnValue = wrapper.vm.onDirectFileUpload(null);
expect(returnValue).toBeUndefined();
});
it('shows an alert if the file size exceeds the maximum limit', () => {
const fakeFile = { size: 999999999 };
vm.onDirectFileUpload(fakeFile);
checkFileSizeLimit.mockReturnValue(false); // Mock exceeding file size
wrapper.vm.onDirectFileUpload(fakeFile);
expect(useAlert).toHaveBeenCalledWith(expect.any(String));
});
});
describe('onIndirectFileUpload', () => {
it('returns early if no file is provided', () => {
const returnValue = vm.onIndirectFileUpload(null);
const returnValue = wrapper.vm.onIndirectFileUpload(null);
expect(returnValue).toBeUndefined();
});
it('shows an alert if the file size exceeds the maximum limit', () => {
const fakeFile = { size: 999999999 };
vm.onIndirectFileUpload(fakeFile);
checkFileSizeLimit.mockReturnValue(false); // Mock exceeding file size
wrapper.vm.onIndirectFileUpload(fakeFile);
expect(useAlert).toHaveBeenCalledWith(expect.any(String));
});
});