import React from 'react';
import { shallowWithIntl } from '../../../helpers/intl-enzym-test-helpers';
import { SlideBoxContent } from '../SlideBoxContent';
import mockdata from '../../mockdata';
import { templateDetailsImage, templateDetailsVideo, templateDetailsText, templateDetails_ } from '../../Viber/tests/mockData';
import { CREATE, RICH_MEDIA } from '../../WeChat/Wrapper/constants';

const {
  whatsappEditTemplateData,
  whatsappPreviewTemplateData,
  rcsEditTemplateData,
  rcsPreviewTemplateData,
  linePreviewTemplateData1,
  linePreviewTemplateData2,
} = mockdata;

jest.mock('../../../v2Components/FormBuilder', () => ({
  __esModule: true,
  default: (props) => (
    <div className="FormBuilder-mock" {...props}>
      FormBuilder
    </div>
  ),
}));

jest.mock('../../WebPush/Create/preview/DevicePreviewContent', () => ({
  __esModule: true,
  default: (props) => (
    <div className="DevicePreviewContent-mock" {...props}>
      DevicePreviewContent
    </div>
  ),
}));

jest.mock('../../WebPush', () => ({
  __esModule: true,
  default: (props) => (
    <div className="WebPush-mock" {...props}>
      WebPush
    </div>
  ),
}));

jest.mock('v2Containers/InApp', () => () => <div data-test="inapp" />);
jest.mock('v2Containers/InAppWrapper', () => () => <div data-test="inapp-wrapper" />);

jest.mock('../../../utils/commonUtils', () => ({
  hasNewEditorFlowInAppEnabled: jest.fn(),
}));

import commonUtil from '../../../utils/commonUtils';

describe('Test SlideBoxContent container', () => {
  const onCreateComplete = jest.fn();
  let renderedComponent;
  let originalDate;

  beforeAll(() => {
    // Store the original Date
    originalDate = global.Date;
    // Mock Date to always return a fixed timestamp
    const fixedDate = new Date('2024-01-01T00:00:00.000Z');
    global.Date = class extends Date {
      constructor() {
        super();
        return fixedDate;
      }
      getMilliseconds() {
        return 123; // Fixed milliseconds value
      }
    };
  });

  afterAll(() => {
    // Restore the original Date
    global.Date = originalDate;
  });

  const renderFunction = (channel, mode, templateData, additionalProps = {}) => {
    renderedComponent = shallowWithIntl(
      <SlideBoxContent
        slidBoxContent={mode}
        currentChannel={channel}
        templateData={templateData}
        onCreateComplete={onCreateComplete}
        {...additionalProps}
      />,
    );
  };

  it('Should render correct component for whatsapp channel create mode', () => {
    renderFunction('WHATSAPP', 'createTemplate', { mode: 'create' });
    expect(renderedComponent).toMatchSnapshot();
  });

  it('Should render correct component for whatsapp channel create mode', () => {
    renderFunction('INAPP', 'createTemplate', { mode: 'create' });
    expect(renderedComponent).toMatchSnapshot();
  });

  it('Should render correct component for whatsapp channel edit mode', () => {
    renderFunction('WHATSAPP', 'editTemplate', whatsappEditTemplateData);
    expect(renderedComponent).toMatchSnapshot();
  });

  it('Should render correct component for whatsapp channel preview mode', () => {
    renderFunction('WHATSAPP', 'preview', whatsappPreviewTemplateData);
    expect(renderedComponent).toMatchSnapshot();
  });

  it('Should render correct component for whatsapp channel templates mode', () => {
    renderFunction('WHATSAPP', 'templates');
    expect(renderedComponent).toMatchSnapshot();
  });

  it('Should render correct component for rcs channel create mode', () => {
    renderFunction('RCS', 'createTemplate', { mode: 'create' });
    expect(renderedComponent).toMatchSnapshot();
  });

  it('Should render correct component for rcs channel edit mode', () => {
    renderFunction('RCs', 'editTemplate', rcsEditTemplateData);
    expect(renderedComponent).toMatchSnapshot();
  });

  it('Should render correct component for rcs channel preview mode', () => {
    renderFunction('RCS', 'preview', rcsPreviewTemplateData);
    expect(renderedComponent).toMatchSnapshot();
  });

  it('Should render correct component for rcs channel templates mode', () => {
    renderFunction('RCS', 'templates');
    expect(renderedComponent).toMatchSnapshot();
  });

  it('Should render correct component for line channel preview mode', () => {
    renderFunction('LINE', 'preview', linePreviewTemplateData1);
    expect(renderedComponent).toMatchSnapshot();
    renderFunction('LINE', 'preview', linePreviewTemplateData2);
    expect(renderedComponent).toMatchSnapshot();
    delete linePreviewTemplateData2.versions.base.content.messages[0].contents;
    renderFunction('LINE', 'preview', linePreviewTemplateData2);
    expect(renderedComponent).toMatchSnapshot();
  });
  it('Should render correct component for viber channel preview mode', () => {
    renderFunction('VIBER', 'preview', templateDetails_);
    expect(renderedComponent).toMatchSnapshot();
    renderFunction('VIBER', 'preview', templateDetailsImage);
    expect(renderedComponent).toMatchSnapshot();
    renderFunction('VIBER', 'preview', templateDetailsVideo);
    expect(renderedComponent).toMatchSnapshot();
    renderFunction('VIBER', 'preview', templateDetailsText);
    expect(renderedComponent).toMatchSnapshot();
  });

  it('Should render correctly with isTestAndPreviewMode enabled', () => {
    // Test with WhatsApp channel
    renderFunction('WHATSAPP', 'createTemplate', { mode: 'create' }, { isTestAndPreviewMode: true });
    expect(renderedComponent).toMatchSnapshot();

    // Test with Email channel
    renderFunction('EMAIL', 'createTemplate', { mode: 'create' }, { isTestAndPreviewMode: true });
    expect(renderedComponent).toMatchSnapshot();

    // Test with preview mode
    renderFunction('VIBER', 'preview', templateDetailsText, { isTestAndPreviewMode: true });
    expect(renderedComponent).toMatchSnapshot();
  });

  it('Should render correctly with isTestAndPreviewMode disabled', () => {
    // Test with WhatsApp channel
    renderFunction('WHATSAPP', 'createTemplate', { mode: 'create' }, { isTestAndPreviewMode: false });
    expect(renderedComponent).toMatchSnapshot();

    // Test with Email channel
    renderFunction('EMAIL', 'createTemplate', { mode: 'create' }, { isTestAndPreviewMode: false });
    expect(renderedComponent).toMatchSnapshot();

    // Test with preview mode
    renderFunction('VIBER', 'preview', templateDetailsText, { isTestAndPreviewMode: false });
    expect(renderedComponent).toMatchSnapshot();
  });

  it('Should handle isTestAndPreviewMode IIFE implementation correctly', () => {
    // Test the IIFE implementation with true value
    const wrapper = shallowWithIntl(
      <SlideBoxContent
        slidBoxContent="createTemplate"
        currentChannel="WHATSAPP"
        templateData={{ mode: 'create' }}
        onCreateComplete={onCreateComplete}
        isTestAndPreviewMode={(() => {
          return true;
        })()}
      />
    );
    expect(wrapper).toMatchSnapshot();

    // Test the IIFE implementation with false value
    const wrapper2 = shallowWithIntl(
      <SlideBoxContent
        slidBoxContent="createTemplate"
        currentChannel="WHATSAPP"
        templateData={{ mode: 'create' }}
        onCreateComplete={onCreateComplete}
        isTestAndPreviewMode={(() => {
          return false;
        })()}
      />
    );
    expect(wrapper2).toMatchSnapshot();
  });

  describe('getWechatTemplateType utility function', () => {
    it('Should return RICH_MEDIA when mode is not CREATE and msgcontent is RICH_MEDIA_WECHAT', () => {
      const templateData = {
        definition: {
          msgcontent: 'RICH_MEDIA_WECHAT'
        }
      };
      renderFunction('WECHAT', 'editTemplate', templateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should return MAP_TEMPLATE when mode is not CREATE and msgcontent is not RICH_MEDIA_WECHAT', () => {
      const templateData = {
        definition: {
          msgcontent: 'OTHER'
        }
      };
      renderFunction('WECHAT', 'editTemplate', templateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should return weChatTemplateType when mode is CREATE', () => {
      renderFunction('WECHAT', CREATE, null, { weChatTemplateType: RICH_MEDIA });
      expect(renderedComponent).toMatchSnapshot();
    });
  });

  describe('getLineType utility function', () => {
    it('Should handle LINE channel in create mode with full mode', () => {
      renderFunction('LINE', 'createTemplate', null, { isFullMode: true });
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should handle LINE channel in edit mode with full mode', () => {
      renderFunction('LINE', 'editTemplate', { type: 'LINE' }, { isFullMode: true });
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should handle LINE channel in non-full mode with template data', () => {
      const templateData = {
        isDefault: true,
        _id: '123',
        versions: {
          base: {
            content: {
              messages: [{ text: 'test' }]
            }
          }
        }
      };
      renderFunction('LINE', 'editTemplate', templateData, { isFullMode: false });
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should handle LINE channel in non-full mode with default template', () => {
      const templateData = {
        isDefault: true
      };
      renderFunction('LINE', 'createTemplate', templateData, { isFullMode: false });
      expect(renderedComponent).toMatchSnapshot();
    });
  });

  describe('getViber utility function', () => {
    it('Should handle VIBER channel in create mode', () => {
      renderFunction('VIBER', 'createTemplate', null);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should handle VIBER channel in edit mode', () => {
      renderFunction('VIBER', 'editTemplate', { type: 'VIBER' });
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should handle non-VIBER channel', () => {
      renderFunction('SMS', 'createTemplate', null);
      expect(renderedComponent).toMatchSnapshot();
    });
  });

  describe('Email component isTestAndPreviewMode IIFE', () => {
    const commonEmailProps = {
      editor: 'default',
      cap: {},
      showTemplateName: jest.fn(),
      onValidationFail: jest.fn(),
      moduleType: 'email',
      showLiquidErrorInFooter: false,
      eventContextTags: {},
      isLoyaltyModule: false,
      handleTestAndPreview: jest.fn(),
      handleCloseTestAndPreview: jest.fn()
    };

    it('Should handle isTestAndPreviewMode IIFE in Email edit mode with ID', () => {
      const emailTemplateData = {
        type: 'EMAIL',
        _id: '123',
        versions: {
          base: {
            content: {}
          }
        }
      };

      // Test with isTestAndPreviewMode true
      renderFunction('EMAIL', 'editTemplate', emailTemplateData, {
        ...commonEmailProps,
        isTestAndPreviewMode: true,
        showTestAndPreviewSlidebox: true
      });
      expect(renderedComponent).toMatchSnapshot();

      // Test with isTestAndPreviewMode false
      renderFunction('EMAIL', 'editTemplate', emailTemplateData, {
        ...commonEmailProps,
        isTestAndPreviewMode: false,
        showTestAndPreviewSlidebox: false
      });
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should handle isTestAndPreviewMode IIFE in Email edit mode without ID', () => {
      const emailTemplateData = {
        type: 'EMAIL',
        versions: {
          base: {
            content: {}
          }
        }
      };

      // Test with isTestAndPreviewMode true
      renderFunction('EMAIL', 'editTemplate', emailTemplateData, {
        ...commonEmailProps,
        isTestAndPreviewMode: true,
        showTestAndPreviewSlidebox: true
      });
      expect(renderedComponent).toMatchSnapshot();

      // Test with isTestAndPreviewMode false
      renderFunction('EMAIL', 'editTemplate', emailTemplateData, {
        ...commonEmailProps,
        isTestAndPreviewMode: false,
        showTestAndPreviewSlidebox: false
      });
      expect(renderedComponent).toMatchSnapshot();
    });
  });

  describe('getChannelPreviewContent utility function for LINE messages type detection', () => {
    it('Should detect text type in LINE messages', () => {
      const templateData = {
        type: 'LINE',
        versions: {
          base: {
            content: {
              messages: [{
                text: 'Hello World'
              }]
            }
          }
        }
      };
      renderFunction('LINE', 'preview', templateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should detect image type in LINE messages', () => {
      const templateData = {
        type: 'LINE',
        versions: {
          base: {
            content: {
              messages: [{
                previewImageUrl: 'image.jpg'
              }]
            }
          }
        }
      };
      renderFunction('LINE', 'preview', templateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should detect sticker type in LINE messages', () => {
      const templateData = {
        type: 'LINE',
        versions: {
          base: {
            content: {
              messages: [{
                selectedSticker: {
                  stickerUrl: 'sticker.jpg',
                  stickerId: '123',
                  packageId: '456'
                }
              }]
            }
          }
        }
      };
      renderFunction('LINE', 'preview', templateData);
      expect(renderedComponent).toMatchSnapshot();

      // Test with just stickerUrl
      const templateData2 = {
        type: 'LINE',
        versions: {
          base: {
            content: {
              messages: [{
                stickerUrl: 'sticker.jpg'
              }]
            }
          }
        }
      };
      renderFunction('LINE', 'preview', templateData2);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should detect imagemap type in LINE messages', () => {
      const templateData = {
        type: 'LINE',
        versions: {
          base: {
            content: {
              messages: [{
                baseUrl: 'base.jpg'
              }]
            }
          }
        }
      };
      renderFunction('LINE', 'preview', templateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should detect video type in LINE messages', () => {
      const templateData = {
        type: 'LINE',
        versions: {
          base: {
            content: {
              messages: [{
                video: {
                  originalContentUrl: 'video.mp4',
                  externalLink: {
                    linkUri: 'example.com'
                  }
                }
              }]
            }
          }
        }
      };
      renderFunction('LINE', 'preview', templateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should detect image_carousel type in LINE messages with template', () => {
      const templateData = {
        type: 'LINE',
        versions: {
          base: {
            content: {
              messages: [{
                template: {}
              }]
            }
          }
        }
      };
      renderFunction('LINE', 'preview', templateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should detect image_carousel type in LINE messages with contents', () => {
      const templateData = {
        type: 'LINE',
        versions: {
          base: {
            content: {
              messages: [{
                contents: {}
              }]
            }
          }
        }
      };
      renderFunction('LINE', 'preview', templateData);
      expect(renderedComponent).toMatchSnapshot();
    });
  });

  describe('getChannelPreviewContent utility function', () => {
    it('Should handle SMS channel preview content with DLT enabled', () => {
      const templateData = {
        type: 'SMS',
        versions: {
          base: {
            'updated-sms-editor': ['Hello', 'World']
          }
        }
      };
      renderFunction('SMS', 'preview', templateData, { smsRegister: true, isFullMode: true });
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should handle SMS channel preview content without DLT', () => {
      const templateData = {
        type: 'SMS',
        versions: {
          base: {
            'sms-editor': 'Hello World'
          }
        }
      };
      renderFunction('SMS', 'preview', templateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should handle LINE channel preview content with flex type', () => {
      const templateData = {
        type: 'LINE',
        versions: {
          base: {
            content: {
              messages: [{
                type: 'flex',
                contents: {
                  contents: [{
                    hero: { url: 'image.jpg' },
                    footer: { contents: [{ action: { label: 'Click' } }] }
                  }]
                }
              }]
            }
          }
        }
      };
      renderFunction('LINE', 'preview', templateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should handle LINE channel preview content with template type', () => {
      const templateData = {
        type: 'LINE',
        versions: {
          base: {
            content: {
              messages: [{
                template: {
                  columns: [{
                    imageUrl: 'image.jpg',
                    action: { label: 'Click' }
                  }]
                }
              }]
            }
          }
        }
      };
      renderFunction('LINE', 'preview', templateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should handle FACEBOOK channel preview content', () => {
      const templateData = {
        type: 'FACEBOOK',
        versions: {
          base: {
            content: {
              FacebookAd: [{
                type: 'image',
                primaryText: 'Hello',
                callToAction: 'Click',
                displayLink: 'example.com',
                imgSrc: 'image.jpg',
                linkDesc: 'Description',
                linkHeadLine: 'Headline',
                subType: 'single',
                webSiteLink: 'example.com'
              }],
              pageOrgUnitId: '123'
            }
          }
        }
      };
      const campaignSettings = {
        accountSettings: {
          socialAccountSettings: {
            facebookAccountSettings: [{
              accountId: '123',
              employeeAccessToken: 'token',
              orgUnitFacebookPageSettingsMap: {
                '123': {
                  pageAccessToken: 'page-token',
                  pageId: 'page-123'
                }
              }
            }]
          }
        }
      };
      renderFunction('FACEBOOK', 'preview', templateData, { campaignSettings });
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should handle VIBER channel preview content with all content types', () => {
      const templateData = {
        type: 'VIBER',
        versions: {
          base: {
            content: {
              content: {
                text: 'Hello World',
                button: {
                  text: 'Click Me'
                },
                image: {
                  url: 'image.jpg'
                },
                video: {
                  url: 'video.mp4',
                  thumbnailUrl: 'thumbnail.jpg'
                }
              }
            }
          }
        }
      };
      renderFunction('VIBER', 'preview', templateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should handle VIBER channel preview content with only text', () => {
      const templateData = {
        type: 'VIBER',
        versions: {
          base: {
            content: {
              content: {
                text: 'Hello World'
              }
            }
          }
        }
      };
      renderFunction('VIBER', 'preview', templateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should handle VIBER channel preview content with only image', () => {
      const templateData = {
        type: 'VIBER',
        versions: {
          base: {
            content: {
              content: {
                image: {
                  url: 'image.jpg'
                }
              }
            }
          }
        }
      };
      renderFunction('VIBER', 'preview', templateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should handle VIBER channel preview content with only video', () => {
      const templateData = {
        type: 'VIBER',
        versions: {
          base: {
            content: {
              content: {
                video: {
                  url: 'video.mp4',
                  thumbnailUrl: 'thumbnail.jpg'
                }
              }
            }
          }
        }
      };
      renderFunction('VIBER', 'preview', templateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should handle RCS channel preview content', () => {
      const templateData = {
        type: 'RCS',
        versions: {
          base: {
            content: {
              RCS: {
                cardContent: [{
                  description: 'Description',
                  media: { mediaUrl: 'image.jpg' },
                  title: 'Title',
                  suggestions: [{ text: 'Click' }]
                }]
              }
            }
          }
        }
      };
      renderFunction('RCS', 'preview', templateData);
      expect(renderedComponent).toMatchSnapshot();
    });
  });

  describe('WebPush channel functionality', () => {
    it('Should render correct component for webpush channel create mode', () => {
      renderFunction('WEBPUSH', 'createTemplate', { mode: 'create' });
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should render correct component for webpush channel edit mode', () => {
      const webpushEditTemplateData = {
        type: 'WEBPUSH',
        _id: '123',
        versions: {
          base: {
            content: {
              webpush: {
                title: 'Test Title',
                message: 'Test Message',
              }
            }
          }
        }
      };
      renderFunction('WEBPUSH', 'editTemplate', webpushEditTemplateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should render correct component for webpush channel preview mode with all fields', () => {
      const webpushPreviewTemplateData = {
        type: 'WEBPUSH',
        versions: {
          base: {
            content: {
              webpush: {
                title: 'Test Notification Title',
                message: 'Test notification body text',
                image: 'https://example.com/image.jpg',
                brandIcon: 'https://example.com/brand-icon.png',
                onClickAction: {
                  url: 'https://example.com'
                }
              }
            }
          }
        }
      };
      renderFunction('WEBPUSH', 'preview', webpushPreviewTemplateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should render correct component for webpush channel preview mode with minimal fields', () => {
      const webpushPreviewTemplateData = {
        type: 'WEBPUSH',
        versions: {
          base: {
            content: {
              webpush: {
                title: 'Test Title',
                message: 'Test Message'
              }
            }
          }
        }
      };
      renderFunction('WEBPUSH', 'preview', webpushPreviewTemplateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should render correct component for webpush channel preview mode with empty fields', () => {
      const webpushPreviewTemplateData = {
        type: 'WEBPUSH',
        versions: {
          base: {
            content: {
              webpush: {}
            }
          }
        }
      };
      renderFunction('WEBPUSH', 'preview', webpushPreviewTemplateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should render correct component for webpush channel preview mode with missing onClickAction url', () => {
      const webpushPreviewTemplateData = {
        type: 'WEBPUSH',
        versions: {
          base: {
            content: {
              webpush: {
                title: 'Test Title',
                message: 'Test Message',
                onClickAction: {}
              }
            }
          }
        }
      };
      renderFunction('WEBPUSH', 'preview', webpushPreviewTemplateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should render correct component for webpush channel preview mode with null onClickAction', () => {
      const webpushPreviewTemplateData = {
        type: 'WEBPUSH',
        versions: {
          base: {
            content: {
              webpush: {
                title: 'Test Title',
                message: 'Test Message',
                onClickAction: null
              }
            }
          }
        }
      };
      renderFunction('WEBPUSH', 'preview', webpushPreviewTemplateData);
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should handle supportedTags prop in webpush create mode', () => {
      renderFunction('WEBPUSH', 'createTemplate', { mode: 'create' }, { 
        supportedTags: ['tag1', 'tag2'] 
      });
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should handle supportedTags prop in webpush edit mode', () => {
      const webpushEditTemplateData = {
        type: 'WEBPUSH',
        _id: '123',
        versions: {
          base: {
            content: {
              webpush: {
                title: 'Test Title',
                message: 'Test Message',
              }
            }
          }
        }
      };
      renderFunction('WEBPUSH', 'editTemplate', webpushEditTemplateData, { 
        supportedTags: ['tag1', 'tag2'] 
      });
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should handle webpush create mode with all props', () => {
      renderFunction('WEBPUSH', 'createTemplate', { mode: 'create' }, {
        isFullMode: true,
        handleClose: jest.fn(),
        onCreateComplete: jest.fn(),
        creativesMode: 'test',
        getDefaultTags: 'outbound',
        forwardedTags: {},
        supportedTags: ['tag1'],
        selectedOfferDetails: [],
        eventContextTags: {}
      });
      expect(renderedComponent).toMatchSnapshot();
    });

    it('Should handle webpush edit mode with all props', () => {
      const webpushEditTemplateData = {
        type: 'WEBPUSH',
        _id: '123',
        versions: {
          base: {
            content: {
              webpush: {
                title: 'Test Title',
                message: 'Test Message',
              }
            }
          }
        }
      };
      renderFunction('WEBPUSH', 'editTemplate', webpushEditTemplateData, {
        isFullMode: true,
        handleClose: jest.fn(),
        onCreateComplete: jest.fn(),
        creativesMode: 'test',
        getDefaultTags: 'outbound',
        forwardedTags: {},
        supportedTags: ['tag1'],
        selectedOfferDetails: [],
        eventContextTags: {}
      });
      expect(renderedComponent).toMatchSnapshot();
    });
  });

  describe('InApp vs InAppWrapper rendering conditions', () => {

    beforeEach(() => {
      jest.clearAllMocks();
    });

    it('renders InAppWrapper when isFullMode=true and new editor disabled', () => {
      commonUtil.hasNewEditorFlowInAppEnabled.mockReturnValue(false);

      renderFunction(
        'INAPP',
        'createTemplate',
        { mode: 'create' },
        { isFullMode: true, isLoyaltyModule: false }
      );

      expect(renderedComponent).toMatchSnapshot();
    });

    it('renders InApp when isFullMode=false and loyalty module enabled', () => {
      commonUtil.hasNewEditorFlowInAppEnabled.mockReturnValue(false);

      renderFunction(
        'INAPP',
        'createTemplate',
        { mode: 'create' },
        { isFullMode: false, isLoyaltyModule: true }
      );

      expect(renderedComponent).toMatchSnapshot();
    });

    it('renders InApp when not full mode, not loyalty and new editor disabled', () => {
      commonUtil.hasNewEditorFlowInAppEnabled.mockReturnValue(false);

      renderFunction(
        'INAPP',
        'createTemplate',
        { mode: 'create' },
        { isFullMode: false, isLoyaltyModule: false }
      );

      expect(renderedComponent).toMatchSnapshot();
    });

    it('renders InAppWrapper when full mode and new editor enabled', () => {
      commonUtil.hasNewEditorFlowInAppEnabled.mockReturnValue(true);

      renderFunction(
        'INAPP',
        'createTemplate',
        { mode: 'create' },
        { isFullMode: true, isLoyaltyModule: false }
      );

      expect(renderedComponent).toMatchSnapshot();
    });

  });
});
