Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix all broken CIs #7439

Merged
merged 31 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { MockedProvider, MockedResponse } from '@apollo/client/testing';
import { MockedResponse } from '@apollo/client/testing';
import { act, renderHook } from '@testing-library/react';
import gql from 'graphql-tag';
import pick from 'lodash.pick';
import { ReactNode } from 'react';
import { RecoilRoot } from 'recoil';

import { useCreateActivityInDB } from '@/activities/hooks/useCreateActivityInDB';
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { SnackBarProviderScope } from '@/ui/feedback/snack-bar-manager/scopes/SnackBarProviderScope';
import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';
import { mockedTasks } from '~/testing/mock-data/tasks';

const mockedDate = '2024-03-15T12:00:00.000Z';
Expand All @@ -26,14 +24,44 @@ const mocks: MockedResponse[] = [
mutation CreateOneTask($input: TaskCreateInput!) {
createTask(data: $input) {
__typename
updatedAt
assignee {
__typename
id
name {
firstName
lastName
}
}
assigneeId
attachments {
edges {
node {
__typename
activityId
authorId
companyId
createdAt
deletedAt
fullPath
id
name
noteId
opportunityId
personId
rocketId
taskId
type
updatedAt
}
}
}
body
createdAt
dueAt
id
status
body
assigneeId
title
updatedAt
}
}
`,
Expand All @@ -56,15 +84,9 @@ const mocks: MockedResponse[] = [
},
];

const Wrapper = ({ children }: { children: ReactNode }) => (
<RecoilRoot>
<MockedProvider mocks={mocks} addTypename={false}>
<SnackBarProviderScope snackBarManagerScopeId="snack-bar-manager">
{children}
</SnackBarProviderScope>
</MockedProvider>
</RecoilRoot>
);
const Wrapper = getJestMetadataAndApolloMocksWrapper({
apolloMocks: mocks,
});

describe('useCreateActivityInDB', () => {
it('Should create activity in DB', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { MockedProvider, MockedResponse } from '@apollo/client/testing';
import { MockedResponse } from '@apollo/client/testing';
import { act, renderHook } from '@testing-library/react';
import { ReactNode } from 'react';
import { RecoilRoot, useRecoilValue, useSetRecoilState } from 'recoil';
import { useRecoilValue, useSetRecoilState } from 'recoil';

import { useOpenCreateActivityDrawer } from '@/activities/hooks/useOpenCreateActivityDrawer';
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { viewableRecordIdState } from '@/object-record/record-right-drawer/states/viewableRecordIdState';
import gql from 'graphql-tag';
import pick from 'lodash.pick';
import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';
import { generatedMockObjectMetadataItems } from '~/testing/mock-data/objectMetadataItems';
import { mockedTasks } from '~/testing/mock-data/tasks';

Expand Down Expand Up @@ -61,13 +61,9 @@ const mocks: MockedResponse[] = [
},
];

const Wrapper = ({ children }: { children: ReactNode }) => (
<RecoilRoot>
<MockedProvider addTypename={false} mocks={mocks}>
{children}
</MockedProvider>
</RecoilRoot>
);
const Wrapper = getJestMetadataAndApolloMocksWrapper({
apolloMocks: mocks,
});

const mockObjectMetadataItems = generatedMockObjectMetadataItems;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { MockedProvider, MockedResponse } from '@apollo/client/testing';
import { MockedResponse } from '@apollo/client/testing';
import { act, renderHook } from '@testing-library/react';
import gql from 'graphql-tag';
import { ReactNode } from 'react';
import { RecoilRoot } from 'recoil';

import { useCompleteTask } from '@/activities/tasks/hooks/useCompleteTask';
import { Task } from '@/activities/types/Task';
import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';

const task: Task = {
id: '123',
Expand All @@ -28,21 +27,123 @@ const mocks: MockedResponse[] = [
mutation UpdateOneTask($idToUpdate: ID!, $input: TaskUpdateInput!) {
updateTask(id: $idToUpdate, data: $input) {
__typename
updatedAt
createdAt
deletedAt
dueAt
id
status
assignee {
__typename
avatarUrl
colorScheme
createdAt
dateFormat
deletedAt
id
locale
name {
firstName
lastName
}
timeFormat
timeZone
updatedAt
userEmail
userId
}
assigneeId
attachments {
edges {
node {
__typename
activityId
authorId
companyId
createdAt
deletedAt
fullPath
id
name
noteId
opportunityId
personId
rocketId
taskId
type
updatedAt
}
}
}
body
createdAt
createdBy {
source
workspaceMemberId
name
}
assigneeId
deletedAt
dueAt
favorites {
edges {
node {
__typename
companyId
createdAt
deletedAt
id
noteId
opportunityId
personId
position
rocketId
taskId
updatedAt
viewId
workflowId
workspaceMemberId
}
}
}
id
position
status
taskTargets {
edges {
node {
__typename
companyId
createdAt
deletedAt
id
opportunityId
personId
rocketId
taskId
updatedAt
}
}
}
timelineActivities {
edges {
node {
__typename
companyId
createdAt
deletedAt
happensAt
id
linkedObjectMetadataId
linkedRecordCachedName
linkedRecordId
name
noteId
opportunityId
personId
properties
rocketId
taskId
updatedAt
workspaceMemberId
}
}
}
title
updatedAt
}
}
`,
Expand Down Expand Up @@ -72,13 +173,9 @@ const mocks: MockedResponse[] = [
},
];

const Wrapper = ({ children }: { children: ReactNode }) => (
<RecoilRoot>
<MockedProvider mocks={mocks} addTypename={false}>
{children}
</MockedProvider>
</RecoilRoot>
);
const Wrapper = getJestMetadataAndApolloMocksWrapper({
apolloMocks: mocks,
});

describe('useCompleteTask', () => {
it('should complete task', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import { renderHook } from '@testing-library/react';

import { useTimelineActivities } from '@/activities/timelineActivities/hooks/useTimelineActivities';
import { ReactNode } from 'react';
import { getJestHookWrapper } from '~/testing/jest/getJestHookWrapper';
import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';

jest.mock('@/object-record/hooks/useFindManyRecords', () => ({
useFindManyRecords: jest.fn(),
}));

const Wrappers = getJestHookWrapper({
const Wrapper = getJestMetadataAndApolloMocksWrapper({
apolloMocks: [],
});

const Wrapper = ({ children }: { children: ReactNode }) => (
<Wrappers>{children}</Wrappers>
);

describe('useTimelineActivities', () => {
afterEach(() => {
jest.clearAllMocks();
Expand Down
Loading
Loading