From 055a1eb00ffd380dad9eec7b8533111dc8e35bbc Mon Sep 17 00:00:00 2001 From: JamalAlabdullah Date: Tue, 14 Nov 2023 15:31:16 +0100 Subject: [PATCH 1/4] added new reg/test to cypress --- .../src/integration/studio/datamodel.js | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/frontend/testing/cypress/src/integration/studio/datamodel.js b/frontend/testing/cypress/src/integration/studio/datamodel.js index 31b2b88d72d..c361ab43393 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('add a new data model, then add an object to the data model and rename it, after that add two string(text1 and text2) and one integer(number1) to the newly added object (test). ', () => { datamodel.getCreateNewButton().click(); cy.findByRole('textbox').type('datamodel'); cy.findByRole('button', { name: texts['schema_editor.create_model_confirm_button'] }).click(); @@ -37,7 +37,58 @@ 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 + cy.findAllByRole('button', { name: texts['schema_editor.open_action_menu'] }) + .should('exist') + .then((button) => { + button[3].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 + cy.findAllByRole('button', { name: texts['schema_editor.open_action_menu'] }) + .should('exist') + .then((button) => { + button[3].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'); }); }); From 48f380b8b31850f226f072aec975cee2408f7b6f Mon Sep 17 00:00:00 2001 From: JamalAlabdullah Date: Wed, 15 Nov 2023 12:32:00 +0100 Subject: [PATCH 2/4] added test for genereting datamodel --- .../testing/cypress/src/integration/studio/datamodel.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/testing/cypress/src/integration/studio/datamodel.js b/frontend/testing/cypress/src/integration/studio/datamodel.js index c361ab43393..6382deb4820 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, then add an object to the data model and rename it, after that add two string(text1 and text2) and one integer(number1) to the newly added object (test). ', () => { + it('Add a new data model, include an object in the data model, and rename it. After that, add two strings (text1 and text2) and one integer (number1) to the object (test). Finally, check if generating the model is okay.', () => { datamodel.getCreateNewButton().click(); cy.findByRole('textbox').type('datamodel'); cy.findByRole('button', { name: texts['schema_editor.create_model_confirm_button'] }).click(); @@ -90,6 +90,12 @@ context('datamodel', () => { 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', () => { From bf5444918a8c3c9bd3c436e042b41c5389b568f2 Mon Sep 17 00:00:00 2001 From: JamalAlabdullah Date: Mon, 20 Nov 2023 09:44:45 +0100 Subject: [PATCH 3/4] update datamodel test --- .../src/integration/studio/datamodel.js | 28 +++++++++++-------- .../cypress/src/selectors/dashboard.js | 12 +++++--- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/frontend/testing/cypress/src/integration/studio/datamodel.js b/frontend/testing/cypress/src/integration/studio/datamodel.js index 6382deb4820..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, include an object in the data model, and rename it. After that, add two strings (text1 and text2) and one integer (number1) to the object (test). Finally, check if generating the model is okay.', () => { + 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(); @@ -56,11 +56,14 @@ context('datamodel', () => { }); // Add text2 - cy.findAllByRole('button', { name: texts['schema_editor.open_action_menu'] }) - .should('exist') - .then((button) => { - button[3].click(); - }); + 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() @@ -73,11 +76,14 @@ context('datamodel', () => { }); //Add number1 - cy.findAllByRole('button', { name: texts['schema_editor.open_action_menu'] }) - .should('exist') - .then((button) => { - button[3].click(); - }); + 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() diff --git a/frontend/testing/cypress/src/selectors/dashboard.js b/frontend/testing/cypress/src/selectors/dashboard.js index 20dd05b3b22..8415bca9101 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.findAllByRole('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), From 0e69279db6d6e9f93a69e5894baaa886010bbe23 Mon Sep 17 00:00:00 2001 From: JamalAlabdullah Date: Tue, 21 Nov 2023 10:03:13 +0100 Subject: [PATCH 4/4] updated test --- frontend/testing/cypress/src/selectors/dashboard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/testing/cypress/src/selectors/dashboard.js b/frontend/testing/cypress/src/selectors/dashboard.js index 8415bca9101..94230f89401 100644 --- a/frontend/testing/cypress/src/selectors/dashboard.js +++ b/frontend/testing/cypress/src/selectors/dashboard.js @@ -11,7 +11,7 @@ const getOrgAppsHeader = (org) => const getUserAppsList = () => getUserAppsListHeader().next(); const getSearchResults = () => getSearchResultsHeader().next(); const getLinksCellForApp = (table, name) => - table.findAllByRole('cell', { name }).siblings("div[data-field='links']"); + table.findByRole('cell', { name }).siblings("div[data-field='links']"); export const dashboard = { getAllAppsHeader,