diff --git a/frontend/testing/cypress/src/integration/studio/datamodel.js b/frontend/testing/cypress/src/integration/studio/datamodel.js index 31b2b88d72d..21aab43170f 100644 --- a/frontend/testing/cypress/src/integration/studio/datamodel.js +++ b/frontend/testing/cypress/src/integration/studio/datamodel.js @@ -25,7 +25,7 @@ context('datamodel', () => { cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken')); }); - it('add a new data model, and then add an object to the data model', () => { + it('Allows to add a datamodel, include an object with custom name and fields in it, and generate a C# model from it', () => { datamodel.getCreateNewButton().click(); cy.findByRole('textbox').type('datamodel'); cy.findByRole('button', { name: texts['schema_editor.create_model_confirm_button'] }).click(); @@ -37,8 +37,71 @@ context('datamodel', () => { .then(() => { datamodel.getProperty('name').should('exist'); datamodel.getNameField().clear().type('test'); + cy.get('body').click(); datamodel.getNameField().invoke('val').should('eq', 'test'); + datamodel.getProperty('test').should('exist').click(); }); + + // Add text1 + cy.findAllByRole('button', { name: texts['schema_editor.open_action_menu'] }).last().click(); + cy.findByRole('menuitem', { name: texts['schema_editor.add_field'] }) + .should('exist') + .click() + .then(() => { + datamodel.getProperty('name').should('exist'); + datamodel.getNameField().clear().type('text1'); + cy.get('body').click(); + datamodel.getNameField().invoke('val').should('eq', 'text1'); + datamodel.getProperty('text1').should('exist'); + }); + + // Add text2 + datamodel + .getProperty(/^test /) + .within(() => + cy + .findAllByRole('button', { name: texts['schema_editor.open_action_menu'] }) + .first() + .click(), + ); + cy.findByRole('menuitem', { name: texts['schema_editor.add_field'] }) + .should('exist') + .click() + .then(() => { + datamodel.getProperty('name').should('exist'); + datamodel.getNameField().clear().type('text2'); + cy.get('body').click(); + datamodel.getNameField().invoke('val').should('eq', 'text2'); + datamodel.getProperty('text2').should('exist'); + }); + + //Add number1 + datamodel + .getProperty(/^test /) + .within(() => + cy + .findAllByRole('button', { name: texts['schema_editor.open_action_menu'] }) + .first() + .click(), + ); + cy.findByRole('menuitem', { name: texts['schema_editor.add_field'] }) + .should('exist') + .click() + .then(() => { + datamodel.getTypeField().click(); + cy.findByRole('option', { name: texts['schema_editor.integer'] }).should('exist').click(); + datamodel.getProperty('name').should('exist'); + datamodel.getTypeField().invoke('val').should('eq', texts['schema_editor.integer']); + datamodel.getNameField().clear().type('number1'); + cy.get('body').click(); + datamodel.getProperty('number1').should('exist'); + }); + + // Generate model + cy.findByRole('button', { name: texts['schema_editor.generate_model_files'] }).click(); + cy.findByRole('alert', { name: texts['schema_editor.model_generation_success'] }).should( + 'be.visible', + ); }); it('edit a data model', () => { diff --git a/frontend/testing/cypress/src/selectors/dashboard.js b/frontend/testing/cypress/src/selectors/dashboard.js index 20dd05b3b22..94230f89401 100644 --- a/frontend/testing/cypress/src/selectors/dashboard.js +++ b/frontend/testing/cypress/src/selectors/dashboard.js @@ -4,17 +4,21 @@ import * as testids from '../../../testids'; const getAllAppsHeader = () => cy.findByRole('heading', { name: texts['dashboard.all_apps'] }); const getUserAppsListHeader = () => cy.findByRole('heading', { name: texts['dashboard.my_apps'] }); const getFavouritesHeader = () => cy.findByRole('heading', { name: texts['dashboard.favourites'] }); -const getSearchResultsHeader = () => cy.findByRole('heading', { name: texts['dashboard.search_result'] }); -const getOrgAppsHeader = (org) => cy.findByRole('heading', { name: texts['dashboard.org_apps'].replace('{{orgName}}', org) }); +const getSearchResultsHeader = () => + cy.findByRole('heading', { name: texts['dashboard.search_result'] }); +const getOrgAppsHeader = (org) => + cy.findByRole('heading', { name: texts['dashboard.org_apps'].replace('{{orgName}}', org) }); const getUserAppsList = () => getUserAppsListHeader().next(); const getSearchResults = () => getSearchResultsHeader().next(); -const getLinksCellForApp = (table, name) => table.findByRole('cell', { name }).siblings('div[data-field=\'links\']'); +const getLinksCellForApp = (table, name) => + table.findByRole('cell', { name }).siblings("div[data-field='links']"); export const dashboard = { getAllAppsHeader, getAppOwnerField: () => cy.findByRole('combobox', { name: texts['general.service_owner'] }), getCancelButton: () => cy.findByRole('button', { name: texts['general.cancel'] }), - getCreateAppButton: () => cy.findByRole('button', { name: texts['dashboard.create_service_btn'] }), + getCreateAppButton: () => + cy.findByRole('button', { name: texts['dashboard.create_service_btn'] }), getFavourites: () => getFavouritesHeader().next(), getFavouritesHeader, getLinksCellForSearchResultApp: (name) => getLinksCellForApp(getSearchResults(), name),