/**
 * Tests for CommonTestAndPreview Constants
 * 
 * Tests all constant exports to ensure they are defined correctly
 */

import {
  // Redux Action Types
  SEARCH_CUSTOMERS_REQUESTED,
  SEARCH_CUSTOMERS_SUCCESS,
  SEARCH_CUSTOMERS_FAILURE,
  EXTRACT_TAGS_REQUESTED,
  EXTRACT_TAGS_SUCCESS,
  EXTRACT_TAGS_FAILURE,
  UPDATE_PREVIEW_REQUESTED,
  UPDATE_PREVIEW_SUCCESS,
  UPDATE_PREVIEW_FAILURE,
  SEND_TEST_MESSAGE_REQUESTED,
  SEND_TEST_MESSAGE_SUCCESS,
  SEND_TEST_MESSAGE_FAILURE,
  GET_TEST_CUSTOMERS_REQUESTED,
  GET_TEST_CUSTOMERS_SUCCESS,
  GET_TEST_CUSTOMERS_FAILURE,
  GET_TEST_GROUPS_REQUESTED,
  GET_TEST_GROUPS_SUCCESS,
  GET_TEST_GROUPS_FAILURE,
  CREATE_MESSAGE_META_REQUESTED,
  CREATE_MESSAGE_META_SUCCESS,
  CREATE_MESSAGE_META_FAILURE,
  GET_PREFILLED_VALUES_REQUESTED,
  GET_PREFILLED_VALUES_SUCCESS,
  GET_PREFILLED_VALUES_FAILURE,
  GET_SENDER_DETAILS_REQUESTED,
  GET_SENDER_DETAILS_SUCCESS,
  GET_SENDER_DETAILS_FAILURE,
  GET_WECRM_ACCOUNTS_REQUESTED,
  GET_WECRM_ACCOUNTS_SUCCESS,
  GET_WECRM_ACCOUNTS_FAILURE,
  CLEAR_CUSTOMER_SEARCH_STATE,
  CLEAR_SEARCH_RESULTS,
  CLEAR_PREFILLED_VALUES,
  CLEAR_PREVIEW_ERRORS,
  // Channel Constants
  CHANNELS,
  // Device Constants
  DESKTOP,
  MOBILE,
  TABLET,
  ANDROID,
  IOS,
  // Module and Client Constants
  MODULE_CREATIVES,
  CLIENT_NAME_CREATIVES,
  // API Channel Constants
  API_CHANNEL_PUSH,
  // Identifier Type Constants
  IDENTIFIER_TYPE_EMAIL,
  IDENTIFIER_TYPE_MOBILE,
  IDENTIFIER_TYPE_PHONE,
  INPUT_HAS_ERROR_CLASS,
  // Validation Regex
  EMAIL_REGEX,
  PHONE_REGEX,
  // Channel Name Constants
  CHANNEL_NAME_INAPP,
  // Channel Mapping Constants
  CHANNEL_MAPPING_EMAIL,
  // Media Type Constants
  MEDIA_TYPE_IMAGE,
  MEDIA_TYPE_TEXT,
  MEDIA_TYPE_VIDEO,
  MEDIA_TYPE_CAROUSEL,
  MEDIA_TYPE_DOCUMENT,
  // Layout Type Constants
  LAYOUT_TYPE_POPUP,
  LAYOUT_TYPE_FULLSCREEN,
  LAYOUT_TYPE_HEADER,
  LAYOUT_TYPE_FOOTER,
  LAYOUT_TYPE_MODAL,
  LAYOUT_TYPE_BANNER,
  // CTA Type Constants
  CTA_TYPE_DEEP_LINK,
  CTA_TYPE_EXTERNAL_URL,
  // Style Type Constants
  STYLE_TYPE_BIG_PICTURE,
  STYLE_TYPE_BIG_TEXT,
  // Device Type Constants
  DEVICE_TYPE_ANDROID,
  DEVICE_TYPE_IOS,
  // Button Type Constants
  BUTTON_TYPE_NONE,
  BUTTON_TYPE_PHONE_NUMBER,
  BUTTON_TYPE_DYNAMIC_URL,
  // Other Constants
  TEST,
  ACTIVE,
  // Initial Payload
  INITIAL_PAYLOAD,
} from '../constants';

describe('CommonTestAndPreview Constants', () => {
  describe('Redux Action Type Constants', () => {
    it('should export all search customer action types', () => {
      expect(SEARCH_CUSTOMERS_REQUESTED).toBe('app/CommonTestAndPreview/SEARCH_CUSTOMERS_REQUESTED');
      expect(SEARCH_CUSTOMERS_SUCCESS).toBe('app/CommonTestAndPreview/SEARCH_CUSTOMERS_SUCCESS');
      expect(SEARCH_CUSTOMERS_FAILURE).toBe('app/CommonTestAndPreview/SEARCH_CUSTOMERS_FAILURE');
    });

    it('should export all extract tags action types', () => {
      expect(EXTRACT_TAGS_REQUESTED).toBe('app/CommonTestAndPreview/EXTRACT_TAGS_REQUESTED');
      expect(EXTRACT_TAGS_SUCCESS).toBe('app/CommonTestAndPreview/EXTRACT_TAGS_SUCCESS');
      expect(EXTRACT_TAGS_FAILURE).toBe('app/CommonTestAndPreview/EXTRACT_TAGS_FAILURE');
    });

    it('should export all update preview action types', () => {
      expect(UPDATE_PREVIEW_REQUESTED).toBe('app/CommonTestAndPreview/UPDATE_PREVIEW_REQUESTED');
      expect(UPDATE_PREVIEW_SUCCESS).toBe('app/CommonTestAndPreview/UPDATE_PREVIEW_SUCCESS');
      expect(UPDATE_PREVIEW_FAILURE).toBe('app/CommonTestAndPreview/UPDATE_PREVIEW_FAILURE');
    });

    it('should export all send test message action types', () => {
      expect(SEND_TEST_MESSAGE_REQUESTED).toBe('app/CommonTestAndPreview/SEND_TEST_MESSAGE_REQUESTED');
      expect(SEND_TEST_MESSAGE_SUCCESS).toBe('app/CommonTestAndPreview/SEND_TEST_MESSAGE_SUCCESS');
      expect(SEND_TEST_MESSAGE_FAILURE).toBe('app/CommonTestAndPreview/SEND_TEST_MESSAGE_FAILURE');
    });

    it('should export all test customers action types', () => {
      expect(GET_TEST_CUSTOMERS_REQUESTED).toBe('app/CommonTestAndPreview/GET_TEST_CUSTOMERS_REQUESTED');
      expect(GET_TEST_CUSTOMERS_SUCCESS).toBe('app/CommonTestAndPreview/GET_TEST_CUSTOMERS_SUCCESS');
      expect(GET_TEST_CUSTOMERS_FAILURE).toBe('app/CommonTestAndPreview/GET_TEST_CUSTOMERS_FAILURE');
    });

    it('should export all test groups action types', () => {
      expect(GET_TEST_GROUPS_REQUESTED).toBe('app/CommonTestAndPreview/GET_TEST_GROUPS_REQUESTED');
      expect(GET_TEST_GROUPS_SUCCESS).toBe('app/CommonTestAndPreview/GET_TEST_GROUPS_SUCCESS');
      expect(GET_TEST_GROUPS_FAILURE).toBe('app/CommonTestAndPreview/GET_TEST_GROUPS_FAILURE');
    });

    it('should export all create message meta action types', () => {
      expect(CREATE_MESSAGE_META_REQUESTED).toBe('app/CommonTestAndPreview/CREATE_MESSAGE_META_REQUESTED');
      expect(CREATE_MESSAGE_META_SUCCESS).toBe('app/CommonTestAndPreview/CREATE_MESSAGE_META_SUCCESS');
      expect(CREATE_MESSAGE_META_FAILURE).toBe('app/CommonTestAndPreview/CREATE_MESSAGE_META_FAILURE');
    });

    it('should export all get prefilled values action types', () => {
      expect(GET_PREFILLED_VALUES_REQUESTED).toBe('app/CommonTestAndPreview/GET_PREFILLED_VALUES_REQUESTED');
      expect(GET_PREFILLED_VALUES_SUCCESS).toBe('app/CommonTestAndPreview/GET_PREFILLED_VALUES_SUCCESS');
      expect(GET_PREFILLED_VALUES_FAILURE).toBe('app/CommonTestAndPreview/GET_PREFILLED_VALUES_FAILURE');
    });

    it('should export all get sender details action types', () => {
      expect(GET_SENDER_DETAILS_REQUESTED).toBe('app/CommonTestAndPreview/GET_SENDER_DETAILS_REQUESTED');
      expect(GET_SENDER_DETAILS_SUCCESS).toBe('app/CommonTestAndPreview/GET_SENDER_DETAILS_SUCCESS');
      expect(GET_SENDER_DETAILS_FAILURE).toBe('app/CommonTestAndPreview/GET_SENDER_DETAILS_FAILURE');
    });

    it('should export all get wecrm accounts action types', () => {
      expect(GET_WECRM_ACCOUNTS_REQUESTED).toBe('app/CommonTestAndPreview/GET_WECRM_ACCOUNTS_REQUESTED');
      expect(GET_WECRM_ACCOUNTS_SUCCESS).toBe('app/CommonTestAndPreview/GET_WECRM_ACCOUNTS_SUCCESS');
      expect(GET_WECRM_ACCOUNTS_FAILURE).toBe('app/CommonTestAndPreview/GET_WECRM_ACCOUNTS_FAILURE');
    });

    it('should export all clear action types', () => {
      expect(CLEAR_CUSTOMER_SEARCH_STATE).toBe('app/CommonTestAndPreview/CLEAR_CUSTOMER_SEARCH_STATE');
      expect(CLEAR_SEARCH_RESULTS).toBe('app/CommonTestAndPreview/CLEAR_SEARCH_RESULTS');
      expect(CLEAR_PREFILLED_VALUES).toBe('app/CommonTestAndPreview/CLEAR_PREFILLED_VALUES');
      expect(CLEAR_PREVIEW_ERRORS).toBe('app/CommonTestAndPreview/CLEAR_PREVIEW_ERRORS');
    });
  });

  describe('Channel Constants', () => {
    it('should export CHANNELS object with all channel types', () => {
      expect(CHANNELS).toBeDefined();
      expect(CHANNELS.EMAIL).toBe('EMAIL');
      expect(CHANNELS.SMS).toBe('SMS');
      expect(CHANNELS.RCS).toBe('RCS');
      expect(CHANNELS.WHATSAPP).toBe('WHATSAPP');
      expect(CHANNELS.INAPP).toBe('INAPP');
      expect(CHANNELS.MOBILEPUSH).toBe('MOBILEPUSH');
      expect(CHANNELS.VIBER).toBe('VIBER');
      expect(CHANNELS.ZALO).toBe('ZALO');
      expect(CHANNELS.WEBPUSH).toBe('WEBPUSH');
    });

    it('should have all required channel keys', () => {
      const expectedChannels = ['EMAIL', 'SMS', 'RCS', 'WHATSAPP', 'INAPP', 'MOBILEPUSH', 'VIBER', 'ZALO', 'WEBPUSH'];
      expect(Object.keys(CHANNELS)).toEqual(expect.arrayContaining(expectedChannels));
      expect(Object.keys(CHANNELS).length).toBe(expectedChannels.length);
    });
  });

  describe('Device Constants', () => {
    it('should export all device constants with correct values', () => {
      expect(DESKTOP).toBe('desktop');
      expect(MOBILE).toBe('mobile');
      expect(TABLET).toBe('tablet');
      expect(ANDROID).toBe('android');
      expect(IOS).toBe('ios');
    });
  });

  describe('Module and Client Constants', () => {
    it('should export module and client constants', () => {
      expect(MODULE_CREATIVES).toBe('CREATIVES');
      expect(CLIENT_NAME_CREATIVES).toBe('CREATIVES');
    });
  });

  describe('API Channel Constants', () => {
    it('should export API channel push constant', () => {
      expect(API_CHANNEL_PUSH).toBe('PUSH');
    });
  });

  describe('Identifier Type Constants', () => {
    it('should export identifier type constants', () => {
      expect(IDENTIFIER_TYPE_EMAIL).toBe('email');
      expect(IDENTIFIER_TYPE_MOBILE).toBe('mobile');
      expect(IDENTIFIER_TYPE_PHONE).toBe('phone');
    });
  });

  describe('Validation Regex', () => {
    it('should export EMAIL_REGEX that validates email format', () => {
      expect(EMAIL_REGEX.test('user@example.com')).toBe(true);
      expect(EMAIL_REGEX.test('invalid')).toBe(false);
    });
    it('should export PHONE_REGEX that validates phone format', () => {
      expect(PHONE_REGEX.test('9123456789')).toBe(true);
      expect(PHONE_REGEX.test('123')).toBe(false);
    });
  });

  describe('Input has error class', () => {
    it('should export INPUT_HAS_ERROR_CLASS', () => {
      expect(INPUT_HAS_ERROR_CLASS).toBe(' has-input-error');
    });
  });

  describe('Channel Name Constants', () => {
    it('should export channel name constants', () => {
      expect(CHANNEL_NAME_INAPP).toBe('INAPP');
    });
  });

  describe('Channel Mapping Constants', () => {
    it('should export channel mapping constants', () => {
      expect(CHANNEL_MAPPING_EMAIL).toBe('email');
    });
  });

  describe('Media Type Constants', () => {
    it('should export all media type constants', () => {
      expect(MEDIA_TYPE_IMAGE).toBe('IMAGE');
      expect(MEDIA_TYPE_TEXT).toBe('TEXT');
      expect(MEDIA_TYPE_VIDEO).toBe('VIDEO');
      expect(MEDIA_TYPE_CAROUSEL).toBe('CAROUSEL');
      expect(MEDIA_TYPE_DOCUMENT).toBe('DOCUMENT');
    });
  });

  describe('Layout Type Constants', () => {
    it('should export all layout type constants', () => {
      expect(LAYOUT_TYPE_POPUP).toBe('POPUP');
      expect(LAYOUT_TYPE_FULLSCREEN).toBe('FULLSCREEN');
      expect(LAYOUT_TYPE_HEADER).toBe('HEADER');
      expect(LAYOUT_TYPE_FOOTER).toBe('FOOTER');
      expect(LAYOUT_TYPE_MODAL).toBe('MODAL');
      expect(LAYOUT_TYPE_BANNER).toBe('BANNER');
    });
  });

  describe('CTA Type Constants', () => {
    it('should export all CTA type constants', () => {
      expect(CTA_TYPE_DEEP_LINK).toBe('DEEP_LINK');
      expect(CTA_TYPE_EXTERNAL_URL).toBe('EXTERNAL_URL');
    });
  });

  describe('Style Type Constants', () => {
    it('should export all style type constants', () => {
      expect(STYLE_TYPE_BIG_PICTURE).toBe('BIG_PICTURE');
      expect(STYLE_TYPE_BIG_TEXT).toBe('BIG_TEXT');
    });
  });

  describe('Device Type Constants', () => {
    it('should export all device type constants', () => {
      expect(DEVICE_TYPE_ANDROID).toBe('ANDROID');
      expect(DEVICE_TYPE_IOS).toBe('IOS');
    });
  });

  describe('Button Type Constants', () => {
    it('should export all button type constants', () => {
      expect(BUTTON_TYPE_NONE).toBe('NONE');
      expect(BUTTON_TYPE_PHONE_NUMBER).toBe('PHONE_NUMBER');
      expect(BUTTON_TYPE_DYNAMIC_URL).toBe('DYNAMIC_URL');
    });
  });

  describe('Other Constants', () => {
    it('should export other constants', () => {
      expect(TEST).toBe('TEST');
      expect(ACTIVE).toBe('active');
    });
  });

  describe('Initial Payload', () => {
    it('should export INITIAL_PAYLOAD with correct structure', () => {
      expect(INITIAL_PAYLOAD).toBeDefined();
      expect(INITIAL_PAYLOAD).toHaveProperty('ouId');
      expect(INITIAL_PAYLOAD).toHaveProperty('sourceEntityId');
      expect(INITIAL_PAYLOAD).toHaveProperty('channel');
      expect(INITIAL_PAYLOAD).toHaveProperty('module');
      expect(INITIAL_PAYLOAD).toHaveProperty('clientName');
      expect(INITIAL_PAYLOAD).toHaveProperty('emailDeliverySettings');
    });

    it('should have correct initial values', () => {
      expect(INITIAL_PAYLOAD.ouId).toBe(-1);
      expect(INITIAL_PAYLOAD.channel).toBe('EMAIL');
      expect(INITIAL_PAYLOAD.module).toBe('CREATIVES');
      expect(INITIAL_PAYLOAD.clientName).toBe('CREATIVES');
    });

    it('should have emailDeliverySettings with correct structure', () => {
      expect(INITIAL_PAYLOAD.emailDeliverySettings).toHaveProperty('additionalSettings');
      expect(INITIAL_PAYLOAD.emailDeliverySettings).toHaveProperty('channelSettings');
      expect(INITIAL_PAYLOAD.emailDeliverySettings.additionalSettings).toHaveProperty('encryptUrl');
      expect(INITIAL_PAYLOAD.emailDeliverySettings.additionalSettings).toHaveProperty('linkTrackingEnabled');
      expect(INITIAL_PAYLOAD.emailDeliverySettings.additionalSettings).toHaveProperty('useTinyUrl');
      expect(INITIAL_PAYLOAD.emailDeliverySettings.additionalSettings).toHaveProperty('skipRateLimit');
      expect(INITIAL_PAYLOAD.emailDeliverySettings.additionalSettings).toHaveProperty('bypassControlUser');
    });

    it('should have channelSettings with correct structure', () => {
      expect(INITIAL_PAYLOAD.emailDeliverySettings.channelSettings).toHaveProperty('channel');
      expect(INITIAL_PAYLOAD.emailDeliverySettings.channelSettings).toHaveProperty('senderLabel');
      expect(INITIAL_PAYLOAD.emailDeliverySettings.channelSettings).toHaveProperty('senderId');
      expect(INITIAL_PAYLOAD.emailDeliverySettings.channelSettings).toHaveProperty('replyToId');
    });
  });
});
