Skip to content

Commit

Permalink
fix: make limit rows less or equal to 100_000
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Nov 25, 2024
1 parent 017b983 commit af2c6d9
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export const querySettingsValidationSchema = z.object({
),
limitRows: z.preprocess(
(val) => (val === '' ? undefined : val),
z.coerce.number().gt(0).lte(10_000).or(z.undefined()),
z.coerce.number().gt(0).lte(100_000).or(z.undefined()),
),
queryMode: queryModeSchema,
transactionMode: transactionModeSchema,
Expand All @@ -340,7 +340,7 @@ export const querySettingsRestoreSchema = z
),
limitRows: z.preprocess(
(val) => (val === '' ? undefined : val),
z.coerce.number().gt(0).lte(10_000).optional().catch(DEFAULT_QUERY_SETTINGS.limitRows),
z.coerce.number().gt(0).lte(100_000).optional().catch(DEFAULT_QUERY_SETTINGS.limitRows),
),
queryMode: queryModeSchema.catch(DEFAULT_QUERY_SETTINGS.queryMode),
transactionMode: transactionModeSchema.catch(DEFAULT_QUERY_SETTINGS.transactionMode),
Expand Down
25 changes: 25 additions & 0 deletions tests/suites/tenant/queryEditor/models/SettingsDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export class SettingsDialog {
private page: Page;
private selectPopup: Locator;
private limitRowsInput: Locator;
private limitRowsErrorIcon: Locator;
private limitRowsErrorPopover: Locator;

private queryModeSelect: Locator;
private transactionModeSelect: Locator;
Expand All @@ -25,6 +27,10 @@ export class SettingsDialog {
this.dialog = page.locator('.ydb-query-settings-dialog');

this.limitRowsInput = this.dialog.locator('.ydb-query-settings-dialog__limit-rows input');
this.limitRowsErrorIcon = this.dialog.locator(
'.ydb-query-settings-dialog__limit-rows [data-qa="control-error-icon-qa"]',
);
this.limitRowsErrorPopover = this.page.locator('.g-popover__tooltip-content');
this.selectPopup = page.locator('.ydb-query-settings-select__popup');

// Define distinct locators for selects
Expand Down Expand Up @@ -79,6 +85,25 @@ export class SettingsDialog {
await this.page.waitForTimeout(1000);
}

async clearLimitRows() {
await this.limitRowsInput.clear();
await this.page.waitForTimeout(1000);
}

async getLimitRowsValue() {
return await this.limitRowsInput.inputValue();
}

async isLimitRowsError() {
return await this.limitRowsErrorIcon.isVisible();
}

async getLimitRowsErrorMessage() {
await this.limitRowsErrorIcon.hover();
await this.limitRowsErrorPopover.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
return await this.limitRowsErrorPopover.textContent();
}

async clickButton(buttonName: ButtonNames) {
const button = this.dialog.getByRole('button', {name: buttonName});
await button.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
Expand Down
53 changes: 53 additions & 0 deletions tests/suites/tenant/queryEditor/querySettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,57 @@ test.describe('Test Query Settings', async () => {

await expect(queryEditor.isBannerHidden()).resolves.toBe(true);
});

test('Shows error for limit rows > 100000', async ({page}) => {
const queryEditor = new QueryEditor(page);
await queryEditor.clickGearButton();

await queryEditor.settingsDialog.changeLimitRows(100001);
await queryEditor.settingsDialog.clickButton(ButtonNames.Save);

await expect(queryEditor.settingsDialog.isLimitRowsError()).resolves.toBe(true);
await expect(queryEditor.settingsDialog.getLimitRowsErrorMessage()).resolves.toBe(
'Number must be less than or equal to 100000',
);
});

test('Shows error for negative limit rows', async ({page}) => {
const queryEditor = new QueryEditor(page);
await queryEditor.clickGearButton();

await queryEditor.settingsDialog.changeLimitRows(-1);
await queryEditor.settingsDialog.clickButton(ButtonNames.Save);

await expect(queryEditor.settingsDialog.isLimitRowsError()).resolves.toBe(true);
await expect(queryEditor.settingsDialog.getLimitRowsErrorMessage()).resolves.toBe(
'Number must be greater than 0',
);
});

test('Persists valid limit rows value', async ({page}) => {
const queryEditor = new QueryEditor(page);
const validValue = 50000;

// Set value and save
await queryEditor.clickGearButton();
await queryEditor.settingsDialog.changeLimitRows(validValue);
await queryEditor.settingsDialog.clickButton(ButtonNames.Save);
await expect(queryEditor.settingsDialog.isHidden()).resolves.toBe(true);

// Reopen and check value
await queryEditor.clickGearButton();
await expect(queryEditor.settingsDialog.getLimitRowsValue()).resolves.toBe(
validValue.toString(),
);
});

test('Allows empty limit rows value', async ({page}) => {
const queryEditor = new QueryEditor(page);

await queryEditor.clickGearButton();
await queryEditor.settingsDialog.clearLimitRows();
await queryEditor.settingsDialog.clickButton(ButtonNames.Save);

await expect(queryEditor.settingsDialog.isHidden()).resolves.toBe(true);
});
});

0 comments on commit af2c6d9

Please sign in to comment.