Initial commit: Add logistics and order_detail message types
Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
- Add Logistics component with progress tracking - Add OrderDetail component for order information - Support data-driven steps and actions - Add blue color scale to widget SCSS - Fix node overflow and progress bar rendering issues - Add English translations for dashboard components Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
102
app/javascript/dashboard/mixins/specs/fileUploadMixin.spec.js
Normal file
102
app/javascript/dashboard/mixins/specs/fileUploadMixin.spec.js
Normal file
@@ -0,0 +1,102 @@
|
||||
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(),
|
||||
resolveMaximumFileUploadSize: vi.fn(value => Number(value) || 40),
|
||||
DEFAULT_MAXIMUM_FILE_UPLOAD_SIZE: 40,
|
||||
}));
|
||||
|
||||
vi.mock('activestorage', () => ({
|
||||
DirectUpload: vi.fn().mockImplementation(() => ({
|
||||
create: vi.fn(),
|
||||
})),
|
||||
}));
|
||||
|
||||
vi.mock('dashboard/composables', () => ({
|
||||
useAlert: vi.fn(),
|
||||
}));
|
||||
|
||||
describe('FileUploadMixin', () => {
|
||||
let wrapper;
|
||||
let mockGlobalConfig;
|
||||
let mockCurrentChat;
|
||||
let mockCurrentUser;
|
||||
|
||||
beforeEach(() => {
|
||||
mockGlobalConfig = reactive({
|
||||
directUploadsEnabled: true,
|
||||
maximumFileUploadSize: 40,
|
||||
});
|
||||
|
||||
mockCurrentChat = reactive({
|
||||
id: 456,
|
||||
});
|
||||
|
||||
mockCurrentUser = reactive({
|
||||
access_token: 'token',
|
||||
});
|
||||
|
||||
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', () => {
|
||||
wrapper.vm.onDirectFileUpload = vi.fn();
|
||||
wrapper.vm.onFileUpload({});
|
||||
expect(wrapper.vm.onDirectFileUpload).toHaveBeenCalledWith({});
|
||||
});
|
||||
|
||||
it('should call onIndirectFileUpload when direct uploads are disabled', () => {
|
||||
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 = wrapper.vm.onDirectFileUpload(null);
|
||||
expect(returnValue).toBeUndefined();
|
||||
});
|
||||
|
||||
it('shows an alert if the file size exceeds the maximum limit', () => {
|
||||
const fakeFile = { size: 999999999 };
|
||||
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 = wrapper.vm.onIndirectFileUpload(null);
|
||||
expect(returnValue).toBeUndefined();
|
||||
});
|
||||
|
||||
it('shows an alert if the file size exceeds the maximum limit', () => {
|
||||
const fakeFile = { size: 999999999 };
|
||||
checkFileSizeLimit.mockReturnValue(false); // Mock exceeding file size
|
||||
wrapper.vm.onIndirectFileUpload(fakeFile);
|
||||
expect(useAlert).toHaveBeenCalledWith(expect.any(String));
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user