Sha256: 446f19a1cb2f21b0dbfa8bdedf616604730de18de8477d4b040a7e42fe771687

Contents?: true

Size: 1.66 KB

Versions: 79

Compression:

Stored size: 1.66 KB

Contents

import React from 'react';
import { IntegrationTestHelper } from '@theforeman/test';
import * as API from 'foremanReact/redux/API';
import { noop } from 'foremanReact/common/helpers';
import SyncButton from '../index';
import { successResponse } from './SyncButtonFixtures';
import {
  INVENTORY_SYNC,
  INVENTORY_SYNC_TASK_UPDATE,
} from '../SyncButtonConstants';

jest.spyOn(API, 'post');
jest.spyOn(API, 'get');

describe('SyncButton integration test', () => {
  it('Successful task was triggered on the server resulting in an info toast and polling on the task', async () => {
    API.post.mockImplementation(({ handleSuccess = noop, key, ...action }) => {
      if (key === INVENTORY_SYNC) {
        handleSuccess(successResponse);
      }
      return { type: 'API_POST', ...action };
    });
    API.get.mockImplementation(({ handleSuccess = noop, key, ...action }) => {
      if (key === INVENTORY_SYNC_TASK_UPDATE) {
        handleSuccess(
          {
            data: {
              endedAt: '2021-03-22T15:59:02.468+02:00',
              output: {
                host_statuses: {
                  sync: 0,
                  disconnect: 2,
                },
              },
              result: 'success',
            },
          },
          jest.fn
        );
      }
      return { type: 'API_GET', ...action };
    });

    const integrationTestHelper = new IntegrationTestHelper();
    const wrapper = integrationTestHelper.mount(<SyncButton />);
    const instance = wrapper.find('SyncButton').instance();
    instance.props.handleSync();
    await IntegrationTestHelper.flushAllPromises();
    integrationTestHelper.takeActionsSnapshot('handleSync was called');
  });
});

Version data entries

79 entries across 79 versions & 1 rubygems

Version Path
foreman_rh_cloud-4.0.27 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-3.0.26 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-4.0.26 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-4.0.25.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-3.0.25 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-4.0.25 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-3.0.24.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-4.0.24.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-3.0.24 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-4.0.24 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-3.0.23 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-4.0.23 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-3.0.22 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-4.0.22 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-4.0.21.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-3.0.21.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-3.0.21 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-3.0.20 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-3.0.19 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js