Skip to content

Commit

Permalink
fix(ui): add total step rows does not require any aggregation TCTC-91…
Browse files Browse the repository at this point in the history
…99 (#2228)

* fix(ui): add total step rows does not require any aggregation

* style(ui): lint
  • Loading branch information
davinov authored Sep 6, 2024
1 parent acd9f7f commit e04e064
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
6 changes: 1 addition & 5 deletions ui/src/components/stepforms/AddTotalRowsStepForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,7 @@ export default class AddTotalRowsStepForm extends BaseStepForm<AddTotalRowsStep>
}
get aggregations() {
if (this.editedStep.aggregations.length) {
return this.editedStep.aggregations;
} else {
return [this.defaultAggregation];
}
return this.editedStep.aggregations;
}
set aggregations(newval) {
Expand Down
37 changes: 37 additions & 0 deletions ui/stories/AddTotalRowsStepForm.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { action } from '@storybook/addon-actions';
import type { Meta, StoryObj } from '@storybook/vue';
import { createPinia, PiniaVuePlugin } from 'pinia';
import Vue from 'vue';

import AddTotalRowsStepForm from '@/components/stepforms/AddTotalRowsStepForm.vue';
import { setupVQBStore } from '@/store';

export default {
component: AddTotalRowsStepForm,
} as Meta<AddTotalRowsStepForm>;

Vue.use(PiniaVuePlugin);

export const Empty: StoryObj<AddTotalRowsStepForm> = {
render: (args, { argTypes }) => ({
components: { AddTotalRowsStepForm },
props: Object.keys(argTypes),
template: '<AddTotalRowsStepForm v-bind="$props" @formSaved="onFormSaved" />',
methods: {
onFormSaved: action('formSaved'),
},
pinia: createPinia(),
created: function () {
setupVQBStore({
backendMessages: [],
dataset: {
headers: [
{ name: 'label', type: 'string' },
{ name: 'value', type: 'string' },
],
data: [],
},
});
},
}),
};
8 changes: 2 additions & 6 deletions ui/tests/unit/totals-step-form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ vi.mock('@/lib/helpers');
import AddTotalRowsStepForm from '@/components/stepforms/AddTotalRowsStepForm.vue';
import AutocompleteWidget from '@/components/stepforms/widgets/Autocomplete.vue';
import InputTextWidget from '@/components/stepforms/widgets/InputText.vue';
import MultiselectWidget from '@/components/stepforms/widgets/Multiselect.vue';
import { setAggregationsNewColumnsInStep } from '@/lib/helpers';

import { BasicStepFormTestRunner } from './utils';
Expand Down Expand Up @@ -101,12 +100,9 @@ describe('Add Total Rows Step Form', () => {
]);
});

it('should have expected default aggregation parameters', () => {
it('should have no default aggregation', () => {
const wrapper = runner.mount();
const autocompleteWrapper = wrapper.findAll(AutocompleteWidget);
const multiselectWrappers = wrapper.findAll(MultiselectWidget);
expect(autocompleteWrapper.at(1).props().value).toEqual('sum');
expect(multiselectWrappers.at(0).props().value).toEqual([]);
expect(wrapper.find('.widget-aggregation__container').exists()).toBe(false);
});
});

Expand Down

0 comments on commit e04e064

Please sign in to comment.