From c36a6b83f6e2e11d38ff5153514315b2fda112e5 Mon Sep 17 00:00:00 2001 From: Jesper Date: Sat, 2 Oct 2021 09:01:20 +0200 Subject: [PATCH 1/2] add test for textbox max length --- .../integration/DataTypes/dataTypes.ts | 43 +++++++++++++++++++ .../integration/Members/memberGroups.js | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/DataTypes/dataTypes.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/DataTypes/dataTypes.ts index 9e1e6cc185dd..d5cccc913943 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/DataTypes/dataTypes.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/DataTypes/dataTypes.ts @@ -2,6 +2,7 @@ import { AliasHelper, ApprovedColorPickerDataTypeBuilder, + TextBoxDataTypeBuilder, } from 'umbraco-cypress-testhelpers'; context('DataTypes', () => { @@ -61,6 +62,48 @@ context('DataTypes', () => { cy.umbracoEnsureTemplateNameNotExists(name); }); + it('Tests Textbox Maxlength', () => { + cy.deleteAllContent(); + const name = 'Textbox Maxlength Test'; + const alias = AliasHelper.toAlias(name); + + cy.umbracoEnsureDocumentTypeNameNotExists(name); + cy.umbracoEnsureDataTypeNameNotExists(name); + + const textBoxDataType = new TextBoxDataTypeBuilder() + .withName(name) + .withMaxChars(10) + .build() + + cy.umbracoCreateDocTypeWithContent(name, alias, textBoxDataType); + + // Act + // Enter content + // Assert no helptext with (max-2) chars & can save + cy.umbracoRefreshContentTree(); + cy.umbracoTreeItem("content", [name]).click(); + cy.get('input[name="textbox"]').type('12345678'); + cy.get('localize[key="textbox_characters_left"]').should('not.exist'); + cy.umbracoButtonByLabelKey('buttons_saveAndPublish').click(); + cy.umbracoSuccessNotification().should('be.visible'); + cy.get('.property-error').should('not.be.visible'); + + // Add char and assert helptext appears - no publish to save time & has been asserted above & below + cy.get('input[name="textbox"]').type('9'); + cy.get('localize[key="textbox_characters_left"]').contains('characters left').should('exist'); + cy.get('.property-error').should('not.be.visible'); + + // Add char and assert errortext appears and can't save + cy.get('input[name="textbox"]').type('10'); // 1 char over max + cy.get('localize[key="textbox_characters_exceed"]').contains('too many').should('exist'); + cy.umbracoButtonByLabelKey('buttons_saveAndPublish').click(); + cy.get('.property-error').should('be.visible'); + + // //Clean + cy.umbracoEnsureDataTypeNameNotExists(name); + cy.umbracoEnsureDocumentTypeNameNotExists(name); + }) + // it('Tests Checkbox List', () => { // const name = 'CheckBox List'; // const alias = AliasHelper.toAlias(name); diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Members/memberGroups.js b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Members/memberGroups.js index be9b93134d01..6add16b4ee68 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Members/memberGroups.js +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Members/memberGroups.js @@ -1,4 +1,4 @@ -context('User Groups', () => { +context('Member Groups', () => { beforeEach(() => { cy.umbracoLogin(Cypress.env('username'), Cypress.env('password')); From 713ac9bca4922e7e9084b5173efd8167f56dff22 Mon Sep 17 00:00:00 2001 From: Jesper Date: Sat, 2 Oct 2021 09:08:17 +0200 Subject: [PATCH 2/2] remove leftover comment --- .../cypress/integration/DataTypes/dataTypes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/DataTypes/dataTypes.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/DataTypes/dataTypes.ts index d5cccc913943..942d42a9bf77 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/DataTypes/dataTypes.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/DataTypes/dataTypes.ts @@ -99,7 +99,7 @@ context('DataTypes', () => { cy.umbracoButtonByLabelKey('buttons_saveAndPublish').click(); cy.get('.property-error').should('be.visible'); - // //Clean + // Clean cy.umbracoEnsureDataTypeNameNotExists(name); cy.umbracoEnsureDocumentTypeNameNotExists(name); })