-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge: Merge branch 'ESAS/fetch_table_data_from_dataset'
- Loading branch information
Showing
17 changed files
with
538 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
cypress/e2e/brewery/TableParameters-dynamic_table.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// Copyright (c) Cosmo Tech. | ||
// Licensed under the MIT license. | ||
import { Login, ScenarioParameters, Scenarios, ScenarioSelector } from '../../commons/actions'; | ||
import { BreweryParameters } from '../../commons/actions/brewery'; | ||
import { stub } from '../../commons/services/stubbing'; | ||
import { apiUtils } from '../../commons/utils'; | ||
import { SOLUTION_WITH_DYNAMIC_TABLE } from '../../fixtures/stubbing/TableParameters-dynamic_table/solution'; | ||
import { DEFAULT_SCENARIOS_LIST } from '../../fixtures/stubbing/default'; | ||
|
||
const EDITED_DATA_CSV = 'customers_from_dataset_edited.csv'; | ||
const twingraphQueryResponse = [ | ||
{ | ||
fields: { | ||
name: 'Customer3', | ||
thirsty: false, | ||
satisfaction: 0, | ||
surroundingSatisfaction: 0, | ||
}, | ||
}, | ||
{ | ||
fields: { | ||
name: 'Customer1', | ||
thirsty: false, | ||
satisfaction: 0, | ||
surroundingSatisfaction: 0, | ||
}, | ||
}, | ||
{ | ||
fields: { | ||
name: 'Customer2', | ||
thirsty: false, | ||
satisfaction: 0, | ||
surroundingSatisfaction: 0, | ||
}, | ||
}, | ||
{ | ||
fields: { | ||
name: 'Customer4', | ||
thirsty: false, | ||
satisfaction: 0, | ||
surroundingSatisfaction: 0, | ||
}, | ||
}, | ||
]; | ||
|
||
describe('can use dataset data in editable table', () => { | ||
before(() => { | ||
stub.start(); | ||
stub.setSolutions([SOLUTION_WITH_DYNAMIC_TABLE]); | ||
}); | ||
beforeEach(() => { | ||
Login.login(); | ||
}); | ||
after(() => { | ||
stub.stop(); | ||
}); | ||
it('can display a table filled with data fetched from dataset', () => { | ||
apiUtils.interceptPostDatasetTwingraphQuery(twingraphQueryResponse, false); | ||
Scenarios.getScenarioViewTab(60).should('be.visible'); | ||
ScenarioParameters.expandParametersAccordion(); | ||
BreweryParameters.switchToCustomersTab(); | ||
BreweryParameters.getCustomersTable().should('be.visible'); | ||
BreweryParameters.getCustomersTableLabel().should('be.visible').should('have.text', 'Customers'); | ||
BreweryParameters.getCustomersTableGrid().should('exist'); | ||
BreweryParameters.getCustomersTableCell('name', 0).should('have.text', twingraphQueryResponse[0].fields.name); | ||
}); | ||
it('can export data fetched from dataset and upload a new table', () => { | ||
apiUtils.interceptPostDatasetTwingraphQuery(twingraphQueryResponse, false); | ||
Scenarios.getScenarioViewTab(60).should('be.visible'); | ||
ScenarioParameters.expandParametersAccordion(); | ||
BreweryParameters.switchToCustomersTab(); | ||
BreweryParameters.getCustomersTable().should('be.visible'); | ||
BreweryParameters.getCustomersTableGrid().should('exist'); | ||
BreweryParameters.exportCustomersTableDataToCSV(); | ||
BreweryParameters.importCustomersTableData(EDITED_DATA_CSV); | ||
BreweryParameters.getCustomersTableCell('name', 0).should('have.text', 'Client'); | ||
BreweryParameters.getCustomersTableCell('name', 1).should('have.text', 'Client'); | ||
}); | ||
it('can fetch data from dataset, edit it without saving and revert', () => { | ||
apiUtils.interceptPostDatasetTwingraphQuery(twingraphQueryResponse, false); | ||
Scenarios.getScenarioViewTab(60).should('be.visible'); | ||
ScenarioParameters.expandParametersAccordion(); | ||
BreweryParameters.getEventsRevertTableButton().should('not.exist'); | ||
BreweryParameters.switchToCustomersTab(); | ||
BreweryParameters.getCustomersTableGrid().should('exist'); | ||
BreweryParameters.getCustomersRevertTableButton().should('exist'); | ||
BreweryParameters.editCustomersTableStringCell('name', 0, 'Client').should('have.text', 'Client'); | ||
BreweryParameters.revertCustomersTable(twingraphQueryResponse); | ||
ScenarioParameters.getSaveButton().should('not.exist'); | ||
}); | ||
it('can fetch data from dataset and save table as dataset part, then revert data', () => { | ||
apiUtils.interceptPostDatasetTwingraphQuery(twingraphQueryResponse, false); | ||
Scenarios.getScenarioViewTab(60).should('be.visible'); | ||
ScenarioParameters.expandParametersAccordion(); | ||
BreweryParameters.switchToCustomersTab(); | ||
BreweryParameters.getCustomersTableGrid().should('exist'); | ||
BreweryParameters.editCustomersTableStringCell('name', 0, 'Client').should('have.text', 'Client'); | ||
ScenarioParameters.save({ datasetsEvents: [{ id: 'd-stbddtspr1', securityChanges: { default: 'admin' } }] }); | ||
BreweryParameters.switchToEventsTab(); | ||
ScenarioSelector.selectScenario(DEFAULT_SCENARIOS_LIST[1].name, DEFAULT_SCENARIOS_LIST[1].id); | ||
ScenarioSelector.selectScenario(DEFAULT_SCENARIOS_LIST[0].name, DEFAULT_SCENARIOS_LIST[0].id); | ||
apiUtils.interceptDownloadWorkspaceFile(); | ||
BreweryParameters.switchToCustomersTab(); | ||
BreweryParameters.getCustomersTableGrid().should('exist'); | ||
BreweryParameters.getCustomersTableCell('name', 0).should('have.text', 'Client'); | ||
BreweryParameters.revertCustomersTable(twingraphQueryResponse); | ||
ScenarioParameters.getSaveButton().should('exist'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name,satisfaction,surroundingSatisfaction,thirsty | ||
Client,0,0,true | ||
Client,5,0,false | ||
Customer2,0,0,false | ||
Customer4,8,0,false |
134 changes: 134 additions & 0 deletions
134
cypress/fixtures/stubbing/TableParameters-dynamic_table/solution.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
// Copyright (c) Cosmo Tech. | ||
// Licensed under the MIT license. | ||
import { DEFAULT_SOLUTION } from '../default'; | ||
|
||
export const SOLUTION_WITH_DYNAMIC_TABLE = { | ||
...DEFAULT_SOLUTION, | ||
runTemplates: [ | ||
{ | ||
id: '3', | ||
name: 'Run template with mock basic types parameters', | ||
description: 'Run template with mock basic types parameters', | ||
csmSimulation: 'BreweryDemoSimulationWithConnector', | ||
tags: ['3', 'Example'], | ||
parameterGroups: ['events', 'customers'], | ||
}, | ||
], | ||
parameterGroups: [ | ||
{ | ||
id: 'events', | ||
labels: { | ||
en: 'Events', | ||
fr: 'Événements', | ||
}, | ||
parameters: ['events'], | ||
}, | ||
{ | ||
id: 'customers', | ||
labels: { | ||
en: 'Customers', | ||
fr: 'Clients', | ||
}, | ||
parameters: ['customers'], | ||
}, | ||
], | ||
parameters: [ | ||
{ | ||
id: 'customers', | ||
labels: { | ||
fr: 'Clients', | ||
en: 'Customers', | ||
}, | ||
varType: '%DATASETID%', | ||
defaultValue: null, | ||
minValue: null, | ||
maxValue: null, | ||
regexValidation: null, | ||
options: { | ||
canChangeRowsNumber: true, | ||
connectorId: 'c-d7e5p9o0kjn9', | ||
subType: 'TABLE', | ||
dynamicValues: { | ||
query: | ||
'MATCH(customer: Customer) WITH {name: customer.id, satisfaction: customer.Satisfaction, ' + | ||
'surroundingSatisfaction: customer.SurroundingSatisfaction, thirsty: customer.Thirsty} ' + | ||
'as fields RETURN fields', | ||
resultKey: 'fields', | ||
}, | ||
columns: [ | ||
{ | ||
field: 'name', | ||
headerName: 'Name', | ||
type: ['string'], | ||
}, | ||
{ | ||
field: 'satisfaction', | ||
headerName: 'Satisfaction', | ||
type: ['int'], | ||
minValue: 0, | ||
maxValue: 10, | ||
acceptsEmptyFields: true, | ||
}, | ||
{ | ||
field: 'surroundingSatisfaction', | ||
headerName: 'SurroundingSatisfaction', | ||
type: ['int'], | ||
minValue: 0, | ||
maxValue: 10, | ||
acceptsEmptyFields: true, | ||
}, | ||
{ | ||
field: 'thirsty', | ||
headerName: 'Thirsty', | ||
type: ['bool'], | ||
acceptsEmptyFields: true, | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
id: 'events', | ||
labels: { | ||
fr: 'Événements', | ||
en: 'Events', | ||
}, | ||
varType: '%DATASETID%', | ||
options: { | ||
subType: 'TABLE', | ||
columns: [ | ||
{ | ||
field: 'theme', | ||
type: ['string'], | ||
}, | ||
{ | ||
field: 'date', | ||
type: ['date'], | ||
minValue: '1900-01-01', | ||
maxValue: '2999-12-31', | ||
}, | ||
{ | ||
field: 'timeOfDay', | ||
type: ['enum'], | ||
enumValues: ['morning', 'midday', 'afternoon', 'evening'], | ||
}, | ||
{ | ||
field: 'eventType', | ||
type: ['string', 'nonResizable', 'nonEditable'], | ||
}, | ||
{ | ||
field: 'reservationsNumber', | ||
type: ['int'], | ||
minValue: 0, | ||
maxValue: 300, | ||
acceptsEmptyFields: true, | ||
}, | ||
{ | ||
field: 'online', | ||
type: ['bool', 'nonSortable'], | ||
}, | ||
], | ||
dateFormat: 'dd/MM/yyyy', | ||
}, | ||
}, | ||
], | ||
}; |
Oops, something went wrong.