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

Table updated tests #2555

Merged
merged 154 commits into from
Dec 4, 2024
Merged

Table updated tests #2555

merged 154 commits into from
Dec 4, 2024

Conversation

shaneeza
Copy link
Collaborator

✍️ Proposed changes

🎟 Jira ticket: Name of ticket

✅ Checklist

For bug fixes, new features & breaking changes

  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • I have run yarn changeset and documented my changes

For new components

  • I have added my new package to the global tsconfig
  • I have added my new package to the Table of Contents on the global README
  • I have verified the Live Example looks as intended on the design website.

🧪 How to test changes

@shaneeza shaneeza marked this pull request as ready for review December 2, 2024 23:11
@shaneeza shaneeza requested a review from a team as a code owner December 2, 2024 23:11
@shaneeza shaneeza requested review from tsck and removed request for a team December 2, 2024 23:11
@mongodb mongodb deleted a comment from shaneeza Dec 4, 2024

HeaderCell.propTypes = {
header: PropTypes.object,
} as any; // avoid inferred types from interfering;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish there was a better way to handle these, but I can't come up with a straightforward way either =(

<StyledHeaderCell data-testid="styled">Some text</StyledHeaderCell>,
);

expect(getByTestId('styled')).toBeInTheDocument();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Wonder if it's necessary to check if this is in the document? It's not actually an implementation detail since we're rendering it directly in the test. Won't comment this on each one to bloat the review, but have the same thinking for each of these styled tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think i can get rid of it since the expect below is also checking for it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed yesterday, I wanted this think about this some more but I think this is the correct call. We don't specify WithoutRT anywhere else, so I think this makes sense.

One question - it doesn't seem like all of these tests were moved over. Was that intentional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I removed the tests for the zebra stripping because that seems more of a chromatic test. I thought we had a generated story to test zebra stripes, but it looks like we don't, so I'll update the generated row story to include it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense to me!

describe('packages/table/Row/NestedRows', () => {
test('renders the correct number of children', () => {
render(<RowWithNestedRows />);
describe('packages/table/RowWithoutRT', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
describe('packages/table/RowWithoutRT', () => {
describe('packages/table/Row', () => {

renderRow({ ...defaultProps, onClick });
const { getRowByIndex } = getTestUtils();
const firstRow = getRowByIndex(0)?.getElement();
fireEvent.click(firstRow!);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for using fireEvent instead of userEvent here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it was just a copy-paste; I'll update it.

Comment on lines 36 to 47
const { result } = renderHook(() =>
useLeafyGreenTable({
data: getDefaultTestData({
// eslint-disable-next-line react/display-name
renderExpandedContent: (_: LeafyGreenTableRow<Person>) => {
return <>Expandable content test</>;
},
}),
columns: getDefaultTestColumns({}),
}),
);
expect(result.current.getRowModel().rows.length).toEqual(3);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm correctly understanding why we're using 3 here, we could map this number more directly to the source here.

Suggested change
const { result } = renderHook(() =>
useLeafyGreenTable({
data: getDefaultTestData({
// eslint-disable-next-line react/display-name
renderExpandedContent: (_: LeafyGreenTableRow<Person>) => {
return <>Expandable content test</>;
},
}),
columns: getDefaultTestColumns({}),
}),
);
expect(result.current.getRowModel().rows.length).toEqual(3);
const data = getDefaultTestData({
// eslint-disable-next-line react/display-name
renderExpandedContent: (_: LeafyGreenTableRow<Person>) => {
return <>Expandable content test</>;
},
});
const { result } = renderHook(() =>
useLeafyGreenTable({
data,
columns: getDefaultTestColumns({}),
}),
);
expect(result.current.getRowModel().rows.length).toEqual(data.length);

Comment on lines 51 to 59
const { result } = renderHook(() =>
useLeafyGreenTable({
data: getDefaultTestData({
subRows: getDefaultTestData({}),
}),
columns: getDefaultTestColumns({}),
}),
);
expect(result.current.getRowModel().rows.length).toEqual(3);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Suggested change
const { result } = renderHook(() =>
useLeafyGreenTable({
data: getDefaultTestData({
subRows: getDefaultTestData({}),
}),
columns: getDefaultTestColumns({}),
}),
);
expect(result.current.getRowModel().rows.length).toEqual(3);
const data = getDefaultTestData({
subRows: getDefaultTestData({}),
});
const { result } = renderHook(() =>
useLeafyGreenTable({
data,
columns: getDefaultTestColumns({}),
}),
);
expect(result.current.getRowModel().rows.length).toEqual(data.length);


// eslint-disable-next-line jest/no-disabled-tests
test.skip('Typescript', () => {
// @ts-expect-error - requires columns, data, containerReff
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nit =)

Suggested change
// @ts-expect-error - requires columns, data, containerReff
// @ts-expect-error - requires columns, data, containerRef

@shaneeza shaneeza requested a review from tsck December 4, 2024 19:35
@shaneeza shaneeza merged commit f3c2a87 into table-refactor-integration Dec 4, 2024
10 of 11 checks passed
@shaneeza shaneeza deleted the shaneeza/table-tests branch December 4, 2024 20:12
github-merge-queue bot pushed a commit that referenced this pull request Dec 19, 2024
* [LG-4489, LG-4488]: remove transitions and nested stories (#2472)

* temp removal of transitions

* remove nested stories

* remove flatten packages

* Table Updates (#2506)

* wip

* wip

* updating stories

* lg virtual item

* top styles

* remove padding from TableBody

* expanded row background color

* removing stuff

* row context

* memoizing stuff

* wip

* styled components

* comments

* more cleanup

* clean up

* comments

* wip, memoize regular table

* testing

* huh

* why does this work?

* testing why nothing works

* clean up

* update virtual stories

* clean up

* cleanup

* row types

* types

* should truncate support

* remove memo from useLeafyGreenVirtualTable

* remove unsed exports

* add a new story

* widths and vertical align

* dynamic ellipsis

* comment

* combined components

* cell generic type

* update types

* align styles

* Prerelease version packages 13.0.0-beta.0

* fix install error

* Prerelease version packages 13.0.0-beta.1

* comment, wip

* revert useLeafyGreenTable hook so its consistent with a virtual table

* add getItemKey

* small fix

* stop mapping columns def

* testing

* debugging

* tbody updates

* css vars

* add virtual context

* remove comment

* remove measureElement from hook

* row context updates

* remove overflow from regular table

* updates virtual types

* more TS docs

* ts fixes

* row TS docs

* TS docs stuff

* fix comment

* remove original from rowCopy

* story clean up

* remove v10 and v11 adapter

* remove react-virtual

* cell styles

* interrowwithRT style updates

* table styles

* comment

* comment

* story with less rows

* cell ternary, headercell util, expandedcontent styles

* fb - toggleExpand, isVirtual boolean, type casting, tsdocs

* virtual scrolling padding util

* forgot to save

* fb - remove virtual context

* custom row model

* styledcomponent stuff, TS still not correct

* callable virtual items

* update ts docs

* token

* feedback

* `Table` forwardRefs (#2539)

* wip

* wip

* updating stories

* lg virtual item

* top styles

* remove padding from TableBody

* expanded row background color

* removing stuff

* row context

* memoizing stuff

* wip

* styled components

* comments

* more cleanup

* clean up

* comments

* wip, memoize regular table

* testing

* huh

* why does this work?

* testing why nothing works

* clean up

* update virtual stories

* clean up

* cleanup

* row types

* types

* should truncate support

* remove memo from useLeafyGreenVirtualTable

* remove unsed exports

* add a new story

* widths and vertical align

* dynamic ellipsis

* comment

* combined components

* cell generic type

* update types

* align styles

* Prerelease version packages 13.0.0-beta.0

* fix install error

* Prerelease version packages 13.0.0-beta.1

* comment, wip

* added forwardrefs to cells and tds

* add tests for useMergeRefs

* forwardRef test

* Row export

* headerRow forwardref test

* TableBody forwardRef test

* TableHeader forwardRef test

* Cell forwardRef test

* HeaderCell ForwardRef test

* ExpandedContent ForwardRef test

* update test

* comments

* revert useLeafyGreenTable hook so its consistent with a virtual table

* fix story

* small fix

* add getItemKey

* small fix

* stop mapping columns def

* testing

* debugging

* tbody updates

* css vars

* add virtual context

* remove comment

* remove measureElement from hook

* remove getAreAncestorsExpanded util

* row context updates

* remove overflow from regular table

* move Generic type to lib

* updating comments

* fix cell fwdRef test

* comments

* updates virtual types

* more TS docs

* ts fixes

* row TS docs

* TS docs stuff

* fix comment

* remove original from rowCopy

* story clean up

* remove v10 and v11 adapter

* fix test

* remove react-virtual

* cell styles

* interrowwithRT style updates

* table styles

* comment

* comment

* comment

* story with less rows

* cell ternary, headercell util, expandedcontent styles

* fb - toggleExpand, isVirtual boolean, type casting, tsdocs

* virtual scrolling padding util

* forgot to save

* fb - remove virtual context

* custom row model

* styledcomponent stuff, TS still not correct

* callable virtual items

* update ts docs

* token

* feedback

* updates

* `Table` sticky scroll shadow (#2541)

* wip

* wip

* updating stories

* lg virtual item

* top styles

* remove padding from TableBody

* expanded row background color

* removing stuff

* row context

* memoizing stuff

* wip

* styled components

* comments

* more cleanup

* clean up

* comments

* wip, memoize regular table

* testing

* huh

* why does this work?

* testing why nothing works

* clean up

* update virtual stories

* clean up

* cleanup

* row types

* types

* should truncate support

* remove memo from useLeafyGreenVirtualTable

* remove unsed exports

* add a new story

* widths and vertical align

* dynamic ellipsis

* comment

* combined components

* cell generic type

* update types

* align styles

* Prerelease version packages 13.0.0-beta.0

* fix install error

* Prerelease version packages 13.0.0-beta.1

* comment, wip

* revert useLeafyGreenTable hook so its consistent with a virtual table

* add getItemKey

* small fix

* stop mapping columns def

* testing

* debugging

* tbody updates

* css vars

* add virtual context

* remove comment

* remove measureElement from hook

* row context updates

* remove overflow from regular table

* updates virtual types

* more TS docs

* ts fixes

* row TS docs

* TS docs stuff

* fix comment

* add react-intersection-observer

* wip

* remove original from rowCopy

* story clean up

* remove v10 and v11 adapter

* remove react-virtual

* cell styles

* interrowwithRT style updates

* table styles

* comment

* comment

* wip

* story with less rows

* move box-shadow to headerRow

* darken darkmode scroll shadow

* move styles

* add test

* remove comments

* testing removing styled components

* add back styled

* diff react-intersection-observer version

* yarn lonk

* cell ternary, headercell util, expandedcontent styles

* fb - toggleExpand, isVirtual boolean, type casting, tsdocs

* virtual scrolling padding util

* forgot to save

* fb - remove virtual context

* custom row model

* styledcomponent stuff, TS still not correct

* callable virtual items

* update ts docs

* token

* use classname

* move interaction test

* use a classname

* remove id

* remove ?

* fix broken stories

* interaction rename and args

* story heights

* add comment

* add comment

* revert changes to expandedContentParentStyles

* `Table` column vertical alignment (#2547)

* wip

* wip

* updating stories

* lg virtual item

* top styles

* remove padding from TableBody

* expanded row background color

* removing stuff

* row context

* memoizing stuff

* wip

* styled components

* comments

* more cleanup

* clean up

* comments

* wip, memoize regular table

* testing

* huh

* why does this work?

* testing why nothing works

* clean up

* update virtual stories

* clean up

* cleanup

* row types

* types

* should truncate support

* remove memo from useLeafyGreenVirtualTable

* remove unsed exports

* add a new story

* widths and vertical align

* dynamic ellipsis

* comment

* combined components

* cell generic type

* update types

* align styles

* Prerelease version packages 13.0.0-beta.0

* fix install error

* Prerelease version packages 13.0.0-beta.1

* comment, wip

* revert useLeafyGreenTable hook so its consistent with a virtual table

* add getItemKey

* small fix

* stop mapping columns def

* testing

* debugging

* tbody updates

* css vars

* add virtual context

* remove comment

* remove measureElement from hook

* row context updates

* remove overflow from regular table

* updates virtual types

* more TS docs

* ts fixes

* row TS docs

* TS docs stuff

* fix comment

* add react-intersection-observer

* wip

* remove original from rowCopy

* story clean up

* remove v10 and v11 adapter

* remove react-virtual

* cell styles

* interrowwithRT style updates

* table styles

* comment

* comment

* wip

* story with less rows

* move box-shadow to headerRow

* darken darkmode scroll shadow

* move styles

* alignment

* remove comment

* add test

* remove comments

* testing removing styled components

* add back styled

* diff react-intersection-observer version

* yarn lonk

* cell ternary, headercell util, expandedcontent styles

* fb - toggleExpand, isVirtual boolean, type casting, tsdocs

* virtual scrolling padding util

* forgot to save

* fb - remove virtual context

* custom row model

* styledcomponent stuff, TS still not correct

* callable virtual items

* update ts docs

* token

* use classname

* move interaction test

* use a classname

* remove id

* remove ?

* fix broken stories

* interaction rename and args

* story heights

* add back color

* update stories

* remove InternalCell file

* new story

* fix row stories

* update rows stories

* revert some story changes

* revert some more story changes

* use classname

* revert some story changes

* `Table` fixed layout (#2545)

* wip

* wip

* updating stories

* lg virtual item

* top styles

* remove padding from TableBody

* expanded row background color

* removing stuff

* row context

* memoizing stuff

* wip

* styled components

* comments

* more cleanup

* clean up

* comments

* wip, memoize regular table

* testing

* huh

* why does this work?

* testing why nothing works

* clean up

* update virtual stories

* clean up

* cleanup

* row types

* types

* should truncate support

* remove memo from useLeafyGreenVirtualTable

* remove unsed exports

* add a new story

* widths and vertical align

* dynamic ellipsis

* comment

* combined components

* cell generic type

* update types

* align styles

* Prerelease version packages 13.0.0-beta.0

* fix install error

* Prerelease version packages 13.0.0-beta.1

* comment, wip

* revert useLeafyGreenTable hook so its consistent with a virtual table

* add getItemKey

* small fix

* stop mapping columns def

* testing

* debugging

* tbody updates

* css vars

* add virtual context

* remove comment

* remove measureElement from hook

* row context updates

* remove overflow from regular table

* updates virtual types

* more TS docs

* ts fixes

* row TS docs

* TS docs stuff

* fix comment

* add react-intersection-observer

* wip

* remove original from rowCopy

* story clean up

* remove v10 and v11 adapter

* remove react-virtual

* cell styles

* interrowwithRT style updates

* table styles

* comment

* comment

* wip

* story with less rows

* move box-shadow to headerRow

* darken darkmode scroll shadow

* move styles

* add test

* remove comments

* testing removing styled components

* add back styled

* diff react-intersection-observer version

* yarn lonk

* cell ternary, headercell util, expandedcontent styles

* fb - toggleExpand, isVirtual boolean, type casting, tsdocs

* virtual scrolling padding util

* forgot to save

* fb - remove virtual context

* custom row model

* styledcomponent stuff, TS still not correct

* callable virtual items

* update ts docs

* token

* use classname

* move interaction test

* use a classname

* remove id

* add table-layout:fixed

* make table fixed, fix shadow and aligment

* line height

* remove ?

* fix error

* fix broken stories

* interaction rename and args

* story heights

* revert row style changes

* update sizes

* add comment

* update story

* LG-4681: fix row background-color styles (#2560)

* LG-4681: fix row background-color styles

* Fix zebra and expanded row styles

* Design feedback

* `Table` updated tests (#2555)

* wip

* wip

* updating stories

* lg virtual item

* top styles

* remove padding from TableBody

* expanded row background color

* removing stuff

* row context

* memoizing stuff

* wip

* styled components

* comments

* more cleanup

* clean up

* comments

* wip, memoize regular table

* testing

* huh

* why does this work?

* testing why nothing works

* clean up

* update virtual stories

* clean up

* cleanup

* row types

* types

* should truncate support

* remove memo from useLeafyGreenVirtualTable

* remove unsed exports

* add a new story

* widths and vertical align

* dynamic ellipsis

* comment

* combined components

* cell generic type

* update types

* align styles

* Prerelease version packages 13.0.0-beta.0

* fix install error

* Prerelease version packages 13.0.0-beta.1

* comment, wip

* added forwardrefs to cells and tds

* add tests for useMergeRefs

* forwardRef test

* Row export

* headerRow forwardref test

* TableBody forwardRef test

* TableHeader forwardRef test

* Cell forwardRef test

* HeaderCell ForwardRef test

* ExpandedContent ForwardRef test

* update test

* comments

* revert useLeafyGreenTable hook so its consistent with a virtual table

* fix story

* small fix

* add getItemKey

* small fix

* stop mapping columns def

* testing

* debugging

* tbody updates

* css vars

* add virtual context

* remove comment

* remove measureElement from hook

* remove getAreAncestorsExpanded util

* row context updates

* remove overflow from regular table

* move Generic type to lib

* updating comments

* fix cell fwdRef test

* comments

* updates virtual types

* more TS docs

* ts fixes

* row TS docs

* TS docs stuff

* fix comment

* remove original from rowCopy

* story clean up

* remove v10 and v11 adapter

* fix test

* remove react-virtual

* cell styles

* interrowwithRT style updates

* table styles

* comment

* comment

* comment

* story with less rows

* cell ternary, headercell util, expandedcontent styles

* fb - toggleExpand, isVirtual boolean, type casting, tsdocs

* virtual scrolling padding util

* forgot to save

* fb - remove virtual context

* custom row model

* styledcomponent stuff, TS still not correct

* callable virtual items

* update ts docs

* token

* feedback

* updates

* headercell tests

* forgot to save

* wip, headerCell

* headerCell tests

* cell tests

* cell mock data

* cell proptypes

* forgot to save

* expandedContent tests

* headerRow tests

* remove todo

* fix test utils

* update hooks tests

* testing

* row test updates

* more row tests

* TableHead tests

* table tests

* table tests

* useLeafyGreenTable tests

* fix table test hook calls

* more virtual table tests

* propTypes

* comments

* HeaderCell story updates

* remove dup interface

* table R17 (#2563)

* add rowRef prop. rm genericMemo

* update ref props

* update comments

* update row tests

* remove document check

* remove import

* check data.length

* update row generated story to include zebra stripes

---------

Co-authored-by: Adam Thompson <[email protected]>

* `Table` bug bash fixes  (#2569)

* fix action buttons

* decrease nestedRow story rows

* decrease expandedContent story rows

* add 100% width to VS table stories

* fix tall row story

* fix table width

* switch to NaN

* remove min-width

* another comment

* fix comment

* `Table` documentation (#2582)

* wip documentation

* forgot to save

* change README files

* add empty examples section

* delete old readme

* wip upgrading

* wip upgrade guide

* more updates

* note on new tanstack virtual package

* add table changeset

* fix story control

* another changeset

* more content updates

* `Table` merge `useMergeRefs` (#2585)

* merge mergeRefs

* changeset

* remove `useMergeRefs` tests from hooks spec file

* deps not depss

* lint

* feedback

* brackets

* this is the correct way to link

* delete old changesets

* some feedback

* more feedback

* import order

* testing max_old_space_size

* another test

* try again

* remove extra node options

* adding back node options

* adding max_old_space_size in different spots

* add to package.json?

* remove from yarn install

* remove from package.json

* try decreasing rows in story

* node options in package.json

* remove changesets for hooks and tools

* remove node options from package.json

* release candidate prelease version packages

* remove changeset

* env in chromatic

* adding env to more spots in chromatic job

* add another step that logs the available system resources to confirm the memory and CPU of the runner

* more logs

* increase size

* revert changes

* Table chromatic test (#2603)

* testing if tallRows is breaking chromatic

* remove nan

* env in chromatic

* testing min-width removal

* increase to 16384

* remove dup node options

* adding back tall rows

* add back css

* remove tall rows

* Table snapshot changes (#2610)

* some snapshot changes

* removing the height from sticky header story

* add back tall rows

* add delay to sticky header story

* trying waitfor in sticky header story

* lint

* add virtual table example

---------

Co-authored-by: Stephen Lee <[email protected]>
Co-authored-by: Adam Thompson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants