Skip to content

Commit

Permalink
Removed all ignore statements
Browse files Browse the repository at this point in the history
  • Loading branch information
arpit-chakraborty committed Jan 18, 2025
1 parent 17396b3 commit cc67bcb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
35 changes: 21 additions & 14 deletions src/screens/OrganizationTags/OrganizationTags.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,10 @@ describe('Organisation Tags Page', () => {
};
});
});

afterEach(() => {
vi.clearAllMocks();
cleanup();
});

test('component loads correctly', async () => {
const { getByText } = renderOrganizationTags(link);

Expand All @@ -113,7 +111,6 @@ describe('Organisation Tags Page', () => {
expect(getByText(translations.createTag)).toBeInTheDocument();
});
});

test('render error component on unsuccessful userTags query', async () => {
const { queryByText } = renderOrganizationTags(link2);

Expand All @@ -123,7 +120,6 @@ describe('Organisation Tags Page', () => {
expect(queryByText(translations.createTag)).not.toBeInTheDocument();
});
});

test('opens and closes the create tag modal', async () => {
renderOrganizationTags(link);

Expand Down Expand Up @@ -159,7 +155,6 @@ describe('Organisation Tags Page', () => {
expect(screen.getByTestId('subTagsScreen')).toBeInTheDocument();
});
});

test('navigates to manage tag page after clicking manage tag option', async () => {
renderOrganizationTags(link);

Expand All @@ -174,7 +169,6 @@ describe('Organisation Tags Page', () => {
expect(screen.getByTestId('manageTagScreen')).toBeInTheDocument();
});
});

test('searchs for tags where the name matches the provided search input', async () => {
renderOrganizationTags(link);

Expand All @@ -195,7 +189,6 @@ describe('Organisation Tags Page', () => {
expect(buttons.length).toEqual(2);
});
});

test('fetches the tags by the sort order, i.e. latest or oldest first', async () => {
renderOrganizationTags(link);

Expand Down Expand Up @@ -252,7 +245,6 @@ describe('Organisation Tags Page', () => {
);
});
});

test('fetches more tags with infinite scroll', async () => {
const { getByText } = renderOrganizationTags(link);

Expand Down Expand Up @@ -281,7 +273,6 @@ describe('Organisation Tags Page', () => {
expect(getByText(translations.createTag)).toBeInTheDocument();
});
});

test('creates a new user tag', async () => {
renderOrganizationTags(link);

Expand Down Expand Up @@ -311,7 +302,6 @@ describe('Organisation Tags Page', () => {
);
});
});

test('creates a new user tag with error', async () => {
renderOrganizationTags(link3);

Expand All @@ -330,7 +320,6 @@ describe('Organisation Tags Page', () => {
expect(toast.error).toHaveBeenCalledWith('Mock Graphql Error');
});
});

test('renders the no tags found message when there are no tags', async () => {
renderOrganizationTags(link4);

Expand All @@ -340,7 +329,6 @@ describe('Organisation Tags Page', () => {
expect(screen.getByText(translations.noTagsFound)).toBeInTheDocument();
});
});

test('sets dataLength to 0 when userTagsList is undefined', async () => {
renderOrganizationTags(link5);

Expand All @@ -352,7 +340,6 @@ describe('Organisation Tags Page', () => {
expect(userTags).toHaveLength(0);
});
});

test('Null endCursor', async () => {
renderOrganizationTags(link6);

Expand All @@ -371,7 +358,6 @@ describe('Organisation Tags Page', () => {
expect(screen.getByTestId('createTagBtn')).toBeInTheDocument();
});
});

test('Null Page available', async () => {
renderOrganizationTags(link7);

Expand All @@ -390,4 +376,25 @@ describe('Organisation Tags Page', () => {
expect(screen.getByTestId('createTagBtn')).toBeInTheDocument();
});
});
test('creates a new user tag with undefined data', async () => {
renderOrganizationTags(link);

await wait();

await waitFor(() => {
expect(screen.getByTestId('createTagBtn')).toBeInTheDocument();
});
userEvent.click(screen.getByTestId('createTagBtn'));

userEvent.type(
screen.getByPlaceholderText(translations.tagNamePlaceholder),
'userTag 13',
);

userEvent.click(screen.getByTestId('createTagSubmitBtn'));

await waitFor(() => {
expect(toast.error).toHaveBeenCalledWith('Tag creation failed');
});
});
});
8 changes: 3 additions & 5 deletions src/screens/OrganizationTags/OrganizationTags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,16 @@ function OrganizationTags(): JSX.Element {
organizationId: orgId,
},
});
/* istanbul ignore else -- @preserve */
if (data) {
toast.success(t('tagCreationSuccess'));
orgUserTagsRefetch();
setTagName('');
setCreateTagModalIsOpen(false);
} else {

Check warning on line 147 in src/screens/OrganizationTags/OrganizationTags.tsx

View check run for this annotation

Codecov / codecov/patch

src/screens/OrganizationTags/OrganizationTags.tsx#L147

Added line #L147 was not covered by tests
toast.error('Tag creation failed');
}
} catch (error: unknown) {
/* istanbul ignore else -- @preserve */
if (error instanceof Error) {
toast.error(error.message);
}
toast.error((error as Error).message);

Check warning on line 151 in src/screens/OrganizationTags/OrganizationTags.tsx

View check run for this annotation

Codecov / codecov/patch

src/screens/OrganizationTags/OrganizationTags.tsx#L151

Added line #L151 was not covered by tests
}
};
if (orgUserTagsError) {
Expand Down
7 changes: 7 additions & 0 deletions src/screens/OrganizationTags/OrganizationTagsMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,13 @@ export const MOCKS = [
},
result: { data: { createUserTag: { _id: '12' } } },
},
{
request: {
query: CREATE_USER_TAG,
variables: { name: 'userTag 13', organizationId: 'orgId' },
},
result: { data: null },
},
];

export const MOCKS_ERROR = [

Check warning on line 319 in src/screens/OrganizationTags/OrganizationTagsMocks.ts

View check run for this annotation

Codecov / codecov/patch

src/screens/OrganizationTags/OrganizationTagsMocks.ts#L319

Added line #L319 was not covered by tests
Expand Down

0 comments on commit cc67bcb

Please sign in to comment.