Sha256: ebadfb8d71d5a0dfa89c9961badfe426912b0bfa0f6b87dc0af089e236a9e1b5

Contents?: true

Size: 1.91 KB

Versions: 20

Compression:

Stored size: 1.91 KB

Contents

import React from 'react';
import { renderWithRedux, patientlyWaitFor, fireEvent } from 'react-testing-lib-wrapper';


import api from '../../../../../../services/api';
import CVFilterAddModal from '../CVFilterAddModal';
import { nockInstance, assertNockRequest } from '../../../../../../test-utils/nockWrapper';
import cvCreateData from './cvFilterCreateResult.fixtures.json';

const cvCreateFilterPath = api.getApiUrl('/content_view_filters?content_view_id=5');

const setIsOpen = jest.fn();

const createDetails = {
  name: 'test',
  description: 'Creating filter',
  inclusion: true,
  type: 'rpm',
};

const createdCVDetails = { ...cvCreateData };

const form = <CVFilterAddModal cvId={5} show setIsOpen={setIsOpen} />;

test('Can save content view filter from form', (done) => {
  const createFilterscope = nockInstance
    .post(cvCreateFilterPath, createDetails)
    .reply(201, createdCVDetails);
  const { queryByText, getByLabelText } = renderWithRedux(form);
  expect(queryByText('Description')).toBeInTheDocument();

  fireEvent.change(getByLabelText('input_name'), { target: { value: 'test' } });
  fireEvent.change(getByLabelText('input_description'), { target: { value: 'Creating filter' } });

  fireEvent.submit(getByLabelText('create_filter'));
  assertNockRequest(createFilterscope, done);
});

test('Closes content view filter form upon save', async (done) => {
  const createFilterscope = nockInstance
    .post(cvCreateFilterPath, createDetails)
    .reply(201, createdCVDetails);
  const { queryByText, getByLabelText } = renderWithRedux(form);
  fireEvent.change(getByLabelText('input_name'), { target: { value: 'test' } });
  fireEvent.change(getByLabelText('input_description'), { target: { value: 'Creating filter' } });

  fireEvent.submit(getByLabelText('create_filter'));
  await patientlyWaitFor(() => {
    expect(queryByText('Description')).not.toBeInTheDocument();
  });

  assertNockRequest(createFilterscope, done);
});

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
katello-4.4.2.2 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js
katello-4.4.2.1 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js
katello-4.4.2 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js
katello-4.5.1 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js
katello-4.5.0 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js
katello-4.5.0.rc2 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js
katello-4.4.1 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js
katello-4.5.0.rc1 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js
katello-4.4.0.2 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js
katello-4.4.0.1 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js
katello-4.3.1 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js
katello-4.4.0 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js
katello-4.4.0.rc2 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js
katello-4.4.0.rc1 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js
katello-4.3.0 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js
katello-4.3.0.rc4 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js
katello-4.3.0.rc3 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js
katello-4.3.0.rc2.1 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js
katello-4.3.0.rc2 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js
katello-4.3.0.rc1 webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js