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

E2e test for editor page #1143

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions src/shared/constants/qa/editor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export const enum EditorPageQA {
RunButton = 'button-draw-preview',
SaveButton = 'save-entry-button',
}

export const enum EditorTemplatesQA {
NoTemplate = 'editor-templates-no-template-item',
Selector = 'editor-templates-selector-item',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import block from 'bem-cn-lite';
import {i18n} from 'i18n';
import PropTypes from 'prop-types';

import {EditorPageQA} from '../../../../../shared';
import {EVENT_DRAW_PREVIEW} from '../../constants/common';

const b = block('btn-draw-preview');
Expand Down Expand Up @@ -35,7 +36,7 @@ function ButtonDrawPreview({onDrawPreview, className, disabled}) {
size="m"
onClick={() => onDrawPreview()}
disabled={disabled}
qa="button-draw-preview"
qa={EditorPageQA.RunButton}
>
{i18n('editor.common.view', 'button_show-preview')}
</Button>
Expand Down
2 changes: 2 additions & 0 deletions src/ui/units/editor/components/ButtonSave/ButtonSave.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
sdk,
} from 'ui';

import {EditorPageQA} from '../../../../../shared';
import {
DIALOG_RESOLVE_STATUS,
ENTRY_ACTION,
Expand Down Expand Up @@ -162,6 +163,7 @@ function ButtonSave({
<div className={b()}>
<NavigationPrompt when={!disabledSave} />
<Button
qa={EditorPageQA.SaveButton}
view={getBtnSaveTheme()}
size="m"
disabled={disabledSave}
Expand Down
1 change: 1 addition & 0 deletions tests/page-objects/constants/common-selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const enum CommonSelectors {
}

export const enum DialogSelectors {
CloseDialogButton = '.g-dialog-btn-close__btn',
ApplyButton = '.g-dialog-footer__button_action_apply',
}

Expand Down
15 changes: 13 additions & 2 deletions tests/page-objects/editor/EditorPage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {slct} from '../../utils';
import {deleteEntity, entryDialogFillAndSave, slct} from '../../utils';
import {BasePage, BasePageProps} from '../BasePage';
import ChartKit from '../wizard/ChartKit';
import {EditorPageQA} from '../../../src/shared';

interface EditorPageProps extends BasePageProps {}

Expand All @@ -18,7 +19,17 @@ class EditorPage extends BasePage {
}

async drawPreview() {
await this.page.click(slct('button-draw-preview'));
await this.page.click(slct(EditorPageQA.RunButton));
}

async saveChartEntry(entryName: string) {
await this.page.locator(slct(EditorPageQA.SaveButton)).click();

await entryDialogFillAndSave(this.page, entryName);
}

async deleteEntry() {
await deleteEntity(this.page);
}
}

Expand Down
6 changes: 3 additions & 3 deletions tests/suites/editor/errorProxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import {Page} from '@playwright/test';

import EditorPage from '../../page-objects/editor/EditorPage';
import datalensTest from '../../utils/playwright/globalTestDefinition';
import {openTestPage} from '../../utils';
import {openTestPage, slct} from '../../utils';
import {RobotChartsEditorUrls} from '../../utils/constants';
import {DEFAULT_QUERY} from '../../page-objects/constants/base';
import {EditorPageQA} from '../../../src/shared';

const SELECTORS = {
RUN_BUTTON: '[data-qa=button-draw-preview]',
CHARKIT_ERROR: '[data-qa=chartkit-error]',
};

Expand All @@ -23,7 +23,7 @@ datalensTest.describe('ChartEditor passing JS errors to the user', () => {
const editor = await page.waitForSelector('.view-line');
await editor.click();
await editor.type('Hello World!');
const runButton = await page.waitForSelector(SELECTORS.RUN_BUTTON);
const runButton = await page.waitForSelector(slct(EditorPageQA.RunButton));
await runButton.click();
const charkitError = await page.waitForSelector(SELECTORS.CHARKIT_ERROR);
const errotTitle = await charkitError.waitForSelector('.datalens-chartkit-error__title');
Expand Down
3 changes: 1 addition & 2 deletions tests/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export enum RobotChartsDatasets {
SampleCHDataset = 'sample-csv-dataset',
CitiesDataset = 'cities-dataset',
SampleDsWithoutProfit = 'dataset-sample-without-profit',
BigDataset = 'big-dataset',
ObligatoryFilterDataset = 'dataset-with-obligatory-filters-duplicate',
DatasetWithParameters = 'sample-csv-dataset-with-parameters',
OrderSalesDataset = 'order-sales-ds',
Expand All @@ -15,7 +14,6 @@ export enum RobotChartsDatasets {

export enum RobotChartsWizardUrls {
Empty = '/wizard/',
WizardWithParameterDataset = '/wizard/?__datasetId=ktrfwixwpwikc',
WizardCitiesDataset = '/wizard/?__datasetId=uxyjsgrbam4sk',
WizardForDatasetSampleCh = '/wizard/?__datasetId=bfvw78uczxp65',
WizardForGeoDataset = '/wizard/?__datasetId=f9v6rrirbjjka',
Expand Down Expand Up @@ -65,6 +63,7 @@ export enum RobotChartsWizardUrls {
export enum RobotChartsEditorUrls {
EditorNew = '/editor/new',
EditorEmptyDraft = '/editor/draft',
EditorNewTableFromTemplate = '/editor/draft/table',
EditorWithWizardId = '/editor/ikblc7qjn4reb',
EditorWithSQLId = '/editor/estm3g44u4g84',
InputWithReset = '/editor/gx2pqz0oqtno6',
Expand Down
Loading