Skip to content

Commit

Permalink
11559 deploy regression test w46 (#11596)
Browse files Browse the repository at this point in the history
* Added new tests to Cypress tests, including adding objects to the data model and generating the data model.
  • Loading branch information
JamalAlabdullah authored Nov 21, 2023
1 parent 7beaacb commit bf55c5a
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 5 deletions.
65 changes: 64 additions & 1 deletion frontend/testing/cypress/src/integration/studio/datamodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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', () => {
Expand Down
12 changes: 8 additions & 4 deletions frontend/testing/cypress/src/selectors/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit bf55c5a

Please sign in to comment.