Skip to content

Commit

Permalink
test management test
Browse files Browse the repository at this point in the history
  • Loading branch information
evmiguel committed May 3, 2023
1 parent d0872ad commit b132f1c
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions client/tests/TestManagement.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* @jest-environment jsdom
*/

import React from 'react';
import { render, waitFor } from '@testing-library/react';
import { InMemoryCache } from '@apollo/client';
import { MockedProvider } from '@apollo/client/testing';
import { BrowserRouter } from 'react-router-dom';
import '@testing-library/jest-dom/extend-expect';

import TestManagement from '../components/TestManagement';

// eslint-disable-next-line jest/no-mocks-import
import { TEST_MANAGEMENT_PAGE_POPULATED } from './__mocks__/GraphQLMocks';

const setup = (mocks = []) => {
return render(
<BrowserRouter>
<MockedProvider
mocks={mocks}
cache={new InMemoryCache({ addTypename: false })}
>
<TestManagement />
</MockedProvider>
</BrowserRouter>
);
};

describe('Test Management page', () => {
let wrapper;

beforeEach(() => {
wrapper = setup(TEST_MANAGEMENT_PAGE_POPULATED);
});

it('renders loading state on initialization', async () => {
const { getByTestId } = wrapper;
const element = getByTestId('page-status');

expect(element).toBeTruthy();
expect(element).toHaveTextContent('Loading');
});

it('renders Status Summary component', async () => {
// allow page time to load
await waitFor(() => new Promise(res => setTimeout(res, 0)));

const { queryAllByText } = wrapper;
const statusSummaryElement = queryAllByText(/Status Summary/i);
const testPlansElement = queryAllByText(/Test Plans/i);
const phaseElement = queryAllByText(/Phase/i);
const candidateElements = queryAllByText(/Candidate/i);
const notTestedElements = queryAllByText(/Not tested/i);

expect(statusSummaryElement.length).toBeGreaterThanOrEqual(1);
expect(testPlansElement.length).toBeGreaterThanOrEqual(1);
expect(phaseElement.length).toBeGreaterThanOrEqual(1);
expect(candidateElements.length).toBeGreaterThanOrEqual(1);
expect(notTestedElements.length).toBeGreaterThanOrEqual(1);
});
});

0 comments on commit b132f1c

Please sign in to comment.