Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pagination error for table without columns or measures #1116

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
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', () => {
datalensTest.beforeEach(async ({page, config}) => {
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');
Expand All @@ -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(
Expand All @@ -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();
},
);
});
});
Loading