@availity/mui-spaces 1.0.30 → 1.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [1.0.31](https://github.com/Availity/element/compare/@availity/mui-spaces@1.0.30...@availity/mui-spaces@1.0.31) (2025-09-22)
6
+
5
7
  ## [1.0.30](https://github.com/Availity/element/compare/@availity/mui-spaces@1.0.29...@availity/mui-spaces@1.0.30) (2025-08-21)
6
8
 
7
9
 
package/dist/index.js CHANGED
@@ -616,14 +616,14 @@ var Spaces = ({
616
616
  }
617
617
  if (spaceIds && spaceIds.length > 0) {
618
618
  for (const id of spaceIds) {
619
- if (!(spacesMap.has(id) || configIdsMap.has(id))) {
619
+ if (id && typeof id === "string" && id.trim() && !(spacesMap.has(id) || configIdsMap.has(id))) {
620
620
  spaceIdsToQuery.add(id);
621
621
  }
622
622
  }
623
623
  }
624
624
  if (payerIds && payerIds.length > 0) {
625
625
  for (const pid of payerIds) {
626
- if (!payerIdsMap.has(pid)) {
626
+ if (pid && typeof pid === "string" && pid.trim() && !payerIdsMap.has(pid)) {
627
627
  payerIdsToQuery.add(pid);
628
628
  }
629
629
  }
package/dist/index.mjs CHANGED
@@ -574,14 +574,14 @@ var Spaces = ({
574
574
  }
575
575
  if (spaceIds && spaceIds.length > 0) {
576
576
  for (const id of spaceIds) {
577
- if (!(spacesMap.has(id) || configIdsMap.has(id))) {
577
+ if (id && typeof id === "string" && id.trim() && !(spacesMap.has(id) || configIdsMap.has(id))) {
578
578
  spaceIdsToQuery.add(id);
579
579
  }
580
580
  }
581
581
  }
582
582
  if (payerIds && payerIds.length > 0) {
583
583
  for (const pid of payerIds) {
584
- if (!payerIdsMap.has(pid)) {
584
+ if (pid && typeof pid === "string" && pid.trim() && !payerIdsMap.has(pid)) {
585
585
  payerIdsToQuery.add(pid);
586
586
  }
587
587
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@availity/mui-spaces",
3
- "version": "1.0.30",
3
+ "version": "1.0.31",
4
4
  "description": "Availity MUI Spaces Component - part of the @availity/element design system",
5
5
  "keywords": [
6
6
  "react",
@@ -3,6 +3,7 @@ import { useState } from 'react';
3
3
  import { render, waitFor, fireEvent } from '@testing-library/react';
4
4
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
5
5
  import { Spaces, useSpaces, useSpacesContext } from '..';
6
+ import { fetchAllSpaces } from './spaces-data';
6
7
 
7
8
  // eslint-disable-next-line @nx/enforce-module-boundaries
8
9
  import { server } from '../../../mock/src/lib/server';
@@ -258,3 +259,95 @@ it('returns first payer space with when no spaceId passed', async () => {
258
259
  expect(spc1).toBeDefined();
259
260
  expect(spc2).toBeDefined();
260
261
  });
262
+ describe('ID validation', () => {
263
+ let mockFetchAllSpaces: jest.SpyInstance;
264
+
265
+ beforeEach(() => {
266
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
267
+ mockFetchAllSpaces = jest.spyOn(require('./spaces-data'), 'fetchAllSpaces').mockResolvedValue([]);
268
+ });
269
+
270
+ afterEach(() => {
271
+ mockFetchAllSpaces.mockRestore();
272
+ });
273
+
274
+ it('filters invalid spaceIds before querying', async () => {
275
+ mockFetchAllSpaces.mockResolvedValue([]);
276
+ const queryClient = new QueryClient();
277
+
278
+ render(
279
+ <QueryClientProvider client={queryClient}>
280
+ <Spaces spaceIds={['valid-id', null, undefined, '', ' ', 123 as any] as any}>
281
+ <div>test</div>
282
+ </Spaces>
283
+ </QueryClientProvider>
284
+ );
285
+
286
+ await waitFor(() => {
287
+ expect(mockFetchAllSpaces).toHaveBeenCalledWith(
288
+ expect.objectContaining({
289
+ variables: expect.objectContaining({
290
+ ids: ['valid-id'],
291
+ }),
292
+ })
293
+ );
294
+ });
295
+ });
296
+
297
+ it('avoids querying if no valid spaceIds exist', async () => {
298
+ mockFetchAllSpaces.mockResolvedValue([]);
299
+ const queryClient = new QueryClient();
300
+
301
+ render(
302
+ <QueryClientProvider client={queryClient}>
303
+ <Spaces spaceIds={[null, undefined, '', ' ', 123 as any] as any}>
304
+ <div>test</div>
305
+ </Spaces>
306
+ </QueryClientProvider>
307
+ );
308
+
309
+ await waitFor(() => {
310
+ expect(mockFetchAllSpaces).not.toHaveBeenCalled();
311
+ });
312
+ });
313
+
314
+ it('filters invalid payerIds before querying', async () => {
315
+ mockFetchAllSpaces.mockResolvedValue([]);
316
+ const queryClient = new QueryClient();
317
+
318
+ render(
319
+ <QueryClientProvider client={queryClient}>
320
+ <Spaces payerIds={['valid-payer', null, undefined, '', ' ', 456 as any] as any}>
321
+ <div>test</div>
322
+ </Spaces>
323
+ </QueryClientProvider>
324
+ );
325
+
326
+ await waitFor(() => {
327
+ expect(mockFetchAllSpaces).toHaveBeenCalledWith(
328
+ expect.objectContaining({
329
+ variables: expect.objectContaining({
330
+ payerIDs: ['valid-payer'],
331
+ }),
332
+ })
333
+ );
334
+ });
335
+ });
336
+
337
+ it('avoids querying if no valid payerIds exist', async () => {
338
+ mockFetchAllSpaces.mockResolvedValue([]);
339
+ const queryClient = new QueryClient();
340
+
341
+ render(
342
+ <QueryClientProvider client={queryClient}>
343
+ <Spaces payerIds={[null, undefined, '', ' ', 456 as any] as any}>
344
+ <div>test</div>
345
+ </Spaces>
346
+ </QueryClientProvider>
347
+ );
348
+
349
+ await waitFor(() => {
350
+ expect(mockFetchAllSpaces).not.toHaveBeenCalled();
351
+ });
352
+ });
353
+ });
@@ -57,7 +57,7 @@ export const Spaces = ({
57
57
 
58
58
  if (spaceIds && spaceIds.length > 0) {
59
59
  for (const id of spaceIds) {
60
- if (!(spacesMap.has(id) || configIdsMap.has(id))) {
60
+ if (id && typeof id === 'string' && id.trim() && !(spacesMap.has(id) || configIdsMap.has(id))) {
61
61
  spaceIdsToQuery.add(id);
62
62
  }
63
63
  }
@@ -65,7 +65,7 @@ export const Spaces = ({
65
65
 
66
66
  if (payerIds && payerIds.length > 0) {
67
67
  for (const pid of payerIds) {
68
- if (!payerIdsMap.has(pid)) {
68
+ if (pid && typeof pid === 'string' && pid.trim() && !payerIdsMap.has(pid)) {
69
69
  payerIdsToQuery.add(pid);
70
70
  }
71
71
  }