Skip to content

Commit

Permalink
Add collections e2e tests (#1846)
Browse files Browse the repository at this point in the history
  • Loading branch information
stepanenkoxx authored Dec 4, 2024
1 parent d118094 commit d816ba8
Show file tree
Hide file tree
Showing 22 changed files with 272 additions and 40 deletions.
5 changes: 3 additions & 2 deletions scripts/e2e/us-dump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ if [ $CONNECTION_CHECK_RESULT_STATUS_CODE -ne 0 ]; then
exit 1
fi

DUMP_CMD="pg_dump --dbname=$US_CONNECTION --column-inserts -a -t workbooks -t entries -t revisions -t links"
docker exec -it $US_CONTAINER_ID /bin/sh -c "$DUMP_CMD" | grep -Ev "^(--|SET|SELECT pg_catalog.set_config)" >$DUMP_TMP
DUMP_CMD="pg_dump --dbname=$US_CONNECTION --disable-triggers --column-inserts -a -t collections -t workbooks -t entries -t revisions -t links"
docker exec -it $US_CONTAINER_ID /bin/sh -c "$DUMP_CMD" |
tee >(grep -Ev "^(--|SET|SELECT pg_catalog.set_config|pg_dump:)" >$DUMP_TMP) | grep "pg_dump:"
DUMP_RESULT_STATUS_CODE=$?

if [ $DUMP_RESULT_STATUS_CODE -ne 0 ]; then
Expand Down
6 changes: 6 additions & 0 deletions src/shared/constants/qa/collections.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const enum CollectionContentTableQa {
Table = 'coll-content-table',
CollectionLinkRow = 'coll-content-table-coll-link-row',
WorkbookLinkRow = 'coll-content-table-workbook-link-row',
CollectionTitleCell = 'coll-content-table-coll-title-cell',
}
17 changes: 9 additions & 8 deletions src/shared/constants/qa/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
export {VisualizationsQa} from './visualization';
export * from './chart';
export * from './collections';
export * from './components';
export * from './connections';
export * from './chart';
export * from './editor';
export * from './datasets';
export * from './control';
export * from './dash';
export * from './datasets';
export * from './dl-navigation';
export * from './wizard';
export * from './control';
export * from './ql';
export * from './editor';
export * from './field-editor';
export {VisualizationsQa} from './visualization';
export * from './uikit';
export * from './ql';
export * from './settings';
export * from './uikit';
export * from './wizard';
3 changes: 2 additions & 1 deletion src/shared/constants/qa/workbooks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export enum WorkbookPage {
export enum WorkbookPageQa {
ListItem = 'workbook-page-list-item',
MenuDropDownBtn = 'workbook-page-list-item-menu-btn',
MenuItemDuplicate = 'workbook-page-list-item-menu-item-duplicate',
Filters = 'workbook-page-filters',
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {Checkbox, DropdownMenu, Tooltip} from '@gravity-ui/uikit';
import block from 'bem-cn-lite';
import {I18n} from 'i18n';
import {useSelector} from 'react-redux';
import {DEFAULT_DATE_FORMAT} from 'shared/constants';
import {CollectionContentTableQa, DEFAULT_DATE_FORMAT} from 'shared/constants';
import {DL} from 'ui/constants/common';
import {selectDateTimeFormat} from 'ui/store/selectors/user';

Expand Down Expand Up @@ -74,7 +74,7 @@ export const CollectionContentTable = React.memo<Props>(

if (DL.IS_MOBILE) {
return (
<div className={b({mobile: true})}>
<div className={b({mobile: true})} data-qa={CollectionContentTableQa.Table}>
<AnimateBlock>
<div className={b('table')}>
<div className={b('content')}>
Expand Down Expand Up @@ -107,7 +107,7 @@ export const CollectionContentTable = React.memo<Props>(
}

return (
<div className={b()}>
<div className={b()} data-qa={CollectionContentTableQa.Table}>
<AnimateBlock>
<div className={b('table')}>
<div className={b('header')}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import block from 'bem-cn-lite';
import {batch, useDispatch, useSelector} from 'react-redux';
import {Link} from 'react-router-dom';
import {CollectionContentTableQa} from 'shared';
import type {CollectionWithPermissions, WorkbookWithPermissions} from 'shared/schema/types';
import {DL} from 'ui/constants/common';
import {selectCollectionBreadcrumbs} from 'ui/units/collections-navigation/store/selectors';
Expand All @@ -24,17 +25,24 @@ export const CollectionLinkRow: React.FC<CollectionLinkRowProps> = ({children, i
const dispatch = useDispatch();
const breadcrumbs = useSelector(selectCollectionBreadcrumbs) ?? [];

const isWorkbookItem = 'workbookId' in item;

return (
<Link
data-qa={
isWorkbookItem
? CollectionContentTableQa.WorkbookLinkRow
: CollectionContentTableQa.CollectionLinkRow
}
to={
'workbookId' in item
isWorkbookItem
? `${WORKBOOKS_PATH}/${item.workbookId}`
: `${COLLECTIONS_PATH}/${item.collectionId}`
}
className={b('content-row')}
onClick={(e) => {
if (!e.metaKey && !e.ctrlKey) {
if ('workbookId' in item) {
if (isWorkbookItem) {
dispatch(setWorkbook(item));
} else {
batch(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';

import block from 'bem-cn-lite';
import {CollectionContentTableQa} from 'shared';
import {CollectionIcon} from 'ui/components/CollectionIcon/CollectionIcon';
import {WorkbookIcon} from 'ui/components/WorkbookIcon/WorkbookIcon';
import {DL} from 'ui/constants/common';
Expand All @@ -25,7 +26,11 @@ export const CollectionTitleCell = ({
const collectionSize = DL.IS_MOBILE ? 28 : undefined;

return (
<div className={b('content-cell', {title: true})} key={collectionId}>
<div
className={b('content-cell', {title: true})}
key={collectionId}
data-qa={CollectionContentTableQa.CollectionTitleCell}
>
<div className={b('title-col')}>
<div>
{isWorkbook ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {DropdownMenu} from '@gravity-ui/uikit';
import {I18n} from 'i18n';
import {Feature} from 'shared';
import type {ConnectorType} from 'shared/constants/connections';
import {WorkbookPage} from 'shared/constants/qa/workbooks';
import {WorkbookPageQa} from 'shared/constants/qa/workbooks';
import type {WorkbookWithPermissions} from 'shared/schema/us/types';
import {EntryScope} from 'shared/types/common';
import {S3_BASED_CONNECTORS} from 'ui/constants';
Expand Down Expand Up @@ -58,7 +58,7 @@ export const EntryActions = ({
{
action: onDuplicateEntry,
text: <DropdownAction icon={Copy} text={i18n('action_duplicate')} />,
qa: WorkbookPage.MenuItemDuplicate,
qa: WorkbookPageQa.MenuItemDuplicate,
},
]
: []),
Expand Down Expand Up @@ -100,7 +100,7 @@ export const EntryActions = ({
<DropdownMenu
size="m"
items={items}
defaultSwitcherProps={{qa: WorkbookPage.MenuDropDownBtn}}
defaultSwitcherProps={{qa: WorkbookPageQa.MenuDropDownBtn}}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {I18n} from 'i18n';
import {useDispatch} from 'react-redux';
import {Link} from 'react-router-dom';
import {DEFAULT_DATE_FORMAT} from 'shared';
import {WorkbookPage} from 'shared/constants/qa/workbooks';
import {WorkbookPageQa} from 'shared/constants/qa/workbooks';
import type {WorkbookWithPermissions} from 'shared/schema/us/types/workbooks';
import {registry} from 'ui/registry/index';
import type {AppDispatch} from 'ui/store';
Expand Down Expand Up @@ -81,7 +81,7 @@ const Row: React.FC<RowProps> = ({
to={url}
className={b({mobile: true})}
style={mobileRowStyle}
data-qa={WorkbookPage.ListItem}
data-qa={WorkbookPageQa.ListItem}
>
<div className={b('content-cell', {title: true})} data-qa={item.entryId}>
<div className={b('title-col')}>
Expand All @@ -101,7 +101,7 @@ const Row: React.FC<RowProps> = ({
}

return (
<Link to={url} className={b()} style={defaultRowStyle} data-qa={WorkbookPage.ListItem}>
<Link to={url} className={b()} style={defaultRowStyle} data-qa={WorkbookPageQa.ListItem}>
<div className={b('content-cell', {title: true})} data-qa={item.entryId}>
<div className={b('title-col', {'is-mobile': DL.IS_MOBILE})}>
<EntryIcon entry={item} width={24} height={24} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {Select} from '@gravity-ui/uikit';
import block from 'bem-cn-lite';
import {DebouncedInput} from 'components/DebouncedInput/DebouncedInput';
import {I18n} from 'i18n';
import {WorkbookPageQa} from 'shared/constants/qa/workbooks';
import type {OrderDirection, OrderWorkbookEntriesField} from 'shared/schema/us/types/sort';

import type {WorkbookEntriesFilters} from '../../types';
Expand Down Expand Up @@ -94,7 +95,7 @@ export const WorkbookFilters = ({className, filters, onChange}: Props) => {

return (
<div className={b(null, className)}>
<div className={b('controls')}>
<div className={b('controls')} data-qa={WorkbookPageQa.Filters}>
<DebouncedInput
className={b('filter-string')}
value={filterString}
Expand Down
8 changes: 8 additions & 0 deletions tests/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ export const WorkbookIds = {
export const WorkbooksUrls = {
E2EWorkbook: `/workbooks/${WorkbookIds.E2EWorkbook}`,
};

export const CollectionIds = {
E2ECollection: 'm45slvqc2k9q9',
};

export const CollectionsUrls = {
E2ECollection: `/collections/${CollectionIds.E2ECollection}`,
};
25 changes: 25 additions & 0 deletions tests/data/us-e2e-data

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions tests/opensource-suites/collections/OpenCollectionsPage.test.tsx

This file was deleted.

35 changes: 35 additions & 0 deletions tests/opensource-suites/collections/contentTableItemsLinks.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {openTestPage} from '../../utils';
import datalensTest from '../../utils/playwright/globalTestDefinition';
import {CollectionsPagePO} from '../../page-objects/collections';
import {Workbook} from '../../page-objects/workbook/Workbook';
import {WorkbooksUrls, CollectionsUrls} from '../../constants/constants';

datalensTest.describe('Collections page', () => {
datalensTest.describe('Content table', () => {
datalensTest.beforeEach(async ({page}) => {
await openTestPage(page, `/collections`);
});

datalensTest('Workbook row link leads to workbook page', async ({page}) => {
const {contentTable} = new CollectionsPagePO({page});

await contentTable.clickWorkbookRowLink();

await page.waitForURL(WorkbooksUrls.E2EWorkbook);

const {filters} = new Workbook(page);

await filters.waitForVisible();
});

datalensTest('Collection row link leads to collection page', async ({page}) => {
const {contentTable, emptyState} = new CollectionsPagePO({page});

await contentTable.clickCollectionRowLink();

await page.waitForURL(CollectionsUrls.E2ECollection);

await emptyState.waitForVisible();
});
});
});
28 changes: 28 additions & 0 deletions tests/page-objects/collections/CollectionsPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {BasePage} from '../BasePage';
import type {BasePageProps} from '../BasePage';
import {ContentTablePO} from './ContentTable';
import {EmptyStatePO} from './EmptyState';

type CollectionsPageProps = BasePageProps;

export class CollectionsPagePO extends BasePage {
private readonly root = '.dl-collections-navigation-layout';

constructor({page}: CollectionsPageProps) {
super({page});
}

get emptyState() {
return new EmptyStatePO({
page: this.page,
parent: this.root,
});
}

get contentTable() {
return new ContentTablePO({
page: this.page,
parent: this.root,
});
}
}
50 changes: 50 additions & 0 deletions tests/page-objects/collections/ContentTable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import {Page} from '@playwright/test';
import {CollectionContentTableQa} from '../../../src/shared';
import {slct} from '../../utils';
import {ElementPO} from '../common/abstract/ElementPO';
import {ContentTableRowPO} from './ContentTableRow';

type ContentTableProps = {
page: Page;
parent: string;
};

export class ContentTablePO extends ElementPO {
constructor({page, parent}: ContentTableProps) {
super({
page,
selectors: {
root: slct(CollectionContentTableQa.Table),
parent,
},
});
}

get collectionRow() {
return new ContentTableRowPO({
page: this.page,
selectors: {
parent: this.getSelector(),
root: slct(CollectionContentTableQa.CollectionLinkRow),
},
});
}

get workbookRow() {
return new ContentTableRowPO({
page: this.page,
selectors: {
parent: this.getSelector(),
root: slct(CollectionContentTableQa.WorkbookLinkRow),
},
});
}

async clickCollectionRowLink() {
await this.collectionRow.clickRowLink();
}

async clickWorkbookRowLink() {
await this.workbookRow.clickRowLink();
}
}
26 changes: 26 additions & 0 deletions tests/page-objects/collections/ContentTableRow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {CollectionContentTableQa} from '../../../src/shared';
import {ElementPO} from '../common/abstract/ElementPO';
import type {ElementPOProps} from '../common/abstract/types';
import {slct} from '../../utils';

type ContentTableRowProps = ElementPOProps;

export class ContentTableRowPO extends ElementPO {
constructor({page, selectors}: ContentTableRowProps) {
super({page, selectors});
}

get rowTitleCell() {
return new ElementPO({
page: this.page,
selectors: {
parent: this.getSelector(),
root: slct(CollectionContentTableQa.CollectionTitleCell),
},
});
}

async clickRowLink() {
await this.rowTitleCell.click();
}
}
19 changes: 19 additions & 0 deletions tests/page-objects/collections/EmptyState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {Page} from '@playwright/test';
import {ElementPO} from '../common/abstract/ElementPO';

type EmptyStateProps = {
page: Page;
parent: string;
};

export class EmptyStatePO extends ElementPO {
constructor({page, parent}: EmptyStateProps) {
super({
page,
selectors: {
root: '.dl-collection-content__empty-state',
parent,
},
});
}
}
1 change: 1 addition & 0 deletions tests/page-objects/collections/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {CollectionsPagePO} from './CollectionsPage';
Loading

0 comments on commit d816ba8

Please sign in to comment.