Skip to content

Commit 7bb9cfe

Browse files
committed
merge: Merge branch 'ESAS/display_etl_runner_name_PROD-13334'
2 parents a67d177 + 9c302c9 commit 7bb9cfe

File tree

7 files changed

+132
-10
lines changed

7 files changed

+132
-10
lines changed

cypress/e2e/brewery/DatasetManager.cy.js

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
DATASETS_TO_REFRESH,
1010
ORGANIZATION_WITH_DEFAULT_ROLE_USER,
1111
} from '../../fixtures/stubbing/DatasetManager';
12+
import { RUNNERS_FOR_ETL_DATASETS } from '../../fixtures/stubbing/DatasetManager/runners';
13+
import { SOLUTION_WITH_TRANSLATED_RUN_TEMPLATES } from '../../fixtures/stubbing/DatasetManager/solutions';
1214
import { USER_EXAMPLE } from '../../fixtures/stubbing/default';
1315

1416
const WORKSPACES = [WORKSPACE];
@@ -43,30 +45,48 @@ describe('Data edition in dataset manager', () => {
4345
before(() => {
4446
stub.start();
4547
stub.setWorkspaces(WORKSPACES);
48+
stub.setSolutions([SOLUTION_WITH_TRANSLATED_RUN_TEMPLATES]);
4649
// we use the copy of DATASETS array to be able to reuse the same fixture
4750
// in all tests in the suite. The cypress doc says that "fixture files are
4851
// assumed to be unchanged during the test, and thus Cypress loads them just once",
4952
// perhaps, we are modifying the list while creating and deleting datasets, so,
5053
// to keep the same list at the beginning of every describe block, we provide a copy
5154
// to stubbing function
5255
stub.setDatasets([...DATASETS]);
56+
stub.setRunners(RUNNERS_FOR_ETL_DATASETS);
5357
});
5458
beforeEach(() => Login.login({ url: '/W-stbbdbrwryWithDM', workspaceId: 'W-stbbdbrwryWithDM' }));
5559
after(stub.stop);
5660

57-
it('can edit datasets metadata', () => {
61+
it('can display and edit datasets metadata', () => {
5862
const DATASET_A = DATASETS[0];
5963
const DATASET_B = DATASETS[1];
64+
const DATASET_ETL = DATASETS[3];
65+
const SUBDATASET = DATASETS[4];
6066
const DATASET_Z = DATASETS[2]; // Non-main dataset
6167

6268
DatasetManager.ignoreDatasetTwingraphQueries();
6369
DatasetManager.switchToDatasetManagerView();
6470

65-
DatasetManager.getDatasetsListItemButtons().should('have.length', 2);
71+
DatasetManager.getDatasetsListItemButtons().should('have.length', 4);
6672
DatasetManager.getDatasetsListItemButton(DATASET_A.id).should('be.visible');
6773
DatasetManager.getDatasetsListItemButton(DATASET_B.id).should('be.visible');
74+
DatasetManager.getDatasetsListItemButton(DATASET_ETL.id).should('be.visible');
75+
DatasetManager.getDatasetsListItemButton(SUBDATASET.id).should('be.visible');
6876
DatasetManager.getDatasetsListItemButton(DATASET_Z.id).should('not.exist');
6977

78+
DatasetManager.selectDatasetById(DATASET_ETL.id);
79+
DatasetManager.getDatasetMetadataSourceType().should(
80+
'have.text',
81+
'Source:' + 'ETL run template with dynamic filter'
82+
);
83+
84+
DatasetManager.selectDatasetById(SUBDATASET.id);
85+
DatasetManager.getDatasetMetadataSourceType().should(
86+
'have.text',
87+
'Source:' + 'Subdataset run template with static filter'
88+
);
89+
7090
DatasetManager.selectDatasetById(DATASET_A.id);
7191
DatasetManager.getDatasetMetadataDescription().should('contain', DATASET_A.description);
7292
DatasetManager.getDatasetMetadataTags().should('have.length', 2);
@@ -136,7 +156,7 @@ describe('Dataset creation', () => {
136156

137157
DatasetManager.ignoreDatasetTwingraphQueries();
138158
DatasetManager.switchToDatasetManagerView();
139-
DatasetManager.getDatasetsListItemButtons().should('have.length', 2);
159+
DatasetManager.getDatasetsListItemButtons().should('have.length', 4);
140160
DatasetManager.startDatasetCreation();
141161
DatasetManager.setNewDatasetName(datasetName);
142162
datasetTags.forEach((tag) => DatasetManager.addNewDatasetTag(tag));
@@ -251,14 +271,16 @@ describe('Dataset delete', () => {
251271
it('can delete all scenarios from the list and display noDatasets placeholder', () => {
252272
DatasetManager.ignoreDatasetTwingraphQueries();
253273
DatasetManager.switchToDatasetManagerView();
254-
DatasetManager.getDatasetsListItemButtons().should('have.length', 2);
274+
DatasetManager.getDatasetsListItemButtons().should('have.length', 4);
255275
DatasetManager.getDatasetDeleteButton(DATASETS[0].id).click();
256276
DatasetManager.getDeleteDatasetDialog().should('be.visible');
257277
DatasetManager.getDeleteDatasetDialogBody().contains(DATASETS[0].name);
258278
DatasetManager.closeDeleteDatasetDialog();
259279
DatasetManager.deleteDataset(DATASETS[0].id, DATASETS[0].name);
260-
DatasetManager.getDatasetsListItemButtons().should('have.length', 1);
280+
DatasetManager.getDatasetsListItemButtons().should('have.length', 3);
261281
DatasetManager.deleteDataset(DATASETS[1].id, DATASETS[1].name);
282+
DatasetManager.deleteDataset(DATASETS[3].id, DATASETS[3].name);
283+
DatasetManager.deleteDataset(DATASETS[4].id, DATASETS[4].name);
262284
DatasetManager.getNoDatasetsPlaceholder().should('be.visible');
263285
DatasetManager.getNoDatasetsPlaceholderUserSubtitle().should('not.exist'); // Default role not set to "user"
264286
});

cypress/fixtures/stubbing/DatasetManager/datasets.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,39 @@ const FILE_DATASET_NON_MAIN = {
3535
description: 'hidden dataset',
3636
};
3737

38+
const ETL_DATASET = {
39+
...EDITABLE_DATASET,
40+
main: true,
41+
id: 'D-stbdataset13',
42+
parentId: 'D-stbdataset2',
43+
name: 'Dataset ETL',
44+
description: 'ETL dataset',
45+
sourceType: 'ETL',
46+
source: {
47+
location: 'W-stbbdbrwry',
48+
name: 'r-stbdrnr1',
49+
path: null,
50+
jobId: 'run-stbrun1',
51+
},
52+
tags: ['dataset', 'ETL'],
53+
};
54+
55+
const SUBDATASET = {
56+
...EDITABLE_DATASET,
57+
main: true,
58+
id: 'D-stbdataset14',
59+
name: 'Subdataset',
60+
description: 'ETL dataset',
61+
sourceType: 'ETL',
62+
source: {
63+
location: 'W-stbbdbrwry',
64+
name: 'r-stbdrnr2',
65+
path: null,
66+
jobId: 'run-stbrun2',
67+
},
68+
tags: ['dataset', 'ETL'],
69+
};
70+
3871
const DATASET_AMSTERDAM = {
3972
...EDITABLE_DATASET,
4073
id: 'D-stbdataset3',
@@ -125,7 +158,7 @@ const DATASET_TWINGRAPH_B = {
125158
twincacheStatus: 'FULL',
126159
};
127160

128-
export const DATASETS = [FILE_DATASET_MAIN_A, FILE_DATASET_MAIN_B, FILE_DATASET_NON_MAIN];
161+
export const DATASETS = [FILE_DATASET_MAIN_A, FILE_DATASET_MAIN_B, FILE_DATASET_NON_MAIN, ETL_DATASET, SUBDATASET];
129162

130163
export const DATASETS_TO_FILTER = [
131164
DATASET_AMSTERDAM,
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) Cosmo Tech.
2+
// Licensed under the MIT license.
3+
import { DEFAULT_RUNNER } from '../default';
4+
5+
const EDITABLE_RUNNER = {
6+
...DEFAULT_RUNNER,
7+
status: 'Running',
8+
security: { default: 'admin', accessControlList: [] },
9+
};
10+
11+
const RUNNER_ETL = {
12+
...EDITABLE_RUNNER,
13+
id: 'r-stbdrnr1',
14+
organizationId: 'O-stbdbrwry',
15+
name: 'ETL Runner',
16+
description: 'Runner for ETL',
17+
runTemplateId: 'etl_run_template',
18+
};
19+
20+
const RUNNER_SUBDATASET = {
21+
...EDITABLE_RUNNER,
22+
id: 'r-stbdrnr2',
23+
organizationId: 'O-stbdbrwry',
24+
name: 'Subdataset runner',
25+
description: 'Runner for subdataset ETL',
26+
runTemplateId: 'subdataset_run_template',
27+
};
28+
29+
export const RUNNERS_FOR_ETL_DATASETS = [RUNNER_ETL, RUNNER_SUBDATASET];

cypress/fixtures/stubbing/DatasetManager/solutions.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,23 @@ export const SOLUTION_WITH_DYNAMIC_VALUES = {
6868
{ id: 'dynamic_values_enum_filter', parameterGroups: ['dynamicValuesEnumGroup'], tags: ['subdatasource'] },
6969
],
7070
};
71+
72+
export const SOLUTION_WITH_TRANSLATED_RUN_TEMPLATES = {
73+
...DEFAULT_SOLUTION,
74+
runTemplates: [
75+
...DEFAULT_SOLUTION.runTemplates,
76+
{
77+
id: 'etl_run_template',
78+
labels: { en: 'ETL run template with dynamic filter', fr: 'Run template avec un filtre dynamique' },
79+
tags: ['datasource'],
80+
},
81+
{
82+
id: 'subdataset_run_template',
83+
labels: {
84+
en: 'Subdataset run template with static filter',
85+
fr: 'Run template de sous-dataset avec un filtre statique',
86+
},
87+
tags: ['subdatasource'],
88+
},
89+
],
90+
};

src/views/DatasetManager/components/DatasetMetadata/DatasetMetadata.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ const useStyles = makeStyles((theme) => ({
2323
export const DatasetMetadata = () => {
2424
const classes = useStyles();
2525
const { t } = useTranslation();
26-
const { dataset, updateDataset, selectedDatasetIndex, parentDatasetName } = useDatasetMetadata();
26+
const { dataset, updateDataset, selectedDatasetIndex, parentDatasetName, etlDatasetRunTemplateName } =
27+
useDatasetMetadata();
2728
const datasetId = dataset?.id;
2829
const userPermissionsOnDataset = dataset?.security?.currentUserPermissions ?? [];
2930

@@ -123,7 +124,7 @@ export const DatasetMetadata = () => {
123124
<MetadataItem
124125
id="source-type"
125126
label={t('commoncomponents.datasetmanager.metadata.sourceType', 'Source')}
126-
value={dataset?.sourceType}
127+
value={etlDatasetRunTemplateName || dataset?.sourceType}
127128
></MetadataItem>
128129
<MetadataItem
129130
id="api-url"

src/views/DatasetManager/components/DatasetMetadata/DatasetMetadataHook.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
11
// Copyright (c) Cosmo Tech.
22
// Licensed under the MIT license.
33
import { useMemo } from 'react';
4+
import { useTranslation } from 'react-i18next';
45
import {
56
useCurrentDataset,
67
useDatasets,
78
useUpdateDataset,
89
useSelectedDatasetIndex,
910
} from '../../../../state/hooks/DatasetHooks';
11+
import { useGetETLRunners } from '../../../../state/hooks/RunnerHooks';
12+
import { TranslationUtils } from '../../../../utils';
1013

1114
export const useDatasetMetadata = () => {
15+
const { t } = useTranslation();
1216
const currentDataset = useCurrentDataset();
1317
const selectedDatasetIndex = useSelectedDatasetIndex();
18+
const runners = useGetETLRunners();
19+
20+
const etlDatasetRunTemplateName = useMemo(() => {
21+
if (currentDataset?.sourceType === 'ETL') {
22+
const datasetRelatedRunner = runners.find((runner) => runner.id === currentDataset?.source?.name) || null;
23+
return datasetRelatedRunner
24+
? t(
25+
TranslationUtils.getRunTemplateTranslationKey(datasetRelatedRunner?.runTemplateId),
26+
datasetRelatedRunner?.runTemplateId
27+
)
28+
: '';
29+
}
30+
}, [currentDataset, runners, t]);
1431
const updateDataset = useUpdateDataset();
1532

1633
const datasets = useDatasets();
@@ -20,5 +37,5 @@ export const useDatasetMetadata = () => {
2037
return parentDataset?.name;
2138
}, [datasets, currentDataset?.parentId]);
2239

23-
return { dataset: currentDataset, updateDataset, selectedDatasetIndex, parentDatasetName };
40+
return { dataset: currentDataset, updateDataset, selectedDatasetIndex, parentDatasetName, etlDatasetRunTemplateName };
2441
};

src/views/DatasetManager/components/UpdateDatasetButton/components/UpdateDatasetDialog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@ UpdateDatasetDialog.propTypes = {
7070
open: PropTypes.bool.isRequired,
7171
closeDialog: PropTypes.func.isRequired,
7272
dataset: PropTypes.object.isRequired,
73-
selectedRunner: PropTypes.object.isRequired,
73+
selectedRunner: PropTypes.object,
7474
};

0 commit comments

Comments
 (0)