Sha256: f9009c291a559b2027b6ba733b6e0a4487def5205f2233cca7f2d8ab714e39db

Contents?: true

Size: 1.67 KB

Versions: 20

Compression:

Stored size: 1.67 KB

Contents

import React from 'react';
import { Provider } from 'react-redux';
import { fireEvent, screen, render, act } from '@testing-library/react';
import { MockedProvider } from '@apollo/client/testing';
import * as api from 'foremanReact/redux/API';
import { JobWizard } from '../../../JobWizard';
import * as selectors from '../../../JobWizardSelectors';
import { testSetup, mockApi, gqlMock } from '../../../__tests__/fixtures';
import { WIZARD_TITLES } from '../../../JobWizardConstants';

const store = testSetup(selectors, api);
mockApi(api);

describe('TemplateInputs', () => {
  it('should save data between steps for template input fields', async () => {
    render(
      <MockedProvider mocks={gqlMock} addTypename={false}>
        <Provider store={store}>
          <JobWizard />
        </Provider>
      </MockedProvider>
    );
    await act(async () => {
      fireEvent.click(screen.getByText(WIZARD_TITLES.hostsAndInputs));
    });
    const textValue = 'I am a plain text';
    const textField = screen.getByLabelText('plain hidden', {
      selector: 'textarea',
    });

    await act(async () => {
      await fireEvent.change(textField, {
        target: { value: textValue },
      });
    });
    expect(
      screen.getByLabelText('plain hidden', {
        selector: 'textarea',
      }).value
    ).toBe(textValue);
    await act(async () => {
      fireEvent.click(screen.getByText(WIZARD_TITLES.categoryAndTemplate));
    });
    expect(screen.getAllByText(WIZARD_TITLES.categoryAndTemplate)).toHaveLength(
      3
    );

    await act(async () => {
      fireEvent.click(screen.getByText(WIZARD_TITLES.hostsAndInputs));
    });
    expect(textField.value).toBe(textValue);
  });
});

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
foreman_remote_execution-7.2.2 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
foreman_remote_execution-7.2.1 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
foreman_remote_execution-7.2.0 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
foreman_remote_execution-5.0.8 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
foreman_remote_execution-8.0.0 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
foreman_remote_execution-7.1.1 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
foreman_remote_execution-7.1.0 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
foreman_remote_execution-7.0.0 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
foreman_remote_execution-5.0.7 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
foreman_remote_execution-5.0.6 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
foreman_remote_execution-6.2.0 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
foreman_remote_execution-5.0.5 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
foreman_remote_execution-6.1.0 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
foreman_remote_execution-5.0.4 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
foreman_remote_execution-5.0.3 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
foreman_remote_execution-6.0.0 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
foreman_remote_execution-5.0.2 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
foreman_remote_execution-5.1.0 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
foreman_remote_execution-5.0.1 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js
foreman_remote_execution-5.0.0 webpack/JobWizard/steps/HostsAndInputs/__tests__/TemplateInputs.test.js