Skip to content

Add data-testid to all React Components_11: 110187576 #1474

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions src/components/common/WorkspaceEditableFeild.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const WorkspaceEditableField = ({
};

return (
<FieldWrap>
<FieldWrap data-testid="workspace-editable-field-component">
<Label>{label}</Label>
<Data>
<OptionsWrap>
Expand Down Expand Up @@ -99,4 +99,4 @@ export const WorkspaceEditableField = ({
</Data>
</FieldWrap>
);
};
};
4 changes: 2 additions & 2 deletions src/components/common/__tests__/Button.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Button Component', () => {
const mockOnClick = jest.fn();

render(
<Button
<Button data-testid="button-component"
id={'1'}
icon={''}
height={10}
Expand All @@ -45,4 +45,4 @@ describe('Button Component', () => {
//If we click on text it should register click
expect(mockOnClick).toHaveBeenCalledTimes(1);
});
});
});
4 changes: 2 additions & 2 deletions src/components/common/__tests__/ButtonContainer.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ beforeAll(() => {
describe('ButtonContainer', () => {
nock(user.url).get('/person/id/1').reply(200, {});
test('is rendered', async () => {
const { container } = render(<ButtonContainer />);
const { container } = render(<ButtonContainer data-testid="button-container-component" />);

//Expect text to be there
expect(container).toBeTruthy();
});
});
});
4 changes: 2 additions & 2 deletions src/components/common/__tests__/Divider.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ beforeAll(() => {
describe('Button Component', () => {
nock(user.url).get('/person/id/1').reply(200, {});
test('display text and click button', async () => {
render(<Divider style={{ color: 'blue' }} />);
render(<Divider data-testid="divider-component" style={{ color: 'blue' }} />);

expect(screen.getByTestId('testid-divider')).toBeInTheDocument();
expect(screen.getByTestId('testid-divider')).toHaveAttribute('style', 'color: blue;');
});
});
});
4 changes: 2 additions & 2 deletions src/components/common/__tests__/Elements.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Elements', () => {
nock(user.url).get('/person/id/1').reply(200, {});
test('Title', async () => {
const TitleText = 'Title Text';
render(<Title>{TitleText}</Title>);
render(<Title data-testid="elements-component">{TitleText}</Title>);

expect(screen.queryByText(TitleText)).toBeInTheDocument();
});
Expand All @@ -43,4 +43,4 @@ describe('Elements', () => {

expect(screen.queryByText(LinkText)).toBeInTheDocument();
});
});
});
4 changes: 2 additions & 2 deletions src/components/common/__tests__/QR.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ describe('QR Component', () => {
nock(user.url).get('/person/id/1').reply(200, {});
test('does display qr code', async () => {
const value = 'test value';
render(<QR type={'connect'} value={value} size={10} />);
render(<QR data-testid="qr-component" type={'connect'} value={value} size={10} />);

//Expect text to be there
expect(screen.getByTestId('testid-qrcode')).toBeInTheDocument();
expect(screen.getByTestId('testid-connectimg')).toBeInTheDocument();
});
});
});
4 changes: 2 additions & 2 deletions src/components/common/__tests__/SidebarComponent.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const mockStores = {

const renderSidebar = (props = {}) =>
render(
<BrowserRouter>
<BrowserRouter data-testid="sidebar-component-component">
<SidebarComponent uuid="test-uuid" {...props} />
</BrowserRouter>
);
Expand Down Expand Up @@ -235,4 +235,4 @@ describe('SidebarComponent Tooltip Tests', () => {
});
});
});
});
});
2 changes: 1 addition & 1 deletion src/components/common/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ export {
Portal,
SearchBar,
QR
};
};
3 changes: 2 additions & 1 deletion src/components/common/useCreateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function CreateModalPortal<T>(
if (!modal) throw new Error('"#modal-root" element not found');
return createPortal(
<Component
data-testid="create-modal-portal-component"
{...props}
onClose={() => {
props.onClose?.();
Expand All @@ -49,4 +50,4 @@ export const CreateModalContext =
>
>();

export const useCreateModal = () => useContext(CreateModalContext).current;
export const useCreateModal = () => useContext(CreateModalContext).current;
4 changes: 2 additions & 2 deletions src/components/common/withCreateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ export function withCreateModal<T extends Object>(Component: FC<T>) {
const injectModalCb = useRef<(props: CreateModalProps) => void>(() => {});

return (
<CreateModalContext.Provider value={injectModalCb}>
<CreateModalContext.Provider data-testid="modal-injector-component" value={injectModalCb}>
<ModalInjector createCb={injectModalCb} />
<Component {...props} />
</CreateModalContext.Provider>
);
};
}
}
Loading