diff --git a/src/server/modes/charts/plugins/datalens/preparers/backend-pivot-table/index.ts b/src/server/modes/charts/plugins/datalens/preparers/backend-pivot-table/index.ts index 4d1f38ad58..8905e90b04 100644 --- a/src/server/modes/charts/plugins/datalens/preparers/backend-pivot-table/index.ts +++ b/src/server/modes/charts/plugins/datalens/preparers/backend-pivot-table/index.ts @@ -178,7 +178,7 @@ const backendPivotTablePreparer = (args: PrepareFunctionArgs): BackendPivotTable const rowHeadersLength = rowHeaders.length; if (columns.length === 1 && columns[0].length === 0) { - const rowValues = tableRows.values; + const rowValues = tableRows?.values || []; const rowValuesLength = rowValues.length; lineHeaderLength = rowHeadersLength + rowValuesLength; } else { diff --git a/tests/opensource-suites/wizard/visualizations/pivot-table/pagination.test.ts b/tests/opensource-suites/wizard/visualizations/pivot-table/pagination.test.ts index e8ddee1b2d..7fbee73a02 100644 --- a/tests/opensource-suites/wizard/visualizations/pivot-table/pagination.test.ts +++ b/tests/opensource-suites/wizard/visualizations/pivot-table/pagination.test.ts @@ -1,11 +1,18 @@ +import type {Locator} from '@playwright/test'; import {expect} from '@playwright/test'; -import datalensTest from '../../../../utils/playwright/globalTestDefinition'; -import {openTestPage, slct} from '../../../../utils'; import {ChartKitTableQa, 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'; +import {PlaceholderName} from '../../../../page-objects/wizard/SectionVisualization'; +import WizardPage from '../../../../page-objects/wizard/WizardPage'; +import {openTestPage, slct} from '../../../../utils'; +import datalensTest from '../../../../utils/playwright/globalTestDefinition'; + +async function paginateTo(table: Locator, pageNumber: number) { + const paginatorInput = table.locator(slct(ChartKitTableQa.PaginatorPageInput)).locator('input'); + await paginatorInput.fill(String(pageNumber)); + await paginatorInput.press('Enter'); +} datalensTest.describe('Wizard', () => { datalensTest.describe('Pivot table', () => { @@ -13,10 +20,6 @@ datalensTest.describe('Wizard', () => { await openTestPage(page, config.wizard.urls.WizardBasicDataset); const wizardPage = new WizardPage({page}); - // Create measure field - const measureField = 'OrdersCount'; - await wizardPage.createNewFieldWithFormula(measureField, 'count([order_id])'); - await wizardPage.setVisualization(WizardVisualizationId.PivotTable); await wizardPage.chartSettings.open(); await wizardPage.chartSettings.toggleSettingItem(ChartSettingsItems.Pagination, 'on'); @@ -26,6 +29,10 @@ datalensTest.describe('Wizard', () => { datalensTest('Page number over limit', async ({page}) => { const wizardPage = new WizardPage({page}); + // Create measure field + const measureField = 'OrdersCount'; + await wizardPage.createNewFieldWithFormula(measureField, 'count([order_id])'); + await wizardPage.sectionVisualization.addFieldByClick(PlaceholderName.Rows, 'country'); await wizardPage.sectionVisualization.addFieldByClick(PlaceholderName.Rows, 'id'); await wizardPage.sectionVisualization.addFieldByClick( @@ -34,14 +41,28 @@ datalensTest.describe('Wizard', () => { ); const table = wizardPage.chartkit.getTableLocator(); - const paginatorInput = table - .locator(slct(ChartKitTableQa.PaginatorPageInput)) - .locator('input'); // Put a number that obviously exceeds the number of pages - await paginatorInput.fill('100'); - await paginatorInput.press('Enter'); + await paginateTo(table, 100); await expect(table.getByText('No data')).toBeVisible(); }); + + datalensTest( + 'Page number over limit (table without columns or measures, only rows)', + async ({page}) => { + const wizardPage = new WizardPage({page}); + + await wizardPage.sectionVisualization.addFieldByClick( + PlaceholderName.Rows, + 'country', + ); + + const table = wizardPage.chartkit.getTableLocator(); + // Put a number that obviously exceeds the number of pages + await paginateTo(table, 100); + + await expect(table.getByText('No data')).toBeVisible(); + }, + ); }); });