Skip to content

Commit

Permalink
fix(object-node-flat-component): Schema property naming in builder mo…
Browse files Browse the repository at this point in the history
…de (#982)

Update change log to wrap code-specific terms
  • Loading branch information
krattet committed Apr 19, 2023
1 parent 839bfc9 commit 3342d8f
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 4 deletions.
89 changes: 89 additions & 0 deletions cypress/e2e/components/json-editor.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,4 +460,93 @@ describe('Json Editor', () => {
});
});
});

describe('Schema Builder Mode', () => {
beforeEach(() => {
cy.get('ngx-section').eq(3).as('schemaBuilderMode');
});
it('should have data', () => {
cy.get('@schemaBuilderMode').within(() => {
cy.get('header h1').should('have.text', 'Schema Builder Mode');
});
});

it('should allow adding a property', () => {
cy.get('@schemaBuilderMode').within(() => {
cy.get('ngx-json-editor-flat').as('jsonEditorFlat');
cy.get('@jsonEditorFlat').within(() => {
cy.get('.add-button')
.last()
.within(() => {
cy.get('ngx-dropdown').as('addPropDropdown').scrollIntoView().should('be.visible');
cy.get('@addPropDropdown').find('ngx-dropdown-toggle').should('contain.text', 'Add a property').click();
cy.get('@addPropDropdown').find('ngx-dropdown-menu').should('exist');
cy.contains('li', 'Object').click();
});
});
});
});

it('should allow modifying the property title', () => {
cy.get('ngx-property-config').as('propertyConfig');
cy.get('@propertyConfig').within(() => {
cy.get('div.header>span').should('have.text', 'Property Configuration');
cy.get('ngx-input').first().should('exist').ngxFill('obj_1');
cy.get('button').contains('Apply').click();
});
cy.get('@schemaBuilderMode').within(() => {
cy.get('ngx-json-editor-flat').as('jsonEditorFlat');
cy.get('@jsonEditorFlat').within(() => {
cy.get('.info-name>span').first().should('contain.text', 'obj_1');
});
});
});

it('should allow adding a nested property', () => {
cy.get('@schemaBuilderMode').within(() => {
cy.get('ngx-json-editor-flat').first().as('jsonEditorFlat');
cy.get('@jsonEditorFlat').within(() => {
cy.get('.add-button')
.first()
.within(() => {
cy.get('ngx-dropdown').as('addPropDropdown').scrollIntoView().should('be.visible');
cy.get('@addPropDropdown').find('ngx-dropdown-toggle').should('contain.text', 'Add a property').click();
cy.get('@addPropDropdown').find('ngx-dropdown-menu').should('exist');
cy.contains('li', 'String').click();
});
});
});
});

it('should allow modifying the nested property title', () => {
cy.get('ngx-property-config').as('propertyConfig');
cy.get('@propertyConfig').within(() => {
cy.get('div.header>span').should('have.text', 'Property Configuration');
cy.get('ngx-input').first().should('exist').ngxFill('str_1');
cy.get('button').contains('Apply').click();
});
cy.get('@schemaBuilderMode').within(() => {
cy.get('ngx-json-editor-flat').as('jsonEditorFlat');
cy.get('@jsonEditorFlat').within(() => {
cy.get('.info-name>span').last().should('contain.text', 'str_1');
});
});
});

it('should allow deleting nested a property', () => {
cy.get('@schemaBuilderMode').within(() => {
cy.get('.node-options')
.last()
.should('be.visible')
.within(() => {
cy.get('ngx-dropdown-toggle').should('be.visible').click();
cy.contains('li', 'Remove').click();
});
cy.get('ngx-json-editor-flat').as('jsonEditorFlat');
cy.get('@jsonEditorFlat').within(() => {
cy.get('.info-name>span').last().should('not.contain.text', 'str_1');
});
});
});
});
});
2 changes: 2 additions & 0 deletions projects/swimlane/ngx-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## HEAD (unreleased)

- Fix (`ngx-json-object-node-flat`): Remove pre-check for schema property when updating a property name. `schemaBuilderMode` determines which schema to update, `schemaRef` or `schema`

## 44.5.1 (2023-4-11)

- Fix (`ngx-button-toggle-group`): change should be detected upon new incoming value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@ export class ObjectNodeFlatComponent extends ObjectNode implements OnInit, OnCha
const newName = newProperty.propertyName;

if (newName !== oldName) {
if (oldName in this.schema.properties) {
this.updateSchemaPropertyName(this.schema, newName, oldName);
}

const schema = this.schemaBuilderMode ? this.schemaRef : this.schema;
this.updateSchemaPropertyName(schema, newName, oldName);
this.updatePropertyName(options.newProperty.id, newName);
Expand Down

0 comments on commit 3342d8f

Please sign in to comment.