mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-04 16:09:05 +00:00
### **User description** with this PR the coverage is -----------------------------------------------|---------|----------|---------|---------|------------------------------------------------------------------------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s -----------------------------------------------|---------|----------|---------|---------|------------------------------------------------------------------------------------- All files | 48.05 | 82.25 | 50.81 | 48.05 | ___ ### **PR Type** Enhancement, Tests, Bug fix ___ ### **Description** - Add comprehensive unit tests across modules - Expose component internals for testability - Safely access org identifier with optional chaining - Minor exports to composables for testing ___ ### Diagram Walkthrough ```mermaid flowchart LR components["Vue components"] expose["Expose methods/refs via defineExpose"] specs["New/expanded unit tests"] fixOrg["Optional chaining for org identifier"] composables["Composables export additions"] components -- "defineExpose, returns additions" --> expose expose -- "enables" --> specs components -- "query params use ?.identifier" --> fixOrg composables -- "export more helpers" --> specs ``` <details> <summary><h3> File Walkthrough</h3></summary> <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Bug fix</strong></td><td><details><summary>1 files</summary><table> <tr> <td><strong>index.vue</strong><dd><code>Use optional chaining for org identifier in routes</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-699c63979f851c48ad440a078e93282fd797a18fc065e5331b2e41122ddb8b69">+15/-13</a> </td> </tr> </table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>39 files</summary><table> <tr> <td><strong>Stream.vue</strong><dd><code>Expose stream form methods and state for tests</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-1a17ced9dc89022502cab0a6f9b97b413c2a2c4f8219733d063fc0180d361739">+33/-0</a> </td> </tr> <tr> <td><strong>RealTimeAlert.vue</strong><dd><code>Expose alert editor methods/data for tests</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-c3ae6b47832eb33f9ca877cc7165d079de14850e5c5d43a227102ba40326b9d8">+19/-0</a> </td> </tr> <tr> <td><strong>ExternalDestination.vue</strong><dd><code>Expose destination form functions and state</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-7ed6a9ef676d7d6db5440d4157512f731bad58716c351ca39015125a8a9d2df5">+22/-0</a> </td> </tr> <tr> <td><strong>PerformanceSummary.vue</strong><dd><code>Export additional helpers and imports for tests</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-fdf59594c111c1af03772c9deef4ba07cf2c2d00c9609737a0ea3e3c76fb1c1b">+3/-1</a> </td> </tr> <tr> <td><strong>StreamFieldInputs.vue</strong><dd><code>Expose field input handlers and state</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-c8173413939f320f197b0f8790e619da18666f79009345f72b3325e89bbb7566">+17/-0</a> </td> </tr> <tr> <td><strong>FilterGroup.vue</strong><dd><code>Expose group manipulation helpers for testing</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-8d5a73bea3aa0b5c86d48cda4a61ee3e30f27797ac2a5add1ee8bd66c75bef23">+17/-0</a> </td> </tr> <tr> <td><strong>ImportDestination.vue</strong><dd><code>Expose validation and helper functions</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-814b8ef1dbb4eebca9dfab72452d9a90d5f3fa5886dea8e82ac0bde44f66b445">+7/-0</a> </td> </tr> <tr> <td><strong>PipelinesDestinationList.vue</strong><dd><code>Expose list helper functions and selectedPerPage</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-088c66f5a34e73a5350a794a772e5d905262277337c937dd36f4295072203ebf">+6/-0</a> </td> </tr> <tr> <td><strong>SearchBar.vue</strong><dd><code>Expose additional editor and action handlers</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-81893de4edf186b0556f610acb280c87baa2ffe67d3b48a60a866094c7635baf">+11/-0</a> </td> </tr> <tr> <td><strong>ImportTemplate.vue</strong><dd><code>Expose template validation and helpers</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-d22684c5142a49b8925a9dba1ef67631128caa95de66e71ba2a5b8120a0b91c6">+6/-0</a> </td> </tr> <tr> <td><strong>IndexList.vue</strong><dd><code>Expose websocket/search helper functions</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-08f058f883b659e713e606991a7ea37ae1ff016b7cccef970489ab5840dc3d09">+11/-0</a> </td> </tr> <tr> <td><strong>ImportAlert.vue</strong><dd><code>Expose alert validation helpers</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-0f40dbf2757672e39ad16b86dddc59b568ca2e6ca36850420cd7be617da12d38">+4/-0</a> </td> </tr> <tr> <td><strong>AlertsDestinationList.vue</strong><dd><code>Expose destination list helpers for tests</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-e9d05ba6c071c0e2f5d9ef7acdef757f79910abd6897b29e27b069a10d4ba8de">+7/-0</a> </td> </tr> <tr> <td><strong>SysLog.vue</strong><dd><code>Expose syslog route helpers and state</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-2f538c29fd1d51aa470edad915666faca1deade7413645f033f2a67354b3726c">+9/-0</a> </td> </tr> <tr> <td><strong>TelegrafConfig.vue</strong><dd><code>Expose ingestionURL in setup for tests</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-f934fcfd5f71fff85e099f5ddf133a1cdd2a02aa3ade339dee73d54474480acf">+2/-0</a> </td> </tr> <tr> <td><strong>schema.vue</strong><dd><code>Expose schema helpers and formatters</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-9196be2ccae4054a00b0b1aa9d1e87b366c10920d6eaf9ef8c6e6293d50bcf46">+7/-0</a> </td> </tr> <tr> <td><strong>AssociatedRegexPatterns.vue</strong><dd><code>Expose pattern state/check helpers</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-c6fce5e1c83798991b6ff19effb23c67af59f38fac0b9e56dcab7a09d139f550">+6/-1</a> </td> </tr> <tr> <td><strong>AddFolder.vue</strong><dd><code>Return defaultValue for tests</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-41d2f8fac44084c004d8386ea4cc32e9c5d3e33266c4009cc855e57fb00a41af">+1/-0</a> </td> </tr> <tr> <td><strong>ImportRegexPattern.vue</strong><dd><code>Expose regex pattern validation and helpers</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-e8e1bcb5a02311504d7d571090eab27a270aaa71cae185ad2703023e2e70a31e">+4/-0</a> </td> </tr> <tr> <td><strong>SearchSchedulersList.vue</strong><dd><code>Expose date helpers and router</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-0c0a4097c53f07712d35562b1336602bf24faddedab77a9f5717f5582dcac2f1">+5/-0</a> </td> </tr> <tr> <td><strong>MoveAcrossFolders.vue</strong><dd><code>Expose getModuleName from setup</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-3826ffbf7e4cbae5b621527c9df856e1bd3b349b78d4a6c514b6967636d04237">+1/-0</a> </td> </tr> <tr> <td><strong>SearchResult.vue</strong><dd><code>Expose row/partition helpers and column sizes</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-5e65533aa4754bb6d0074fda18ffc1ecacded3b9ca6bc28a161c3f6b12f20195">+5/-0</a> </td> </tr> <tr> <td><strong>AddUpdateTicket.vue</strong><dd><code>Expose validation/upload methods via expose</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-bd6f97ffe635a2127610e0bbc94b1c9fe40a6ca1dff98e72efc4a449116c59db">+2/-0</a> </td> </tr> <tr> <td><strong>usage.vue</strong><dd><code>Expose getUsage and router</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-87c1e1d75e488a25773db68ada1e49913ad50be7971fbb588939941a3ea6302b">+2/-0</a> </td> </tr> <tr> <td><strong>Databricks.vue</strong><dd><code>Expose database config state</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-2ff8f0c23b75de8b87f86d00af9de4f6c8ceb335ade6cbef227cb37f26d42ae6">+4/-0</a> </td> </tr> <tr> <td><strong>SqlServer.vue</strong><dd><code>Expose database config state</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-23653eb1e4b5fa9fc519ac44cdf06b01e645d61c86340e59fcf58eb11702008f">+5/-0</a> </td> </tr> <tr> <td><strong>JsonPreview.vue</strong><dd><code>Expose getTracesStreams function</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-3985073134d35ff074742944b114d0905524038b42e6d2ac887fef2c8436fb16">+1/-0</a> </td> </tr> <tr> <td><strong>VisualizeLogsQuery.vue</strong><dd><code>Expose hovered series and metadata</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-979b01d943d58c5d70faeeac5948b7f02f0b2392a12b84ef07ba7f7393ab0261">+2/-0</a> </td> </tr> <tr> <td><strong>FrontendRumConfig.vue</strong><dd><code>Expose defaultConfig for tests</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-a90414833508a6d5f76b245c65f2a2ff067ada5e1c5c09b1b53598a4881e2676">+1/-0</a> </td> </tr> <tr> <td><strong>OpenTelemetry.vue</strong><dd><code>Expose ingestionURL in setup</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-45be3e74a543860331e1cbb11c299a81d5f2e49030bcc3eab03dd6db09f93c5b">+1/-0</a> </td> </tr> <tr> <td><strong>Index.vue</strong><dd><code>Expose ingestRoutes for tests</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-a8ce6281b41747a4c58b111d6c31a57f8597b2c33f79d9b236af548d5683b200">+1/-0</a> </td> </tr> <tr> <td><strong>PipelineFlow.vue</strong><dd><code>Expose store and setViewport</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-9c7475a54f0c895dd49eb0c5b53fe0a76ceff0520f667a9cb065b364557ced50">+2/-0</a> </td> </tr> <tr> <td><strong>MessageQueues.vue</strong><dd><code>Expose messageQueueTabs</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-ab520bb9b203fc532d2544ba60b140600cbc0efb9773e000c1867076275780bc">+1/-0</a> </td> </tr> <tr> <td><strong>Database.vue</strong><dd><code>Expose databaseTabs</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-9f043be1b81e96e163d333d8fac934fbd8cf9009076eeaaf2bd8ee360a3e913c">+1/-0</a> </td> </tr> <tr> <td><strong>Languages.vue</strong><dd><code>Expose languagesTabs</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-5ac446e8fed967883b402dfe4ff686717138a76f0333c2416a6b6f955a0086fc">+1/-0</a> </td> </tr> <tr> <td><strong>Networking.vue</strong><dd><code>Expose networkingTabs</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-ca61b8331afde2b46c0a193e0cc31e2b6b8a915aad1841fbbda229450af02726">+1/-0</a> </td> </tr> <tr> <td><strong>Recommended.vue</strong><dd><code>Expose recommendedTabs</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-d52f7f52bf8f6d3d639e5d0a550bed82223cd4fbd3eee3c257b7f80e0b8ee6d2">+1/-0</a> </td> </tr> <tr> <td><strong>SearchBar.spec.ts</strong><dd><code>Rewrite and expand SearchBar unit tests</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-63ac75d3fe278dad233e7dd7c51b3b33076d54a776b89ae05190d8522130c78b">+1058/-1118</a></td> </tr> <tr> <td><strong>GCPConfig.spec.ts</strong><dd><code>Add unit tests for GCP config logic</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-76e896e96fdae254b7b569e0d3afdea55b05c7777d6eda2da0374fe782d74457">+533/-0</a> </td> </tr> </table></details></td></tr><tr><td><strong>Enhancement</strong></td><td><details><summary>1 files</summary><table> <tr> <td><strong>usePromqlSuggestions.ts</strong><dd><code>Export additional suggestion helpers/state</code> </dd></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-250bf4b2d8cb3845005f72188d73ab954359f841e15c4f217708beac1493e83a">+4/-0</a> </td> </tr> </table></details></td></tr><tr><td><strong>Additional files</strong></td><td><details><summary>101 files</summary><table> <tr> <td><strong>App.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-e5d10660c09127e3b4234cd8fe18303e53db38e43a1c5a6edb13032afbebe28f">+291/-0</a> </td> </tr> <tr> <td><strong>AutoRefreshInterval.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-4fae96431d981a4338e96dd393820e3497ed56382adc77fab6024f6efd15bd4c">+320/-0</a> </td> </tr> <tr> <td><strong>ConfirmDialog.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-16ffba01e15b66513827b99a68c002b567e65bd1124f9bcf7c4db8db5795df8a">+61/-0</a> </td> </tr> <tr> <td><strong>CopyContent.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-a09160ad7355806c5f4f5b0194a6026ed7c24a77f3de0bce58ffa67c4e97de4d">+348/-0</a> </td> </tr> <tr> <td><strong>CustomDateTimePicker.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-f3c4dc21e87d485ae2d167b1f4e993ffc00b941b207a664ea504468842f4d428">+338/-0</a> </td> </tr> <tr> <td><strong>DateTime.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-ee6ae1a77af32afb0b0410cbe812d546c8639815748908e716d48a189695d8ec">+543/-0</a> </td> </tr> <tr> <td><strong>MenuLink.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-bd04ff500fc31583a430993830eed36cdf6254c2ce1a52b8a58a07b89bb9f825">+56/-4</a> </td> </tr> <tr> <td><strong>PendingSubscriptionWarning.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-a38d050077b70a4e16ed3fa89df6978e0d15284b824fc1840ed3d0f10403f9f8">+301/-0</a> </td> </tr> <tr> <td><strong>ResumePipelineDialog.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-ca982d78b8c120585dcf75837fbc09426c3fa2dd7e0f3a8d6cdbf9954aee6027">+136/-0</a> </td> </tr> <tr> <td><strong>RouteTabs.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-f4940a707bb9a1790b34d87c2588bb957876214edbfaf0072b2519afe230d077">+400/-0</a> </td> </tr> <tr> <td><strong>SanitizedHtmlRenderer.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-b45de775a1fc42af052b7af7b5c0b40512fab530db228a548e5bbe0510e774de">+350/-0</a> </td> </tr> <tr> <td><strong>FileItem.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-189b4998b9446d2b44aa820117eb54f555e15fb5d12dbd5bf61b4722fbc85b4e">+395/-0</a> </td> </tr> <tr> <td><strong>ScriptEditor.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-7989b3c2125f44e258f2e1e12dbb6e0608c2cfd6165619815501c8a4548b641c">+408/-0</a> </td> </tr> <tr> <td><strong>ScriptToolbar.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-5057edcc2e7f7f2bd115d1ad3b00bb668607662edee60131ba04fd078e41eaef">+412/-0</a> </td> </tr> <tr> <td><strong>AddAlert.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-84362398fea8abd9acf30f4f40ba8d4cf27348677454017bd4e6f568d5176ac6">+5/-3</a> </td> </tr> <tr> <td><strong>AlertsDestinationList.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-796a77635e67bca70cc19a671e1862438f78a9391ede0e936763e2204bd7a876">+709/-0</a> </td> </tr> <tr> <td><strong>FilterCondition.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-d09ca687da324598f7c1f17610406dda5c47faba21b1eba5dd606ce8f5a2671e">+463/-0</a> </td> </tr> <tr> <td><strong>FilterGroup.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-1628547d4b6650b1e87817989b84ffb25895c64ad789457b094860fcd7f13447">+1405/-0</a></td> </tr> <tr> <td><strong>ImportAlert.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-553f61b4cb949550d09d7016031a29361e4aaa22ad86f20781787bc4ccf43272">+951/-0</a> </td> </tr> <tr> <td><strong>ImportDestination.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-cf334a840c66788867f54f726f5d9431f8e1197637c641469a34e63facfcb180">+815/-0</a> </td> </tr> <tr> <td><strong>ImportTemplate.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-1a14d1b5cdc535c0fd982bcb6c02af07b647d5013922084df5d208c673eefaff">+875/-0</a> </td> </tr> <tr> <td><strong>PipelinesDestinationList.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-f749b2cdb5476b289a38418201bf27c69a7e9ab01237f6ffefc7b23392c3ff71">+529/-0</a> </td> </tr> <tr> <td><strong>RealTimeAlert.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-3b33541be3d07c04f1afd3b0a716e683b804b4f8adcba09b4fc5f3ddd0c14ef6">+693/-0</a> </td> </tr> <tr> <td><strong>ScheduledAlert.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-c85c209fe2d6eb3e8a223ddc1124e713f21ce3bbddf657be931cf8726f2e2934">+1197/-0</a></td> </tr> <tr> <td><strong>VariablesInput.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-1c6c211f8e8e49e12619c73ac450cfdc6f92f5ffc533bf09716477fa37154786">+353/-0</a> </td> </tr> <tr> <td><strong>AddCipherKey.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-1ae71f00dfb6f9424d2443856ca3a419aaf2ee0c08900f7ef2ca44e41c1982e9">+507/-467</a></td> </tr> <tr> <td><strong>AppDialog.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-28cde24b3e035186bbdf389f3c7560ba087588fd52d377c5615d50a6b5ad3dc7">+443/-0</a> </td> </tr> <tr> <td><strong>AppTabs.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-1a762da82b05a89aaea5cfac75315972be2fcc622d8dcabd9bb6e10a091a2e9d">+132/-0</a> </td> </tr> <tr> <td><strong>JsonEditor.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-be62ee12fe0b191ed850f0d8c6be49abc52596a06bfd10ac037ecc8f758d2660">+107/-0</a> </td> </tr> <tr> <td><strong>LoadingProgress.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-6096c465ac03fdbe599251405ff150d38ffc2f42be501d93723a6cc9f8eeae52">+153/-0</a> </td> </tr> <tr> <td><strong>RelativeTime.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-1ab920651a73975c32a1e00c0c6c0596866bf65b6aeec005e0d17f5084fddfef">+75/-0</a> </td> </tr> <tr> <td><strong>AddFolder.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-c47fb42fd03cf2b19f7c1da98ec484699730d00d2a5ae348002df727c6f009b4">+545/-0</a> </td> </tr> <tr> <td><strong>FieldList.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-b32e6b73a1268169f32fcd0a092350e543c3d4ffb00eef685aed4ba8c36ac6a1">+907/-0</a> </td> </tr> <tr> <td><strong>MoveAcrossFolders.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-4bce3286733956ade6e6f93cc65f471314a07e610b7e3f57a95050f683fc688a">+1385/-0</a></td> </tr> <tr> <td><strong>AddFunction.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-5bf8cf7b136d01ade73a969358f28642eca484ee1f93008f2787405bc928c0df">+883/-0</a> </td> </tr> <tr> <td><strong>EnrichmentSchema.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-020714ac53ba9e0397b5f0d7fa40bbb54638a30858d2e85693e117e3616c03d1">+394/-0</a> </td> </tr> <tr> <td><strong>FullViewContainer.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-498a7631461da0b1acbb272f4e1be20f999a28cdbf66f3e2f86b2f59b82841fd">+503/-0</a> </td> </tr> <tr> <td><strong>FunctionList.spec.js</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-555eb5d72b94d73c66cc303b1e3cece61564b622f7b1010219a23761c21f4c55">+0/-618</a> </td> </tr> <tr> <td><strong>TestFunction.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-c1b26d908f381d548650300e436d7b2e22410ef4e3d6508287c951add6633f3c">+598/-0</a> </td> </tr> <tr> <td><strong>ServiceAccountsList.spec.js</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-7b77b3425b30af8671b95b2c74702c89cf374669c2dc67a0b49ec182d30bedcd">+415/-99</a></td> </tr> <tr> <td><strong>AscSort.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-afc2d5fea4960d77d9f0487a89139f5409c9f55e34c3a58aedc8664cb9465c36">+200/-0</a> </td> </tr> <tr> <td><strong>DescSort.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-f6c074687e3f02ec34f0c398f64a100f5511baf1789e5dd280d48f999dfd8505">+231/-0</a> </td> </tr> <tr> <td><strong>FunctionIcon.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-5ce858f61f52bf2fdad1dc34d3ecdd852f38c66e329b6f71a4eb25f745530ada">+313/-0</a> </td> </tr> <tr> <td><strong>PipelineIcon.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-28fb2dcadc48a4bf7407fe99d2dddcd4993b430fe8398db23c786abd9cdad427">+340/-0</a> </td> </tr> <tr> <td><strong>Custom.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-75fb68bb0e3ab0416c7a6840bd615a0432026c0675b7b8db80cedd8a29f07d0f">+941/-0</a> </td> </tr> <tr> <td><strong>Database.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-890a9b5f5bde73f36522a300d5ada6f14fae2a94bdb3f061ac3e7d1d0cb9cd8e">+775/-0</a> </td> </tr> <tr> <td><strong>DevOps.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-8dbbccb5f29f0766ead95f3aea538f5f5b85ec3b2ff8fbedbaff50f0c5771ab4">+331/-0</a> </td> </tr> <tr> <td><strong>Languages.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-34642bc2e6238f98a78fe2185eadd4995749ae336204bfb6095620369268e7d1">+753/-0</a> </td> </tr> <tr> <td><strong>MessageQueues.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-eee646fcdd254e0be152dfb3f2c6749b1710b6ec6be272b8c5f865b83d2853df">+526/-0</a> </td> </tr> <tr> <td><strong>Networking.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-aff8de29d05af2b04cc0b83ab292896c79a6d68cfb3649c10ec517679b73e97e">+659/-0</a> </td> </tr> <tr> <td><strong>Others.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-56f4544b83413f5b8d87c5fec280204b75388a0686c388445b3eceaef523f10e">+493/-0</a> </td> </tr> <tr> <td><strong>Recommended.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-86de7fab5e678188cf1b96d463809fa645abd8d1a19d86cd3f2214b12fac3c43">+557/-0</a> </td> </tr> <tr> <td><strong>Security.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-952301dec9efb69bbdc3b82753e8a7c86d64a67e3cd544fcc50f118fcd1d017e">+623/-0</a> </td> </tr> <tr> <td><strong>Server.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-80a46b98c8aef2059b9d25de464c3450aa3310c02d1a4bbfcd32a706b5d0334c">+667/-0</a> </td> </tr> <tr> <td><strong>Databricks.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-0cc6f4230b08c6d1f888bae4c5d9f11169714506be5f3be77b371ced9d084936">+350/-0</a> </td> </tr> <tr> <td><strong>Postgres.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-046ae7ca570ff9960c83ec5fca8a95110a5158ceafda48549bdf47ccc5c71b71">+498/-0</a> </td> </tr> <tr> <td><strong>SqlServer.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-33abd49e96a5a6ecb0e07f76f3b55cb53a12674ddd450890ec185eb85e33fae3">+313/-0</a> </td> </tr> <tr> <td><strong>Curl.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-755d02153c11d74b259e12605ae3ad203b01507c4f778347616ed4c1ba542024">+374/-24</a></td> </tr> <tr> <td><strong>FileBeat.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-d4f433b57979c49407559afd1b9a35131cf823a29596882f46aca6aa8789a777">+389/-0</a> </td> </tr> <tr> <td><strong>FluentBit.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-9bb84df5402b65026cdf6fe4ead0937f825f129538f4e7e6291492a9b9ade289">+362/-27</a></td> </tr> <tr> <td><strong>Fluentd.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-b0d737e6ac8536493791c38acde3b0b339bae519b8ce58fb780f794bc31f62d1">+382/-23</a></td> </tr> <tr> <td><strong>LogstashDatasource.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-2cd019295a25886a037e6ede5cad795b52851a377f48beb46f3897bc6d64a20b">+522/-0</a> </td> </tr> <tr> <td><strong>SysLog.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-98526471b0f8a5a7547c205c9da6f8b4e62f20c6ee728b687225d4ee1c564758">+966/-0</a> </td> </tr> <tr> <td><strong>SyslogNg.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-c1afe13c4d7ccf6c9e360c4beff423e785f52c05b58340acf5d0e11fbc77bfc3">+787/-0</a> </td> </tr> <tr> <td><strong>Vector.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-35a48d805d8ded5b793d07c4dbb85cfafb759d073e597758cb999ed28eaf3f31">+571/-26</a></td> </tr> <tr> <td><strong>ingestionIndex.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-aa6c7d67f4885ef49f587f3dde7760ba3eabea6478e776aede5f86ab4ca76e75">+570/-0</a> </td> </tr> <tr> <td><strong>CloudWatchMetrics.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-d2e18e89f6400e04f77e4dff297030ffdf6306038d7cfe08315e0736cd0520f4">+615/-0</a> </td> </tr> <tr> <td><strong>PrometheusConfig.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-9026aa740243dc87d7be703fad5ad83e8ebdbb907b20b0f75a653ea3514dd6b4">+416/-0</a> </td> </tr> <tr> <td><strong>TelegrafConfig.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-9de7588766a4cc480d9b053d4c6dd34bad93c4e85c6580c2d8f04073f8f0fa25">+350/-0</a> </td> </tr> <tr> <td><strong>AWSConfig.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-a40ad271f4e88e42c4e746b5ce54ef0dceca122bedf3f9fa1f0571765001c680">+500/-0</a> </td> </tr> <tr> <td><strong>FrontendRumConfig.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-28bda2968dbbe401bacf2ce4a95e566d4672d59dafdf309d9a66dd567734af9a">+945/-0</a> </td> </tr> <tr> <td><strong>OpenTelemetry.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-489085e78e204c6e2b6dfdf21f1e48fef86d4bc4dd6f36869f9a2164027b3b7b">+554/-0</a> </td> </tr> <tr> <td><strong>Login.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-746b43968d685362866c3f97bf2b5e0846bac7463fe1ecb080c1c7d962cb855b">+994/-0</a> </td> </tr> <tr> <td><strong>AssociatedRegexPatterns.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-4ca41bf14fd6a3c79a3877324a7c7520a25d1d33f97fe947b2f6dd4bbf6ca5b4">+1384/-0</a></td> </tr> <tr> <td><strong>Schema.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-27aac0c27d14c76ae7d02277822392d29777f07fb588bc4a19d93cc0379a25e6">+593/-677</a></td> </tr> <tr> <td><strong>StreamFieldInputs.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-a421936485eb26fe8b6c1a89cd0b40de202936fd57b49957e8ac1521a4641f57">+469/-0</a> </td> </tr> <tr> <td><strong>ExternalDestination.spec.js</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-716d02dd388d827ba64d21320834f07a281242627dbce78a9d29fa84e2727a42">+0/-584</a> </td> </tr> <tr> <td><strong>ExternalDestination.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-a404d8244c3beb0122fbd403d2b8b410a934aacd3e498c73499204db85bc790e">+1029/-0</a></td> </tr> <tr> <td><strong>Query.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-28606cc9e509c3f1c132551ed29c46ef168444b4425cf5e81e0eff65302a9d16">+950/-0</a> </td> </tr> <tr> <td><strong>Stream.spec.js</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-f0e36c3bdbe8da79becc97e236de086bec117c4272ef4a7691a3330835993e40">+232/-5</a> </td> </tr> <tr> <td><strong>PipelineView.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-f78a1273b1fb7f5696f364f509b6bd13a1536a160b4fd98260cc8e61750e96f9">+600/-0</a> </td> </tr> <tr> <td><strong>PipelinesList.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-afcaf75b1dd20ccf66bd61334ba262512135a3f85593310890a774421d50265e">+712/-0</a> </td> </tr> <tr> <td><strong>pipelineCommonValidation.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-820d4f4f076840724bd6f0e7b5a9da1cbacea4d074249f07c957120b6601ac38">+311/-0</a> </td> </tr> <tr> <td><strong>pipelineCommonValidation.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-b2c4c50027aace8991d17030333e880b7d4808ab04d96e9c372d82d424235ef5">+1/-1</a> </td> </tr> <tr> <td><strong>CreateReport.spec.js</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-8a0f39751d08a258c4997c5e68edaf167ea01477528beee2295dd9f992310cc6">+0/-1854</a></td> </tr> <tr> <td><strong>PerformanceOverview.vue</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-c37f87d6d7205b9688af8c24fa6d7847c77bf35c51d4d7d1e08e6f10f3af2942">[link]</a> </td> </tr> <tr> <td><strong>PerformanceSummary.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-a2a97a13f8d5caa69d38d883576678dacecd8728386886f76d105e376879d60e">+1582/-0</a></td> </tr> <tr> <td><strong>ImportRegexPattern.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-1111ec8ccc0c9b62d4791101f69855ac22baa856dedd54827970f993147c3aed">+811/-0</a> </td> </tr> <tr> <td><strong>RegexPatternList.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-df942239cac609f116dcb4aa61405a60fc718219c77af46258c34e8e86e44080">+1005/-0</a></td> </tr> <tr> <td><strong>settingsIndex.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-fc96fd3ae93a42ba09577ee2c27416e9e729f2729146f88e146e4a9473626da2">+774/-0</a> </td> </tr> <tr> <td><strong>FilterCreatorPopup.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-4167cd3f9eec0c9df78517b7514c39dcc2c0234810010d93e311879971bd552e">+439/-0</a> </td> </tr> <tr> <td><strong>NoData.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-e7f5be4faf7164f86bdfea69049db3aae0509a8d33b037bfcf799347b3a0ab0d">+335/-0</a> </td> </tr> <tr> <td><strong>NoOrganizationSelected.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-1338e495c82b9d07995c13a6b245c919588012974c0f08096c7b93b5e143606c">+88/-0</a> </td> </tr> <tr> <td><strong>Pagination.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-8846923daf3fe7a897ab5956098564aeb6d1748db90f637fc39f4ac8a30e1234">+110/-0</a> </td> </tr> <tr> <td><strong>AddUpdateTicket.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-8f7eb6b61a8dfdab68d5e2f73e1d2bc9580e03290d287bcfb35802331165d118">+531/-0</a> </td> </tr> <tr> <td><strong>usePermissions.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-83e050b2b1753f98e357db0e2f8a6a353b24857640c3a522a73d0d2609a0bced">+513/-0</a> </td> </tr> <tr> <td><strong>useActions.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-1bd297e5011b31dca1cb4edb6ff63a705e582dfe392e34b2e781c8051be5ee5e">+158/-0</a> </td> </tr> <tr> <td><strong>useIngestion.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-495d1e7e830eecd3e430e987a7056298d67df84282b31869bb27973aec8e4f06">+606/-0</a> </td> </tr> <tr> <td><strong>useIsMetaOrg.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-635f3965352f56c275b1309753a9f1421ffb0e8bd985b1286a012217df33eab5">+123/-0</a> </td> </tr> <tr> <td><strong>useLogs.spec.ts</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-1e4dd9056495ae6a0c1cf2b8c9e803d7372c2c1426918d848bb903b424103875">+2/-2</a> </td> </tr> <tr> <td><strong>Additional files not shown</strong></td> <td><a href="https://github.com/openobserve/openobserve/pull/8121/files#diff-2f328e4cd8dbe3ad193e49d92bcf045f47a6b72b1e9487d366f6b8288589b4ca"></a></td> </tr> </table></details></td></tr></tr></tbody></table> </details> ___
320 lines
11 KiB
TypeScript
320 lines
11 KiB
TypeScript
import { mount } from "@vue/test-utils";
|
|
import { describe, expect, it, beforeEach, afterEach, vi } from "vitest";
|
|
import { installQuasar } from "@/test/unit/helpers/install-quasar-plugin";
|
|
import AutoRefreshInterval from "@/components/AutoRefreshInterval.vue";
|
|
import i18n from "@/locales";
|
|
import { createRouter, createWebHistory } from "vue-router";
|
|
|
|
installQuasar();
|
|
|
|
vi.mock("@/utils/date", () => ({
|
|
generateDurationLabel: vi.fn((value) => `${value} seconds`)
|
|
}));
|
|
|
|
const mockRouter = createRouter({
|
|
history: createWebHistory(),
|
|
routes: [
|
|
{ path: "/", component: { template: "<div>Home</div>" } }
|
|
]
|
|
});
|
|
|
|
describe("AutoRefreshInterval", () => {
|
|
let wrapper: any = null;
|
|
|
|
beforeEach(() => {
|
|
vi.useFakeTimers();
|
|
});
|
|
|
|
afterEach(() => {
|
|
if (wrapper) {
|
|
wrapper.unmount();
|
|
}
|
|
vi.useRealTimers();
|
|
});
|
|
|
|
const createWrapper = (props = {}) => {
|
|
return mount(AutoRefreshInterval, {
|
|
props: {
|
|
modelValue: 0,
|
|
trigger: false,
|
|
...props
|
|
},
|
|
global: {
|
|
plugins: [i18n, mockRouter],
|
|
stubs: {
|
|
'q-btn-dropdown': {
|
|
template: '<div class="q-btn-dropdown"><slot /><slot name="label" /></div>'
|
|
},
|
|
'q-icon': {
|
|
template: '<div class="q-icon"></div>'
|
|
},
|
|
'q-btn': {
|
|
template: '<button @click="$emit(\'click\')" :disabled="disable"><slot /></button>',
|
|
props: ['disable', 'disabled']
|
|
},
|
|
'q-separator': {
|
|
template: '<div class="q-separator"></div>'
|
|
},
|
|
'q-tooltip': {
|
|
template: '<div class="q-tooltip"><slot /></div>'
|
|
}
|
|
}
|
|
},
|
|
});
|
|
};
|
|
|
|
it("should mount AutoRefreshInterval component", () => {
|
|
wrapper = createWrapper();
|
|
expect(wrapper).toBeTruthy();
|
|
});
|
|
|
|
it("should have correct component name", () => {
|
|
wrapper = createWrapper();
|
|
expect(wrapper.vm.$options.name).toBe("AutoRefreshInterval");
|
|
});
|
|
|
|
it("should have correct props", () => {
|
|
wrapper = createWrapper({ modelValue: 5, trigger: true });
|
|
expect(wrapper.props('modelValue')).toBe(5);
|
|
expect(wrapper.props('trigger')).toBe(true);
|
|
});
|
|
|
|
it("should render without errors", () => {
|
|
wrapper = createWrapper();
|
|
expect(wrapper.exists()).toBe(true);
|
|
});
|
|
|
|
it("should expose necessary properties from setup", () => {
|
|
wrapper = createWrapper();
|
|
expect(typeof wrapper.vm.t).toBe("function");
|
|
expect(wrapper.vm.router).toBeDefined();
|
|
expect(wrapper.vm.btnRefreshInterval).toBeDefined();
|
|
expect(wrapper.vm.selectedLabel).toBeDefined();
|
|
expect(wrapper.vm.refreshTimes).toBeDefined();
|
|
expect(typeof wrapper.vm.onItemClick).toBe("function");
|
|
expect(wrapper.vm.minRangeRestrictionMessageVal).toBeDefined();
|
|
});
|
|
|
|
describe("Function Coverage Tests", () => {
|
|
it("should trigger timer management through prop changes", async () => {
|
|
const mockSetInterval = vi.fn().mockReturnValue(123);
|
|
const mockClearInterval = vi.fn();
|
|
|
|
vi.stubGlobal('setInterval', mockSetInterval);
|
|
vi.stubGlobal('clearInterval', mockClearInterval);
|
|
|
|
wrapper = createWrapper({
|
|
modelValue: 0,
|
|
trigger: true
|
|
});
|
|
|
|
// Change to a non-zero value to trigger timer setup
|
|
await wrapper.setProps({ modelValue: 60 });
|
|
|
|
expect(mockSetInterval).toHaveBeenCalledWith(expect.any(Function), 60000);
|
|
|
|
vi.unstubAllGlobals();
|
|
});
|
|
|
|
it("should handle disabled values through button clicks", async () => {
|
|
wrapper = createWrapper({
|
|
modelValue: 0,
|
|
minRefreshInterval: 30
|
|
});
|
|
|
|
// Find a button for a value less than minRefreshInterval
|
|
const fiveSecButton = wrapper.find('[data-test="logs-search-bar-refresh-time-5"]');
|
|
await fiveSecButton.trigger('click');
|
|
|
|
// Should not change to disabled value, stays at 0 or goes to 0
|
|
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
|
});
|
|
|
|
it("should handle valid values through button clicks", async () => {
|
|
wrapper = createWrapper({
|
|
modelValue: 0,
|
|
minRefreshInterval: 10
|
|
});
|
|
|
|
// Find a button for a value greater than minRefreshInterval
|
|
const oneMinButton = wrapper.find('[data-test="logs-search-bar-refresh-time-60"]');
|
|
await oneMinButton.trigger('click');
|
|
|
|
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
|
const emittedValues = wrapper.emitted('update:modelValue') as any[][];
|
|
expect(emittedValues[emittedValues.length - 1][0]).toBe(60);
|
|
});
|
|
|
|
it("should test onItemClick through component interaction", async () => {
|
|
wrapper = createWrapper({ modelValue: 0 });
|
|
|
|
// Click on a specific refresh time button
|
|
const fiveMinButton = wrapper.find('[data-test="logs-search-bar-refresh-time-300"]');
|
|
await fiveMinButton.trigger('click');
|
|
|
|
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
|
const emittedValues = wrapper.emitted('update:modelValue') as any[][];
|
|
expect(emittedValues[emittedValues.length - 1][0]).toBe(300);
|
|
});
|
|
|
|
it("should emit trigger event from interval", async () => {
|
|
let intervalCallback: Function;
|
|
const mockSetInterval = vi.fn().mockImplementation((callback) => {
|
|
intervalCallback = callback;
|
|
return 789;
|
|
});
|
|
|
|
vi.stubGlobal('setInterval', mockSetInterval);
|
|
|
|
wrapper = createWrapper({
|
|
modelValue: 5,
|
|
trigger: true
|
|
});
|
|
|
|
// Wait for component to set up interval
|
|
await wrapper.vm.$nextTick();
|
|
|
|
// Execute the interval callback if it was set
|
|
if (intervalCallback!) {
|
|
intervalCallback();
|
|
expect(wrapper.emitted('trigger')).toBeTruthy();
|
|
}
|
|
|
|
vi.unstubAllGlobals();
|
|
});
|
|
|
|
it("should update disabled flags when minRefreshInterval changes", async () => {
|
|
wrapper = createWrapper({
|
|
modelValue: 0,
|
|
minRefreshInterval: 10
|
|
});
|
|
|
|
// Initially, 60s item should not be disabled
|
|
let oneMinItem = wrapper.vm.refreshTimes.flat().find((item: any) => item.value === 60);
|
|
expect(oneMinItem.disabled).toBe(false);
|
|
|
|
// Change the minRefreshInterval prop
|
|
await wrapper.setProps({ minRefreshInterval: 70 });
|
|
|
|
// Now the 1 min item should be disabled
|
|
oneMinItem = wrapper.vm.refreshTimes.flat().find((item: any) => item.value === 60);
|
|
expect(oneMinItem.disabled).toBe(true);
|
|
|
|
// Check restriction message
|
|
expect(wrapper.vm.minRangeRestrictionMessageVal).toContain("70 seconds");
|
|
});
|
|
|
|
it("should handle timer reset when value becomes 0", async () => {
|
|
const mockSetInterval = vi.fn().mockReturnValue(999);
|
|
const mockClearInterval = vi.fn();
|
|
|
|
vi.stubGlobal('setInterval', mockSetInterval);
|
|
vi.stubGlobal('clearInterval', mockClearInterval);
|
|
|
|
wrapper = createWrapper({
|
|
modelValue: 60,
|
|
trigger: true
|
|
});
|
|
|
|
// Change to 0 to stop timer
|
|
await wrapper.setProps({ modelValue: 0 });
|
|
|
|
expect(mockClearInterval).toHaveBeenCalled();
|
|
|
|
vi.unstubAllGlobals();
|
|
});
|
|
|
|
it("should test component reactivity and watch behavior", async () => {
|
|
wrapper = createWrapper({
|
|
modelValue: 0,
|
|
trigger: true
|
|
});
|
|
|
|
// Component should be reactive to prop changes
|
|
expect(wrapper.vm).toBeTruthy();
|
|
|
|
// Change modelValue to test reactivity
|
|
await wrapper.setProps({ modelValue: 60 });
|
|
await wrapper.vm.$nextTick();
|
|
|
|
// Component should still be working
|
|
expect(wrapper.exists()).toBe(true);
|
|
expect(wrapper.vm.selectedLabel).toBe("1 min");
|
|
});
|
|
|
|
it("should test disabled state through component data", () => {
|
|
wrapper = createWrapper({
|
|
modelValue: 0,
|
|
minRefreshInterval: 30
|
|
});
|
|
|
|
// Items with values less than 30 should be disabled
|
|
const fiveSecItem = wrapper.vm.refreshTimes.flat().find((item: any) => item.value === 5);
|
|
const tenSecItem = wrapper.vm.refreshTimes.flat().find((item: any) => item.value === 10);
|
|
const fifteenSecItem = wrapper.vm.refreshTimes.flat().find((item: any) => item.value === 15);
|
|
const oneMinItem = wrapper.vm.refreshTimes.flat().find((item: any) => item.value === 60);
|
|
|
|
expect(fiveSecItem.disabled).toBe(true);
|
|
expect(tenSecItem.disabled).toBe(true);
|
|
expect(fifteenSecItem.disabled).toBe(true);
|
|
expect(oneMinItem.disabled).toBe(false);
|
|
});
|
|
|
|
it("should test disabled flags update on mount", async () => {
|
|
wrapper = createWrapper({
|
|
modelValue: 0,
|
|
minRefreshInterval: 25
|
|
});
|
|
|
|
// Component should be mounted and flags should be updated
|
|
const fifteenSecItem = wrapper.vm.refreshTimes.flat().find((item: any) => item.value === 15);
|
|
const oneMinItem = wrapper.vm.refreshTimes.flat().find((item: any) => item.value === 60);
|
|
|
|
expect(fifteenSecItem.disabled).toBe(true);
|
|
expect(oneMinItem.disabled).toBe(false);
|
|
});
|
|
|
|
it("should generate correct selectedLabel for predefined values", () => {
|
|
wrapper = createWrapper({ modelValue: 60 });
|
|
expect(wrapper.vm.selectedLabel).toBe("1 min");
|
|
|
|
wrapper = createWrapper({ modelValue: 300 });
|
|
expect(wrapper.vm.selectedLabel).toBe("5 min");
|
|
|
|
wrapper = createWrapper({ modelValue: 0 });
|
|
// For value 0, it should show the generated duration label since it's not in refreshTimes
|
|
expect(wrapper.vm.selectedLabel).toBe("0 seconds");
|
|
});
|
|
|
|
it("should generate correct selectedLabel for custom values", async () => {
|
|
wrapper = createWrapper({ modelValue: 45 });
|
|
|
|
// For custom values not in predefined options, should use generateDurationLabel
|
|
expect(wrapper.vm.selectedLabel).toBe("45 seconds");
|
|
});
|
|
|
|
it("should handle off button click", async () => {
|
|
wrapper = createWrapper({ modelValue: 60 });
|
|
|
|
const offButton = wrapper.find('[data-test="logs-search-off-refresh-interval"]');
|
|
await offButton.trigger('click');
|
|
|
|
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
|
const emittedValues = wrapper.emitted('update:modelValue') as any[][];
|
|
expect(emittedValues[emittedValues.length - 1][0]).toBe(0);
|
|
});
|
|
|
|
it("should show tooltip for disabled buttons", () => {
|
|
wrapper = createWrapper({
|
|
modelValue: 0,
|
|
minRefreshInterval: 30,
|
|
minRangeRestrictionMessage: "Custom restriction message"
|
|
});
|
|
|
|
// Check that disabled items exist and restriction message is set
|
|
const disabledItems = wrapper.vm.refreshTimes.flat().filter((item: any) => item.disabled);
|
|
expect(disabledItems.length).toBeGreaterThan(0);
|
|
expect(wrapper.vm.minRangeRestrictionMessageVal).toBeDefined();
|
|
});
|
|
});
|
|
}); |