Skip to content

Commit

Permalink
feat(Table): test id for table row and loading state (#2389)
Browse files Browse the repository at this point in the history
* feat: support test id for table row

* feat: add test id for table loading state

* Create clever-pigs-grow.md

* refactor: rename to table spinner

Co-authored-by: Anurag Hazra <[email protected]>

* chore: update test snapshot

---------

Co-authored-by: Anurag Hazra <[email protected]>
  • Loading branch information
harshcut and anuraghazra authored Oct 25, 2024
1 parent 1d0dae7 commit eef992b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/clever-pigs-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@razorpay/blade": patch
---

feat(blade): support test id for table row
2 changes: 1 addition & 1 deletion packages/blade/src/components/Table/Table.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ const _Table = <Item,>({
{...getStyledProps(styledProps)}
{...metaAttribute({ name: MetaConstants.Table })}
>
<Spinner accessibilityLabel="Loading Table" size="large" />
<Spinner accessibilityLabel="Loading Table" size="large" testID="table-spinner" />
</BaseBox>
) : (
<BaseBox
Expand Down
3 changes: 2 additions & 1 deletion packages/blade/src/components/Table/TableBody.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ const _TableRow = <Item,>({
isDisabled,
onHover,
onClick,
testID,
}: TableRowProps<Item>): React.ReactElement => {
const {
selectionType,
Expand Down Expand Up @@ -338,7 +339,7 @@ const _TableRow = <Item,>({
onMouseEnter={() => onHover?.({ item })}
onClick={() => onClick?.({ item })}
{...makeAccessible({ selected: isSelected })}
{...metaAttribute({ name: MetaConstants.TableRow })}
{...metaAttribute({ name: MetaConstants.TableRow, testID })}
>
{isMultiSelect && (
<TableCheckboxCell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4571,6 +4571,7 @@ exports[`<Table /> should render table with isLoading 1`] = `
<div
class=""
data-blade-component="spinner"
data-testid="table-spinner"
>
<div
aria-label="Loading Table"
Expand Down
3 changes: 2 additions & 1 deletion packages/blade/src/components/Table/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { StyledPropsBlade } from '~components/Box/styledProps';
import type { DropdownProps } from '~components/Dropdown';
import type { BaseInputProps } from '~components/Input/BaseInput';
import type { DotNotationToken } from '~utils/lodashButBetter/get';
import type { TestID } from '~utils/types';

type TableNode<Item> = Item & {
id: Identifier;
Expand Down Expand Up @@ -241,7 +242,7 @@ type TableRowProps<Item> = {
* Callback triggered when the row is clicked. It is called with the current row item prop.
*/
onClick?: ({ item }: { item: TableNode<Item> }) => void;
};
} & TestID;

type TableCellProps = {
/**
Expand Down

0 comments on commit eef992b

Please sign in to comment.