cozy-search 0.24.0 → 0.24.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.
@@ -19,9 +19,11 @@ var useConversation = function useConversation() {
19
19
  setIsOpenSearchConversation = _useAssistant.setIsOpenSearchConversation;
20
20
 
21
21
  var goToConversation = function goToConversation(conversationId) {
22
+ var _match$;
23
+
22
24
  // Extract base path safely by identifying the start of '/assistant' if it exists.
23
25
  var match = location.pathname.match(/^(.*?)(\/assistant(\/|$).*|$)/);
24
- var basePath = ((match === null || match === void 0 ? void 0 : match[1]) || location.pathname).replace(/\/$/, '');
26
+ var basePath = ((_match$ = match === null || match === void 0 ? void 0 : match[1]) !== null && _match$ !== void 0 ? _match$ : location.pathname).replace(/\/$/, '');
25
27
  var newPathname = "".concat(basePath, "/assistant/").concat(conversationId);
26
28
  setIsOpenSearchConversation(false);
27
29
  navigate({
@@ -66,6 +66,18 @@ describe('useConversation', () => {
66
66
  hash: ''
67
67
  });
68
68
  });
69
+ it('navigates correctly when assistant route is at the root', () => {
70
+ mockLocation.pathname = '/assistant/old-convo-123';
71
+ const { result } = renderHook(() => useConversation());
72
+ act(() => {
73
+ result.current.goToConversation('new-convo-456');
74
+ });
75
+ expect(mockNavigate).toHaveBeenCalledWith({
76
+ pathname: '/assistant/new-convo-456',
77
+ search: '',
78
+ hash: ''
79
+ });
80
+ });
69
81
  it('preserves search query and hash fragments', () => {
70
82
  mockLocation = {
71
83
  pathname: '/base',
@@ -82,6 +82,21 @@ describe('useConversation', () => {
82
82
  })
83
83
  })
84
84
 
85
+ it('navigates correctly when assistant route is at the root', () => {
86
+ mockLocation.pathname = '/assistant/old-convo-123'
87
+ const { result } = renderHook(() => useConversation())
88
+
89
+ act(() => {
90
+ result.current.goToConversation('new-convo-456')
91
+ })
92
+
93
+ expect(mockNavigate).toHaveBeenCalledWith({
94
+ pathname: '/assistant/new-convo-456',
95
+ search: '',
96
+ hash: ''
97
+ })
98
+ })
99
+
85
100
  it('preserves search query and hash fragments', () => {
86
101
  mockLocation = {
87
102
  pathname: '/base',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cozy-search",
3
3
  "description": "UI components about search bar and IA assistant",
4
- "version": "0.24.0",
4
+ "version": "0.24.1",
5
5
  "author": {
6
6
  "name": "Cozy Cloud",
7
7
  "url": "https://github.com/cozy"
@@ -92,5 +92,5 @@
92
92
  "lint": "cd .. && yarn eslint --ext js,jsx,ts packages/cozy-search"
93
93
  },
94
94
  "types": "dist/index.d.ts",
95
- "gitHead": "9655a128354d92bbb108ed6ec830704dd158d48a"
95
+ "gitHead": "a0c69ea92558eebaef06da8fd0d2593213adce76"
96
96
  }