Skip to content

Commit

Permalink
Display values for string fields in total (flat table) (#1763)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuzmadom authored Oct 31, 2024
1 parent 52191d2 commit 4f1cf32
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {BarTableCell, ServerField, TableCommonCell} from '../../../../../../../../../shared';
import {isDateField, isMarkupField} from '../../../../../../../../../shared';
import {isDateField, isMarkupField, isStringField} from '../../../../../../../../../shared';
import {TABLE_TOTALS_STYLES} from '../../../../../constants/misc';
import {
findIndexInOrder,
Expand Down Expand Up @@ -41,6 +41,8 @@ export const prepareFooterValue = (
} else if (isDateField({data_type: itemDataType})) {
const date = new Date(total);
value = getTimezoneOffsettedTime(date);
} else if (isStringField({data_type: itemDataType})) {
value = total;
}

if (columnIndex === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {expect} from '@playwright/test';

import datalensTest from '../../../../utils/playwright/globalTestDefinition';
import {openTestPage} from '../../../../utils';
import {WizardVisualizationId} from '../../../../../src/shared';
import {Operations, WizardVisualizationId} from '../../../../../src/shared';
import WizardPage from '../../../../page-objects/wizard/WizardPage';
import {PlaceholderName} from '../../../../page-objects/wizard/SectionVisualization';
import {ChartSettingsItems} from '../../../../page-objects/wizard/ChartSettings';
Expand Down Expand Up @@ -45,5 +45,42 @@ datalensTest.describe('Wizard', () => {
const noDataRow = chart.getByText('No data');
await expect(noDataRow).toBeVisible();
});

datalensTest('Totals for different field type', async ({page}) => {
const wizardPage = new WizardPage({page});
const table = wizardPage.chartkit.getTableLocator();
const tfoot = table.locator('tfoot');

await wizardPage.chartSettings.open();
await wizardPage.chartSettings.toggleSettingItem(ChartSettingsItems.Totals, 'on');
await wizardPage.chartSettings.apply();

await wizardPage.sectionVisualization.addFieldByClick(PlaceholderName.Filters, 'id');
await wizardPage.filterEditor.selectFilterOperation(Operations.LTE);
await wizardPage.filterEditor.setInputValue('5');
await wizardPage.filterEditor.apply();

await wizardPage.sectionVisualization.addFieldByClick(
PlaceholderName.FlatTableColumns,
'id',
);

// number column
await wizardPage.createNewFieldWithFormula('number_id', 'max([id])');
await wizardPage.sectionVisualization.addFieldByClick(
PlaceholderName.FlatTableColumns,
'number_id',
);

// string column
await wizardPage.createNewFieldWithFormula('str_id', '"str:" + str(max([id]))');
await wizardPage.sectionVisualization.addFieldByClick(
PlaceholderName.FlatTableColumns,
'str_id',
);

await expect(tfoot).toBeVisible();
await expect(tfoot.locator('td')).toHaveText(['Total', '5', 'str:5'], {timeout: 1000});
});
});
});

0 comments on commit 4f1cf32

Please sign in to comment.