paths.spec.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. import { GIT_REPO_LINK } from 'lib/constants';
  2. import * as paths from 'lib/paths';
  3. import { RouteParams } from 'lib/paths';
  4. const clusterName = 'test-cluster-name';
  5. const groupId = 'test-group-id';
  6. const schemaId = 'test-schema-id';
  7. const topicId = 'test-topic-id';
  8. const brokerId = 'test-Broker-id';
  9. const connectName = 'test-connect-name';
  10. const connectorName = 'test-connector-name';
  11. describe('Paths', () => {
  12. it('gitCommitPath', () => {
  13. expect(paths.gitCommitPath('1234567gh')).toEqual(
  14. `${GIT_REPO_LINK}/commit/1234567gh`
  15. );
  16. });
  17. it('getNonExactPath', () => {
  18. expect(paths.getNonExactPath('')).toEqual('/*');
  19. expect(paths.getNonExactPath('/clusters')).toEqual('/clusters/*');
  20. });
  21. it('clusterPath', () => {
  22. expect(paths.clusterPath(clusterName)).toEqual(
  23. `/ui/clusters/${clusterName}`
  24. );
  25. expect(paths.clusterPath()).toEqual(
  26. paths.clusterPath(RouteParams.clusterName)
  27. );
  28. });
  29. it('clusterBrokersPath', () => {
  30. expect(paths.clusterBrokersPath(clusterName)).toEqual(
  31. `${paths.clusterPath(clusterName)}/brokers`
  32. );
  33. expect(paths.clusterBrokersPath()).toEqual(
  34. paths.clusterBrokersPath(RouteParams.clusterName)
  35. );
  36. expect(paths.clusterBrokerPath(clusterName, brokerId)).toEqual(
  37. `${paths.clusterPath(clusterName)}/brokers/${brokerId}`
  38. );
  39. expect(paths.clusterBrokerPath()).toEqual(
  40. paths.clusterBrokerPath(RouteParams.clusterName, RouteParams.brokerId)
  41. );
  42. expect(paths.clusterBrokerMetricsPath(clusterName, brokerId)).toEqual(
  43. `${paths.clusterPath(clusterName)}/brokers/${brokerId}/metrics`
  44. );
  45. expect(paths.clusterBrokerMetricsPath()).toEqual(
  46. paths.clusterBrokerMetricsPath(
  47. RouteParams.clusterName,
  48. RouteParams.brokerId
  49. )
  50. );
  51. });
  52. it('clusterConsumerGroupsPath', () => {
  53. expect(paths.clusterConsumerGroupsPath(clusterName)).toEqual(
  54. `${paths.clusterPath(clusterName)}/consumer-groups`
  55. );
  56. expect(paths.clusterConsumerGroupsPath()).toEqual(
  57. paths.clusterConsumerGroupsPath(RouteParams.clusterName)
  58. );
  59. });
  60. it('clusterConsumerGroupDetailsPath', () => {
  61. expect(paths.clusterConsumerGroupDetailsPath(clusterName, groupId)).toEqual(
  62. `${paths.clusterConsumerGroupsPath(clusterName)}/${groupId}`
  63. );
  64. expect(paths.clusterConsumerGroupDetailsPath()).toEqual(
  65. paths.clusterConsumerGroupDetailsPath(
  66. RouteParams.clusterName,
  67. RouteParams.consumerGroupID
  68. )
  69. );
  70. });
  71. it('clusterConsumerGroupResetOffsetsPath', () => {
  72. expect(
  73. paths.clusterConsumerGroupResetOffsetsPath(clusterName, groupId)
  74. ).toEqual(
  75. `${paths.clusterConsumerGroupDetailsPath(
  76. clusterName,
  77. groupId
  78. )}/reset-offsets`
  79. );
  80. expect(paths.clusterConsumerGroupResetOffsetsPath()).toEqual(
  81. paths.clusterConsumerGroupResetOffsetsPath(
  82. RouteParams.clusterName,
  83. RouteParams.consumerGroupID
  84. )
  85. );
  86. });
  87. it('clusterSchemasPath', () => {
  88. expect(paths.clusterSchemasPath(clusterName)).toEqual(
  89. `${paths.clusterPath(clusterName)}/schemas`
  90. );
  91. expect(paths.clusterSchemasPath()).toEqual(
  92. paths.clusterSchemasPath(RouteParams.clusterName)
  93. );
  94. });
  95. it('clusterSchemaNewPath', () => {
  96. expect(paths.clusterSchemaNewPath(clusterName)).toEqual(
  97. `${paths.clusterSchemasPath(clusterName)}/create-new`
  98. );
  99. expect(paths.clusterSchemaNewPath()).toEqual(
  100. paths.clusterSchemaNewPath(RouteParams.clusterName)
  101. );
  102. });
  103. it('clusterSchemaPath', () => {
  104. expect(paths.clusterSchemaPath(clusterName, schemaId)).toEqual(
  105. `${paths.clusterSchemasPath(clusterName)}/${schemaId}`
  106. );
  107. expect(paths.clusterSchemaPath()).toEqual(
  108. paths.clusterSchemaPath(RouteParams.clusterName, RouteParams.subject)
  109. );
  110. });
  111. it('clusterSchemaEditPath', () => {
  112. expect(paths.clusterSchemaEditPath(clusterName, schemaId)).toEqual(
  113. `${paths.clusterSchemaPath(clusterName, schemaId)}/edit`
  114. );
  115. expect(paths.clusterSchemaEditPath()).toEqual(
  116. paths.clusterSchemaEditPath(RouteParams.clusterName, RouteParams.subject)
  117. );
  118. });
  119. it('clusterSchemaComparePath', () => {
  120. expect(paths.clusterSchemaComparePath(clusterName, schemaId)).toEqual(
  121. `${paths.clusterSchemaPath(clusterName, schemaId)}/compare`
  122. );
  123. expect(paths.clusterSchemaComparePath()).toEqual(
  124. paths.clusterSchemaComparePath(
  125. RouteParams.clusterName,
  126. RouteParams.subject
  127. )
  128. );
  129. });
  130. it('clusterTopicsPath', () => {
  131. expect(paths.clusterTopicsPath(clusterName)).toEqual(
  132. `${paths.clusterPath(clusterName)}/all-topics`
  133. );
  134. expect(paths.clusterTopicsPath()).toEqual(
  135. paths.clusterTopicsPath(RouteParams.clusterName)
  136. );
  137. });
  138. it('clusterTopicNewPath', () => {
  139. expect(paths.clusterTopicNewPath(clusterName)).toEqual(
  140. `${paths.clusterTopicsPath(clusterName)}/create-new-topic`
  141. );
  142. expect(paths.clusterTopicNewPath()).toEqual(
  143. paths.clusterTopicNewPath(RouteParams.clusterName)
  144. );
  145. });
  146. it('clusterTopicPath', () => {
  147. expect(paths.clusterTopicPath(clusterName, topicId)).toEqual(
  148. `${paths.clusterTopicsPath(clusterName)}/${topicId}`
  149. );
  150. expect(paths.clusterTopicPath()).toEqual(
  151. paths.clusterTopicPath(RouteParams.clusterName, RouteParams.topicName)
  152. );
  153. });
  154. it('clusterTopicSettingsPath', () => {
  155. expect(paths.clusterTopicSettingsPath(clusterName, topicId)).toEqual(
  156. `${paths.clusterTopicPath(clusterName, topicId)}/settings`
  157. );
  158. expect(paths.clusterTopicSettingsPath()).toEqual(
  159. paths.clusterTopicSettingsPath(
  160. RouteParams.clusterName,
  161. RouteParams.topicName
  162. )
  163. );
  164. });
  165. it('clusterTopicConsumerGroupsPath', () => {
  166. expect(paths.clusterTopicConsumerGroupsPath(clusterName, topicId)).toEqual(
  167. `${paths.clusterTopicPath(clusterName, topicId)}/consumer-groups`
  168. );
  169. expect(paths.clusterTopicConsumerGroupsPath()).toEqual(
  170. paths.clusterTopicConsumerGroupsPath(
  171. RouteParams.clusterName,
  172. RouteParams.topicName
  173. )
  174. );
  175. });
  176. it('clusterTopicMessagesPath', () => {
  177. expect(paths.clusterTopicMessagesPath(clusterName, topicId)).toEqual(
  178. `${paths.clusterTopicPath(clusterName, topicId)}/messages`
  179. );
  180. expect(paths.clusterTopicMessagesPath()).toEqual(
  181. paths.clusterTopicMessagesPath(
  182. RouteParams.clusterName,
  183. RouteParams.topicName
  184. )
  185. );
  186. });
  187. it('clusterTopicSendMessagePath', () => {
  188. expect(paths.clusterTopicSendMessagePath(clusterName, topicId)).toEqual(
  189. `${paths.clusterTopicPath(clusterName, topicId)}/message`
  190. );
  191. expect(paths.clusterTopicSendMessagePath()).toEqual(
  192. paths.clusterTopicSendMessagePath(
  193. RouteParams.clusterName,
  194. RouteParams.topicName
  195. )
  196. );
  197. });
  198. it('clusterTopicEditPath', () => {
  199. expect(paths.clusterTopicEditPath(clusterName, topicId)).toEqual(
  200. `${paths.clusterTopicPath(clusterName, topicId)}/edit`
  201. );
  202. expect(paths.clusterTopicEditPath()).toEqual(
  203. paths.clusterTopicEditPath(RouteParams.clusterName, RouteParams.topicName)
  204. );
  205. });
  206. it('clusterTopicCopyPath', () => {
  207. expect(paths.clusterTopicCopyPath(clusterName)).toEqual(
  208. `${paths.clusterTopicsPath(clusterName)}/copy`
  209. );
  210. expect(paths.clusterTopicCopyPath()).toEqual(
  211. paths.clusterTopicCopyPath(RouteParams.clusterName)
  212. );
  213. });
  214. it('clusterTopicStatisticsPath', () => {
  215. expect(paths.clusterTopicStatisticsPath(clusterName, topicId)).toEqual(
  216. `${paths.clusterTopicPath(clusterName, topicId)}/statistics`
  217. );
  218. expect(paths.clusterTopicStatisticsPath()).toEqual(
  219. paths.clusterTopicStatisticsPath(
  220. RouteParams.clusterName,
  221. RouteParams.topicName
  222. )
  223. );
  224. });
  225. it('clusterConnectsPath', () => {
  226. expect(paths.clusterConnectsPath(clusterName)).toEqual(
  227. `${paths.clusterPath(clusterName)}/connects`
  228. );
  229. expect(paths.clusterConnectsPath()).toEqual(
  230. paths.clusterConnectsPath(RouteParams.clusterName)
  231. );
  232. });
  233. it('clusterConnectorsPath', () => {
  234. expect(paths.clusterConnectorsPath(clusterName)).toEqual(
  235. `${paths.clusterPath(clusterName)}/connectors`
  236. );
  237. expect(paths.clusterConnectorsPath()).toEqual(
  238. paths.clusterConnectorsPath(RouteParams.clusterName)
  239. );
  240. });
  241. it('clusterConnectorNewPath', () => {
  242. expect(paths.clusterConnectorNewPath(clusterName)).toEqual(
  243. `${paths.clusterConnectorsPath(clusterName)}/create-new`
  244. );
  245. expect(paths.clusterConnectorNewPath()).toEqual(
  246. paths.clusterConnectorNewPath(RouteParams.clusterName)
  247. );
  248. });
  249. it('clusterConnectConnectorPath', () => {
  250. expect(
  251. paths.clusterConnectConnectorPath(clusterName, connectName, connectorName)
  252. ).toEqual(
  253. `${paths.clusterConnectsPath(
  254. clusterName
  255. )}/${connectName}/connectors/${connectorName}`
  256. );
  257. expect(paths.clusterConnectConnectorPath()).toEqual(
  258. paths.clusterConnectConnectorPath(
  259. RouteParams.clusterName,
  260. RouteParams.connectName,
  261. RouteParams.connectorName
  262. )
  263. );
  264. });
  265. it('clusterConnectConnectorsPath', () => {
  266. expect(
  267. paths.clusterConnectConnectorsPath(clusterName, connectName)
  268. ).toEqual(
  269. `${paths.clusterConnectsPath(clusterName)}/${connectName}/connectors`
  270. );
  271. expect(paths.clusterConnectConnectorsPath()).toEqual(
  272. paths.clusterConnectConnectorsPath(
  273. RouteParams.clusterName,
  274. RouteParams.connectName
  275. )
  276. );
  277. });
  278. it('clusterConnectConnectorEditPath', () => {
  279. expect(
  280. paths.clusterConnectConnectorEditPath(
  281. clusterName,
  282. connectName,
  283. connectorName
  284. )
  285. ).toEqual(
  286. `${paths.clusterConnectConnectorPath(
  287. clusterName,
  288. connectName,
  289. connectorName
  290. )}/edit`
  291. );
  292. expect(paths.clusterConnectConnectorEditPath()).toEqual(
  293. paths.clusterConnectConnectorEditPath(
  294. RouteParams.clusterName,
  295. RouteParams.connectName,
  296. RouteParams.connectorName
  297. )
  298. );
  299. });
  300. it('clusterConnectConnectorTasksPath', () => {
  301. expect(
  302. paths.clusterConnectConnectorTasksPath(
  303. clusterName,
  304. connectName,
  305. connectorName
  306. )
  307. ).toEqual(
  308. `${paths.clusterConnectConnectorPath(
  309. clusterName,
  310. connectName,
  311. connectorName
  312. )}/tasks`
  313. );
  314. expect(paths.clusterConnectConnectorTasksPath()).toEqual(
  315. paths.clusterConnectConnectorTasksPath(
  316. RouteParams.clusterName,
  317. RouteParams.connectName,
  318. RouteParams.connectorName
  319. )
  320. );
  321. });
  322. it('clusterConnectConnectorConfigPath', () => {
  323. expect(
  324. paths.clusterConnectConnectorConfigPath(
  325. clusterName,
  326. connectName,
  327. connectorName
  328. )
  329. ).toEqual(
  330. `${paths.clusterConnectConnectorPath(
  331. clusterName,
  332. connectName,
  333. connectorName
  334. )}/config`
  335. );
  336. expect(paths.clusterConnectConnectorConfigPath()).toEqual(
  337. paths.clusterConnectConnectorConfigPath(
  338. RouteParams.clusterName,
  339. RouteParams.connectName,
  340. RouteParams.connectorName
  341. )
  342. );
  343. });
  344. it('clusterKsqlDbPath', () => {
  345. expect(paths.clusterKsqlDbPath(clusterName)).toEqual(
  346. `${paths.clusterPath(clusterName)}/ksqldb`
  347. );
  348. expect(paths.clusterKsqlDbPath()).toEqual(
  349. paths.clusterKsqlDbPath(RouteParams.clusterName)
  350. );
  351. });
  352. it('clusterKsqlDbQueryPath', () => {
  353. expect(paths.clusterKsqlDbQueryPath(clusterName)).toEqual(
  354. `${paths.clusterKsqlDbPath(clusterName)}/query`
  355. );
  356. expect(paths.clusterKsqlDbQueryPath()).toEqual(
  357. paths.clusterKsqlDbQueryPath(RouteParams.clusterName)
  358. );
  359. });
  360. it('clusterKsqlDbTablesPath', () => {
  361. expect(paths.clusterKsqlDbTablesPath(clusterName)).toEqual(
  362. `${paths.clusterKsqlDbPath(clusterName)}/tables`
  363. );
  364. expect(paths.clusterKsqlDbTablesPath()).toEqual(
  365. paths.clusterKsqlDbTablesPath(RouteParams.clusterName)
  366. );
  367. });
  368. it('clusterKsqlDbStreamsPath', () => {
  369. expect(paths.clusterKsqlDbStreamsPath(clusterName)).toEqual(
  370. `${paths.clusterKsqlDbPath(clusterName)}/streams`
  371. );
  372. expect(paths.clusterKsqlDbStreamsPath()).toEqual(
  373. paths.clusterKsqlDbStreamsPath(RouteParams.clusterName)
  374. );
  375. });
  376. });