Files
openobserve/web
ktx-vaidehi d44db085fb fix: dashboard unit tests (#8239)
### **PR Type**
Tests, Enhancement


___

### **Description**
- Add comprehensive unit tests for data loaders

- Add WebSocket/streaming values tests

- Add annotations data workflow tests

- Improve loader mocks and error handling


___

### Diagram Walkthrough


```mermaid
flowchart LR
  specs["Add dashboard composables specs"] -- "usePanelDataLoader" --> panelLoader["Panel data loading tests"]
  specs -- "useValuesWebSocket" --> valuesWS["Field values WS/stream tests"]
  specs -- "useAnnotationsData" --> annotations["Annotations data workflow tests"]
```



<details> <summary><h3> File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>

<summary><strong>usePanelDataLoader.spec.ts</strong><dd><code>Comprehensive
tests for panel data loader</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>

web/src/composables/dashboard/usePanelDataLoader.spec.ts

<ul><li>Add extensive tests for loadData flow<br> <li> Mock services,
WS, streaming, cache, annotations<br> <li> Cover variables, partitions,
PromQL, histograms<br> <li> Validate error, abort, and cache
behaviors</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8239/files#diff-f8306bde2ca2b3902674ef12091f2867c7e8b13d4d59d39d4d4152704326c09a">+2666/-0</a></td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>useValuesWebSocket.spec.ts</strong><dd><code>Tests for
values WebSocket and fetching paths</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

web/src/composables/dashboard/useValuesWebSocket.spec.ts

<ul><li>Test trace ID management and handlers<br> <li> Verify
WS/stream/REST field values paths<br> <li> Validate response merging and
meta updates<br> <li> Cover error and edge-case handling</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8239/files#diff-9c2dfef7fc575383b8084ce0d4a81a8cdf3db555182dd175adc4f2292a6e9771">+719/-0</a>&nbsp;
</td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>useAnnotationsData.spec.ts</strong><dd><code>Unit tests
for annotations data composable</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

web/src/composables/dashboard/useAnnotationsData.spec.ts

<ul><li>Test add/edit annotation UI state flows<br> <li> Verify
notifications and watchers<br> <li> Test dashboard panel extraction
logic<br> <li> Handle error and edge scenarios</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8239/files#diff-e37e9b0c45ffb85d81b95d7aa109858be3a825e70d25fd2e1876bcf89693a191">+582/-0</a>&nbsp;
</td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>usePanelCache.spec.ts</strong><dd><code>Tests for panel
cache behavior</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

web/src/composables/dashboard/usePanelCache.spec.ts

<ul><li>Add unit tests for panel cache composable<br> <li> Validate
get/save interactions and edge cases</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8239/files#diff-e6aaaf3ac620a36599bb16bc25a0368299a05f9514788366bb98e34f27a9d9d1">+524/-0</a>&nbsp;
</td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>useCancelQuery.spec.ts</strong><dd><code>Tests for
cancel query composable</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

web/src/composables/dashboard/useCancelQuery.spec.ts

<ul><li>Add tests for canceling running queries<br> <li> Cover WS and
streaming cancellation paths</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8239/files#diff-b32a712642618ba717898c9722d44f0bc76a439fe03948e5d3123bcc783c1908">+542/-0</a>&nbsp;
</td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>useAnnotations.spec.ts</strong><dd><code>Tests for
annotations composable</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

web/src/composables/dashboard/useAnnotations.spec.ts

<ul><li>Add tests for annotations fetching logic<br> <li> Cover success
and error flows</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8239/files#diff-9e2e3a05f1f983e70a15029a64d007d4fc69f6bbc623cf6c03a8bac53e0b3cd3">+310/-0</a>&nbsp;
</td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___
2025-09-03 12:08:35 +05:30
..
2023-02-02 09:03:11 +05:30
2025-09-03 12:08:35 +05:30
2023-08-06 01:29:13 +08:00
2023-02-02 09:03:11 +05:30
2023-02-02 09:03:11 +05:30
2023-02-02 09:03:11 +05:30
2025-08-11 17:06:35 -07:00
2024-04-03 12:49:25 +05:30
2023-02-02 09:03:11 +05:30

web

This template should help get you started developing with Vue 3 in Vite.

VSCode + Volar (and disable Vetur) + TypeScript Vue Plugin (Volar).

Type Support for .vue Imports in TS

TypeScript cannot handle type information for .vue imports by default, so we replace the tsc CLI with vue-tsc for type checking. In editors, we need TypeScript Vue Plugin (Volar) to make the TypeScript language service aware of .vue types.

If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a Take Over Mode that is more performant. You can enable it by the following steps:

  1. Disable the built-in TypeScript Extension
    1. Run Extensions: Show Built-in Extensions from VSCode's command palette
    2. Find TypeScript and JavaScript Language Features, right click and select Disable (Workspace)
  2. Reload the VSCode window by running Developer: Reload Window from the command palette.

Customize configuration

See Vite Configuration Reference.

Project Setup

npm install

Compile and Hot-Reload for Development

For stand-alone UI development environment, create .env file and which contains below environment variable

VITE_OPENOBSERVE_ENDPOINT=http://localhost:5080/
npm run dev

Type-Check, Compile and Minify for Production

npm run build

Run Unit Tests with Vitest

npm run test:unit

Run End-to-End Tests with Cypress

npm run test:e2e:dev

This runs the end-to-end tests against the Vite development server. It is much faster than the production build.

But it's still recommended to test the production build with test:e2e before deploying (e.g. in CI environments):

npm run build
npm run test:e2e

Lint with ESLint

npm run lint