@oslokommune/punkt-react 19.18.0 → 19.18.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-react",
3
- "version": "19.18.0",
3
+ "version": "19.18.1",
4
4
  "description": "React komponentbibliotek til Punkt, designsystem for Oslo kommune",
5
5
  "homepage": "https://punkt.oslo.kommune.no",
6
6
  "author": "Team Designsystem, Oslo kommune",
@@ -43,7 +43,7 @@
43
43
  "@eslint/js": "^10.0.1",
44
44
  "@oslokommune/punkt-assets": "^19.14.2",
45
45
  "@oslokommune/punkt-css": "^19.16.2",
46
- "@testing-library/jest-dom": "^6.9.1",
46
+ "@testing-library/jest-dom": "^7.0.1",
47
47
  "@testing-library/react": "^16.3.2",
48
48
  "@testing-library/user-event": "^14.6.1",
49
49
  "@types/jest-axe": "^3.5.9",
@@ -58,7 +58,7 @@
58
58
  "eslint-plugin-react-hooks": "^7.1.1",
59
59
  "eslint-plugin-simple-import-sort": "^13.0.0",
60
60
  "globals": "^17.6.0",
61
- "jest-axe": "^10.0.0",
61
+ "jest-axe": "^11.0.0",
62
62
  "jsdom": "^29.1.1",
63
63
  "prettier": "^3.8.4",
64
64
  "react-hook-form": "^7.79.0",
@@ -102,5 +102,5 @@
102
102
  "url": "https://github.com/oslokommune/punkt/issues"
103
103
  },
104
104
  "license": "MIT",
105
- "gitHead": "6b3cae25111200ae8f8f3673e13c8b6379337ecf"
105
+ "gitHead": "7c8508f96a754c830bc794977065f4c162f45240"
106
106
  }
@@ -1,4 +1,5 @@
1
1
  import '@testing-library/jest-dom'
2
+ import { vi } from 'vitest'
2
3
 
3
4
  import { render, screen, waitFor } from '../../utils/test-utils'
4
5
  import { PktIcon } from './Icon'
@@ -109,4 +110,25 @@ describe('PktIcon', () => {
109
110
  expect(svg).toHaveAttribute('aria-label', 'chevron-right')
110
111
  })
111
112
  })
113
+
114
+ describe('Restricted storage', () => {
115
+ test('loads when reading sessionStorage throws', async () => {
116
+ const original = Object.getOwnPropertyDescriptor(globalThis, 'sessionStorage')
117
+ Object.defineProperty(globalThis, 'sessionStorage', {
118
+ configurable: true,
119
+ get() {
120
+ throw new DOMException('Access is denied for this document.', 'SecurityError')
121
+ },
122
+ })
123
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
124
+ vi.resetModules()
125
+ try {
126
+ await expect(import('./Icon')).resolves.toHaveProperty('PktIcon')
127
+ } finally {
128
+ if (original) Object.defineProperty(globalThis, 'sessionStorage', original)
129
+ else delete (globalThis as { sessionStorage?: Storage }).sessionStorage
130
+ warn.mockRestore()
131
+ }
132
+ })
133
+ })
112
134
  })
@@ -22,7 +22,13 @@ const dlCache: { [key: string]: Promise<string> } = {}
22
22
  const MAX_RETRIES = 2
23
23
  const RETRY_DELAY = 1500
24
24
 
25
- const isSessionStorageAvailable = typeof Storage !== 'undefined' && typeof sessionStorage !== 'undefined'
25
+ const isSessionStorageAvailable = (() => {
26
+ try {
27
+ return typeof Storage !== 'undefined' && typeof sessionStorage !== 'undefined'
28
+ } catch {
29
+ return false
30
+ }
31
+ })()
26
32
 
27
33
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect
28
34