import * as React from 'react';
import { beforeEach, describe, it } from 'vitest';
import { AppState } from '../../Enums/AppState';
import { FAST_BOOT } from '../../utils/default';
import { fireEvent, render, RenderResult } from '../../utils/test-utils';
import { App } from './App';

describe.concurrent('App', () => {
  let app: RenderResult;

  beforeEach(() => {
    app = render(
      <App root={document} />
    );
  });

  it('New editor', async() => {
    if (FAST_BOOT !== AppState.MainMenu) {
      return;
    }

    const start = app.getByText(/Start from scratch/i);
    fireEvent.click(start);
  }, 10000);

  it('Load editor by file', () => {
    if (FAST_BOOT !== AppState.MainMenu) {
      return;
    }

    const load = app.getByText(/Load a configuration file/i);
    fireEvent.click(load);

    const goBack = app.getByText(/Go back/i);
    fireEvent.click(goBack);

    const load2 = app.getByText(/Load a configuration file/i);
    fireEvent.click(load2);

    app.getByText(/Import Save/i);
    document.querySelector('input[type="file"]') as HTMLInputElement;
  });
});
