text: import 'regenerator-runtime';
  import { mount } from '@vue/test-utils';
  import ticketing_index from '../../../Pages/Onboarding/Ticketing/Index';
  import Vuex from 'vuex';
  import { createWebHistory, createRouter } from 'vue-router';
  import storeConfig from '../../Admin/store-config';
  import axios from 'axios';
  import MockAdapter from 'axios-mock-adapter';
  import routes from "../../../Router/routes";
  
  describe('actions', () => {
      let http;
      let store;
  
      beforeAll(() => {
          http = new MockAdapter(axios);
          store = new Vuex.Store(storeConfig);
      });
  
      afterEach(() => {
          http.reset();
      });
  
      afterAll(() => {
          http.restore();
      });
  
      it('btn disabled while no answer picked available after picked', async () => {
          const router = createRouter({
              history: createWebHistory(),
              routes
          });
          const wrapper = mount(ticketing_index, {
              global: {
                  plugins: [store, router],
              },
              data() {
                  return {
                      ticketing_solutions: [
                          {
                              type: 'plot',
                              name: 'Yes Please, I want to use Plot Ticketing',
                              answers: [
                                  {
                                      type: 'generic',
                                      answer: 'General Admission and Day Tickets'
                                  },
                                  {
                                      type: 'individual',
                                      answer: 'Individually ticketed events'
                                  }
                              ]
                          },
                          {
                              type: 'external',
                              name: 'No thanks, we are using a 3rd Party platform',
                          }
                      ],
                      form: {
                          solution_chosen: '',
                          answerType: '',
                          ticketLink: ''
                      }
                  }
              }
          });
  
          await wrapper.setData({
              form: {
                  solution_chosen: ''
              }
          });
  
          let btn = wrapper.findAll('.btn');
          expect(btn[1].classes('disabled')).toBe(true);
  
  
          await wrapper.setData({
              form: {
                  solution_chosen: 'plot'
              }
          });
  
          btn = wrapper.findAll('.btn');
          expect(btn[1].classes('disabled')).toBe(false);
      });
  
      it('plot ticketing show answer types', async () => {
          const router = createRouter({
              history: createWebHistory(),
              routes
          });
          const wrapper = mount(ticketing_index, {
              global: {
                  plugins: [store, router],
              },
              data() {
                  return {
                      ticketing_solutions: [
                          {
                              type: 'plot',
                              name: 'Yes Please, I want to use Plot Ticketing',
                              answers: [
                                  {
                                      type: 'generic',
                                      answer: 'General Admission and Day Tickets'
                                  },
                                  {
                                      type: 'individual',
                                      answer: 'Individually ticketed events'
                                  }
                              ]
                          },
                          {
                              type: 'external',
                              name: 'No thanks, we are using a 3rd Party platform',
                          }
                      ],
                      form: {
                          solution_chosen: '',
                          answerType: '',
                          ticketLink: ''
                      }
                  }
              }
          });
  
          await wrapper.setData({
              form: {
                  solution_chosen: 'plot'
              }
          });
  
          const form = wrapper.find('.plot-form');
          const answer_types_message = form.find('.font-regular-lg');
          expect(answer_types_message.text()).toBe('Great News! How will you sell ticket to the event?');
      });
  
      it('third party ticketing show url input', async () => {
          const router = createRouter({
              history: createWebHistory(),
              routes
          });
          const wrapper = mount(ticketing_index, {
              global: {
                  plugins: [store, router],
              },
              data() {
                  return {
                      ticketing_solutions: [
                          {
                              type: 'plot',
                              name: 'Yes Please, I want to use Plot Ticketing',
                              answers: [
                                  {
                                      type: 'generic',
                                      answer: 'General Admission and Day Tickets'
                                  },
                                  {
                                      type: 'individual',
                                      answer: 'Individually ticketed events'
                                  }
                              ]
                          },
                          {
                              type: 'external',
                              name: 'No thanks, we are using a 3rd Party platform',
                          }
                      ],
                      form: {
                          solution_chosen: '',
                          answerType: '',
                          ticketLink: ''
                      }
                  }
              }
          });
  
          await wrapper.setData({
              form: {
                  solution_chosen: 'external'
              }
          });
  
          const form = wrapper.find('.plot-form');
          const answer_types_message = form.find('.font-regular-lg');
          expect(answer_types_message.text()).toBe('Add your ticketing link if you have one.');
      });
  
      it('url is link validation', async () => {
          const router = createRouter({
              history: createWebHistory(),
              routes
          });
          const wrapper = mount(ticketing_index, {
              global: {
                  plugins: [store, router],
              },
              data() {
                  return {
                      ticketing_solutions: [
                          {
                              type: 'plot',
                              name: 'Yes Please, I want to use Plot Ticketing',
                              answers: [
                                  {
                                      type: 'generic',
                                      answer: 'General Admission and Day Tickets'
                                  },
                                  {
                                      type: 'individual',
                                      answer: 'Individually ticketed events'
                                  }
                              ]
                          },
                          {
                              type: 'external',
                              name: 'No thanks, we are using a 3rd Party platform',
                          }
                      ],
                      form: {
                          solution_chosen: 'external',
                          answerType: 'asdasd',
                          ticketLink: ''
                      }
                  }
              }
          });
  
          const responseData = {
              status: 'error',
              messages: {
                  ticketLink: ['Please enter a valid url. For example: https://www.example.com']
              }
          };
  
          http.onPost('/api/ticketing-type/update').reply(400, {data: responseData});
  
          await wrapper.setData({
              errors: {
                  ticketLink: responseData.messages.ticketLink
              }
          });
  
          const error = wrapper.find('.plot-form__input-error');
          const errorspan = wrapper.find('span.plot-form__input-helper--error');
  
          expect(error.exists()).toBe(true);
          expect(errorspan.text()).toBe(responseData['messages']['ticketLink'][0]);
      });
  });