Skip to content

Commit f4f4670

Browse files
committed
add tests
1 parent efef0df commit f4f4670

File tree

2 files changed

+67
-2
lines changed

2 files changed

+67
-2
lines changed

packages/compass-global-writes/src/components/shard-zones-table.spec.tsx

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,70 @@ describe('Compass GlobalWrites Plugin', function () {
5555
expect(within(rows[2]).getByText('Germany - Berlin (DE-BE)')).to.be.visible;
5656
expect(within(rows[2]).getByText('EMEA (Frankfurt)')).to.be.visible;
5757
});
58+
59+
it('allows top level search', function () {
60+
render(
61+
<ShardZonesTable
62+
shardZones={[
63+
...shardZones,
64+
{
65+
zoneId: '438908',
66+
country: 'Slovakia',
67+
readableName: 'Slovakia',
68+
isoCode: 'SK',
69+
typeOneIsoCode: 'SK',
70+
zoneName: 'Zone 2',
71+
zoneLocations: ['Location 2'],
72+
},
73+
]}
74+
/>
75+
);
76+
77+
const searchInput = screen.getByLabelText('Search for a location');
78+
expect(searchInput).to.be.visible;
79+
userEvent.type(searchInput, 'Slo');
80+
const rows = screen.getAllByRole('row');
81+
expect(rows).to.have.lengthOf(2); // 1 header, 1 item
82+
expect(within(rows[1]).getByText('Slovakia (SK)')).to.be.visible;
83+
expect(within(rows[1]).getByText('Zone 2 (Location 2)')).to.be.visible;
84+
});
85+
86+
it('allows subZone search', function () {
87+
render(
88+
<ShardZonesTable
89+
shardZones={[
90+
...shardZones,
91+
{
92+
zoneId: '4389048',
93+
country: 'Slovakia',
94+
readableName: 'Slovakia',
95+
isoCode: 'SK',
96+
typeOneIsoCode: 'SK',
97+
zoneName: 'Zone 2',
98+
zoneLocations: ['Location 2'],
99+
},
100+
{
101+
zoneId: '8908900',
102+
country: 'Slovakia',
103+
readableName: 'Slovakia - Bratislava',
104+
isoCode: 'SK-BA',
105+
typeOneIsoCode: 'SK',
106+
zoneName: 'Zone 2',
107+
zoneLocations: ['Location 2'],
108+
},
109+
]}
110+
/>
111+
);
112+
113+
const searchInput = screen.getByLabelText('Search for a location');
114+
expect(searchInput).to.be.visible;
115+
userEvent.type(searchInput, 'Bra');
116+
const rows = screen.getAllByRole('row');
117+
expect(rows).to.have.lengthOf(3); // 1 header, 2 items
118+
expect(within(rows[1]).getByText('Slovakia (SK)')).to.be.visible;
119+
expect(within(rows[1]).getByText('Zone 2 (Location 2)')).to.be.visible;
120+
expect(within(rows[2]).getByText('Slovakia - Bratislava (SK-BA)')).to.be
121+
.visible;
122+
expect(within(rows[2]).getByText('Zone 2 (Location 2)')).to.be.visible;
123+
});
58124
});

packages/compass-global-writes/src/components/shard-zones-table.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const containerStyles = css({
2929
interface ShardZoneRow {
3030
locationName: string;
3131
zone: string;
32-
searchable: string;
3332
}
3433

3534
interface ShardZoneExpandableRow extends ShardZoneRow {
@@ -46,6 +45,7 @@ const columns: Array<LGColumnDef<ShardZoneRow>> = [
4645
accessorKey: 'zone',
4746
header: 'Zone',
4847
enableSorting: true,
48+
enableGlobalFilter: false,
4949
},
5050
];
5151

@@ -57,7 +57,6 @@ const parseRow = ({
5757
}: ShardZoneData): ShardZoneRow => ({
5858
locationName: `${readableName} (${isoCode})`,
5959
zone: `${zoneName} (${zoneLocations.join(', ')})`,
60-
searchable: readableName,
6160
});
6261

6362
const parseData = (shardZones: ShardZoneData[]): ShardZoneExpandableRow[] => {

0 commit comments

Comments
 (0)