Skip to content

The open alternative to Salesforce, designed for AI.

Fix tests (#537)

Charles Bochete2822ed09519
diff --git a/front/src/modules/ui/components/editable-cell/EditableCell.tsx b/front/src/modules/ui/components/editable-cell/EditableCell.tsx
index 65ec7fbf57d..888e26ccd29 100644
--- a/front/src/modules/ui/components/editable-cell/EditableCell.tsx
+++ b/front/src/modules/ui/components/editable-cell/EditableCell.tsx
@@ -1,11 +1,9 @@
import { ReactElement } from 'react';
import styled from '@emotion/styled';
-import { useRecoilValue } from 'recoil';
import { useAddToHotkeysScopeStack } from '@/hotkeys/hooks/useAddToHotkeysScopeStack';
import { HotkeysScopeStackItem } from '@/hotkeys/types/internal/HotkeysScopeStackItems';
import { InternalHotkeysScope } from '@/hotkeys/types/internal/InternalHotkeysScope';
-import { isSoftFocusActiveState } from '@/ui/tables/states/isSoftFocusActiveState';
import { useEditableCell } from './hooks/useCloseEditableCell';
import { useCurrentCellEditMode } from './hooks/useCurrentCellEditMode';
@@ -47,7 +45,7 @@ export function EditableCell({
const { openEditableCell } = useEditableCell();
- const isSoftFocusActive = useRecoilValue(isSoftFocusActiveState);
+ const hasSoftFocus = useIsSoftFocusOnCurrentCell();
const addToHotkeysScopeStack = useAddToHotkeysScopeStack();
@@ -59,7 +57,7 @@ export function EditableCell({
return;
}
- if (isSoftFocusActive) {
+ if (hasSoftFocus) {
openEditableCell();
addToHotkeysScopeStack(
editHotkeysScope ?? {
@@ -71,8 +69,6 @@ export function EditableCell({
setSoftFocusOnCurrentCell();
}
- const hasSoftFocus = useIsSoftFocusOnCurrentCell();
-
return (
<CellBaseContainer onClick={handleOnClick}>
{isCurrentCellInEditMode ? (
diff --git a/front/src/pages/companies/__stories__/Companies.filterBy.stories.tsx b/front/src/pages/companies/__stories__/Companies.filterBy.stories.tsx
index 9d518309489..501825f2c23 100644
--- a/front/src/pages/companies/__stories__/Companies.filterBy.stories.tsx
+++ b/front/src/pages/companies/__stories__/Companies.filterBy.stories.tsx
@@ -73,7 +73,9 @@ export const FilterByAccountOwner: Story = {
await userEvent.click(accountOwnerFilterButton);
- const accountOwnerNameInput = canvas.getByPlaceholderText('Account owner');
+ const accountOwnerNameInput = await canvas.findByPlaceholderText(
+ 'Account owner',
+ );
await userEvent.type(accountOwnerNameInput, 'Char', {
delay: 200,
});
diff --git a/front/src/pages/people/__stories__/People.inputs.stories.tsx b/front/src/pages/people/__stories__/People.inputs.stories.tsx
index 7355c3a6e6e..bfa9fc4a635 100644
--- a/front/src/pages/people/__stories__/People.inputs.stories.tsx
+++ b/front/src/pages/people/__stories__/People.inputs.stories.tsx
@@ -30,13 +30,9 @@ export const InteractWithManyRows: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- const firstRowEmailCell = await canvas.findByText(
- mockedPeopleData[0].email,
- );
+ let firstRowEmailCell = await canvas.findByText(mockedPeopleData[0].email);
- const secondRowEmailCell = await canvas.findByText(
- mockedPeopleData[1].email,
- );
+ let secondRowEmailCell = await canvas.findByText(mockedPeopleData[1].email);
expect(
canvas.queryByTestId('editable-cell-edit-mode-container'),
@@ -44,10 +40,18 @@ export const InteractWithManyRows: Story = {
await userEvent.click(firstRowEmailCell);
+ await sleep(100);
+ firstRowEmailCell = await canvas.findByText(mockedPeopleData[0].email);
+ await userEvent.click(firstRowEmailCell);
+ await sleep(100);
+ firstRowEmailCell = await canvas.findByText(mockedPeopleData[0].email);
+ await userEvent.click(firstRowEmailCell);
+
expect(
canvas.queryByTestId('editable-cell-edit-mode-container'),
).toBeInTheDocument();
+ secondRowEmailCell = await canvas.findByText(mockedPeopleData[1].email);
await userEvent.click(secondRowEmailCell);
await sleep(25);
@@ -190,11 +194,17 @@ export const EditRelation: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- const firstRowCompanyCell = await canvas.findByText(
+ let secondRowCompanyCell = await canvas.findByText(
mockedPeopleData[1].company.name,
);
- await userEvent.click(firstRowCompanyCell);
+ await userEvent.click(secondRowCompanyCell);
+
+ secondRowCompanyCell = await canvas.findByText(
+ mockedPeopleData[1].company.name,
+ );
+
+ await userEvent.click(secondRowCompanyCell);
const relationInput = await canvas.findByPlaceholderText('Search');
@@ -227,11 +237,15 @@ export const SelectRelationWithKeys: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- const thirdRowCompanyCell = await canvas.findByText(
+ let firstRowCompanyCell = await canvas.findByText(
mockedPeopleData[0].company.name,
);
- await userEvent.click(thirdRowCompanyCell);
+ await userEvent.click(firstRowCompanyCell);
+ firstRowCompanyCell = await canvas.findByText(
+ mockedPeopleData[0].company.name,
+ );
+ await userEvent.click(firstRowCompanyCell);
const relationInput = await canvas.findByPlaceholderText('Search');
diff --git a/front/src/testing/renderWrappers.tsx b/front/src/testing/renderWrappers.tsx
index dfe5b2420b4..fb73808942b 100644
--- a/front/src/testing/renderWrappers.tsx
+++ b/front/src/testing/renderWrappers.tsx
@@ -1,13 +1,16 @@
import React from 'react';
+import { HotkeysProvider } from 'react-hotkeys-hook';
import { MemoryRouter } from 'react-router-dom';
import { ApolloProvider } from '@apollo/client';
import { RecoilRoot } from 'recoil';
+import { INITIAL_HOTKEYS_SCOPES } from '@/hotkeys/constants';
import { RecoilScope } from '@/recoil-scope/components/RecoilScope';
import { HooksEntityTable } from '@/ui/components/table/HooksEntityTable';
import { DefaultLayout } from '@/ui/layout/DefaultLayout';
import { TableContext } from '@/ui/tables/states/TableContext';
import { companiesFilters } from '~/pages/companies/companies-filters';
+import { ClientConfigProvider } from '~/providers/client-config/ClientConfigProvider';
import { UserProvider } from '~/providers/user/UserProvider';
import { mockedCompaniesData } from './mock-data/companies';
@@ -24,11 +27,15 @@ export function getRenderWrapperForPage(
<RecoilRoot>
<ApolloProvider client={mockedClient}>
<UserProvider>
- <MemoryRouter initialEntries={[currentPath]}>
- <FullHeightStorybookLayout>
- <DefaultLayout>{children}</DefaultLayout>
- </FullHeightStorybookLayout>
- </MemoryRouter>
+ <ClientConfigProvider>
+ <HotkeysProvider initiallyActiveScopes={INITIAL_HOTKEYS_SCOPES}>
+ <MemoryRouter initialEntries={[currentPath]}>
+ <FullHeightStorybookLayout>
+ <DefaultLayout>{children}</DefaultLayout>
+ </FullHeightStorybookLayout>
+ </MemoryRouter>
+ </HotkeysProvider>
+ </ClientConfigProvider>
</UserProvider>
</ApolloProvider>
</RecoilRoot>