Skip to content

Commit 903bcf8

Browse files
Git add --update fix...
1 parent b70a37e commit 903bcf8

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<div
3+
v-if="visible"
4+
class="mb-4 p-3 bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded"
5+
>
6+
<div class="flex items-center mb-2">
7+
<i class="pi pi-exclamation-triangle text-orange-600 mr-2"></i>
8+
<strong class="text-orange-800 dark:text-orange-200 text-sm">Multiple Cell Methods Detected:</strong>
9+
</div>
10+
<p class="text-orange-700 dark:text-orange-300 text-sm">
11+
This dataset contains multiple variable cell methods. You will need to filter by
12+
<code class="px-1 py-0.5 bg-orange-100 dark:bg-orange-900 rounded text-xs font-mono">variable_cell_methods</code>
13+
to select the specific temporal aggregation you need before calling
14+
<code class="px-1 py-0.5 bg-orange-100 dark:bg-orange-900 rounded text-xs font-mono">to_dask()</code>.
15+
</p>
16+
</div>
17+
</template>
18+
19+
<script setup lang="ts">
20+
/**
21+
* Component props for MultipleCellMethodsWarning.
22+
*
23+
* Displays a warning message when a single dataset has multiple variable_cell_methods
24+
* options available, indicating the user should apply additional filtering before
25+
* converting to an xarray dataset.
26+
*/
27+
interface Props {
28+
/**
29+
* Whether to display the warning. Should be true when:
30+
* - The user has filtered down to a single dataset (to_dask mode)
31+
* - There are multiple options available for variable_cell_methods
32+
* - xarray mode is enabled
33+
*/
34+
visible: boolean;
35+
}
36+
37+
defineProps<Props>();
38+
</script>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { describe, it, expect } from 'vitest';
2+
import { mount } from '@vue/test-utils';
3+
import MultipleCellMethodsWarning from '../MultipleCellMethodsWarning.vue';
4+
5+
describe('MultipleCellMethodsWarning', () => {
6+
// Helper to create wrapper
7+
const createWrapper = (props: any) => {
8+
return mount(MultipleCellMethodsWarning, {
9+
props,
10+
});
11+
};
12+
13+
// Test that the component renders when visible is true
14+
it('renders warning when visible is true', () => {
15+
const wrapper = createWrapper({
16+
visible: true,
17+
});
18+
19+
expect(wrapper.html()).toBeTruthy();
20+
expect(wrapper.text()).toContain('Multiple Cell Methods Detected:');
21+
expect(wrapper.text()).toContain('variable_cell_methods');
22+
expect(wrapper.text()).toContain('to_dask()');
23+
});
24+
25+
// Test that the component does not render when visible is false
26+
it('does not render when visible is false', () => {
27+
const wrapper = createWrapper({
28+
visible: false,
29+
});
30+
31+
expect(wrapper.find('.bg-orange-50').exists()).toBe(false);
32+
});
33+
34+
// Test that warning icon is displayed
35+
it('displays warning icon', () => {
36+
const wrapper = createWrapper({
37+
visible: true,
38+
});
39+
40+
const icon = wrapper.find('.pi-exclamation-triangle');
41+
expect(icon.exists()).toBe(true);
42+
});
43+
44+
// Test that code elements are rendered for technical terms
45+
it('renders code elements for technical terms', () => {
46+
const wrapper = createWrapper({
47+
visible: true,
48+
});
49+
50+
const codeElements = wrapper.findAll('code');
51+
expect(codeElements.length).toBeGreaterThanOrEqual(2);
52+
expect(codeElements.some((el) => el.text().includes('variable_cell_methods'))).toBe(true);
53+
expect(codeElements.some((el) => el.text().includes('to_dask()'))).toBe(true);
54+
});
55+
56+
// Test that the component has proper styling classes
57+
it('has proper warning styling classes', () => {
58+
const wrapper = createWrapper({
59+
visible: true,
60+
});
61+
62+
const outerDiv = wrapper.find('div');
63+
expect(outerDiv.classes()).toContain('bg-orange-50');
64+
expect(outerDiv.classes()).toContain('border-orange-200');
65+
});
66+
});

0 commit comments

Comments
 (0)