diff --git a/frontend/packages/shared/src/navigation/PackagesRouter/PackagesRouter.test.ts b/frontend/packages/shared/src/navigation/PackagesRouter/PackagesRouter.test.ts index 4b2abb39407..c6204cfd3a3 100644 --- a/frontend/packages/shared/src/navigation/PackagesRouter/PackagesRouter.test.ts +++ b/frontend/packages/shared/src/navigation/PackagesRouter/PackagesRouter.test.ts @@ -5,13 +5,6 @@ const mockApp: string = 'app'; describe('PackagesRouter', () => { describe('constructor', () => { - it('should initialize app and org properties', () => { - const packagesRouter = new PackagesRouter({ org: mockOrg, app: mockApp }); - - expect(packagesRouter['app']).toEqual(mockApp); - expect(packagesRouter['org']).toEqual(mockOrg); - }); - it('should default to empty strings if app and org are not provided', () => { const routerWithoutParams = new PackagesRouter({}); expect(routerWithoutParams['app']).toEqual(''); @@ -20,7 +13,7 @@ describe('PackagesRouter', () => { }); describe('navigateToPackage', () => { - it('should navigate to the correct URL without subUrl', () => { + it('should navigate to the correct "editor/overview page when the location parameter is set to "editorOverview"', () => { const packagesRouter = new PackagesRouter({ org: mockOrg, app: mockApp }); const expectedUrl = `/editor/${mockOrg}/${mockApp}/overview`; @@ -36,11 +29,11 @@ describe('PackagesRouter', () => { expect(assignMock).toHaveBeenCalledWith(expectedUrl); }); - it('should navigate to the correct URL with subUrl', () => { + it('should navigate to the correct URL and include queryParams', () => { const packagesRouter = new PackagesRouter({ org: mockOrg, app: mockApp }); - const mockSubUrl = '?layout=123'; - const expectedUrl = `/editor/${mockOrg}/${mockApp}/ui-editor${mockSubUrl}`; + const mockQueryParams = '?layout=123'; + const expectedUrl = `/editor/${mockOrg}/${mockApp}/ui-editor${mockQueryParams}`; const assignMock = jest.fn(); Object.defineProperty(window, 'location', { @@ -48,7 +41,7 @@ describe('PackagesRouter', () => { writable: true, }); - packagesRouter.navigateToPackage('editorUiEditor', mockSubUrl); + packagesRouter.navigateToPackage('editorUiEditor', mockQueryParams); expect(assignMock).toHaveBeenCalledWith(expectedUrl); }); diff --git a/frontend/packages/shared/src/navigation/PackagesRouter/PackagesRouter.ts b/frontend/packages/shared/src/navigation/PackagesRouter/PackagesRouter.ts index 37596b345cf..9e2a1207761 100644 --- a/frontend/packages/shared/src/navigation/PackagesRouter/PackagesRouter.ts +++ b/frontend/packages/shared/src/navigation/PackagesRouter/PackagesRouter.ts @@ -10,7 +10,7 @@ type PackagesRoute = | 'preview' | 'editorPublish'; -const packagesRoutes = { +const packagesRoutes: Record = { dashboard: '/dashboard', editorOverview: '/editor/{{org}}/{{app}}/overview', editorUiEditor: '/editor/{{org}}/{{app}}/ui-editor', @@ -27,8 +27,8 @@ export class PackagesRouter { this.org = this.paramsOptions.org ?? ''; } - public navigateToPackage(packageRoute: PackagesRoute, subUrl?: string): void { - window.location.assign(`${this.getPackageNavigationUrl(packageRoute)}${subUrl ? subUrl : ''}`); + public navigateToPackage(packageRoute: PackagesRoute, queryParams?: string): void { + window.location.assign(`${this.getPackageNavigationUrl(packageRoute)}${queryParams ?? ''}`); } public getPackageNavigationUrl(packageRoute: PackagesRoute): string {