|
2 | 2 | import {
|
3 | 3 | AliasHelper,
|
4 | 4 | ApprovedColorPickerDataTypeBuilder,
|
| 5 | + TextBoxDataTypeBuilder, |
5 | 6 | } from 'umbraco-cypress-testhelpers';
|
6 | 7 |
|
7 | 8 | context('DataTypes', () => {
|
@@ -62,6 +63,48 @@ context('DataTypes', () => {
|
62 | 63 | cy.umbracoEnsureTemplateNameNotExists(name);
|
63 | 64 | });
|
64 | 65 |
|
| 66 | + it('Tests Textbox Maxlength', () => { |
| 67 | + cy.deleteAllContent(); |
| 68 | + const name = 'Textbox Maxlength Test'; |
| 69 | + const alias = AliasHelper.toAlias(name); |
| 70 | + |
| 71 | + cy.umbracoEnsureDocumentTypeNameNotExists(name); |
| 72 | + cy.umbracoEnsureDataTypeNameNotExists(name); |
| 73 | + |
| 74 | + const textBoxDataType = new TextBoxDataTypeBuilder() |
| 75 | + .withName(name) |
| 76 | + .withMaxChars(10) |
| 77 | + .build() |
| 78 | + |
| 79 | + cy.umbracoCreateDocTypeWithContent(name, alias, textBoxDataType); |
| 80 | + |
| 81 | + // Act |
| 82 | + // Enter content |
| 83 | + // Assert no helptext with (max-2) chars & can save |
| 84 | + cy.umbracoRefreshContentTree(); |
| 85 | + cy.umbracoTreeItem("content", [name]).click(); |
| 86 | + cy.get('input[name="textbox"]').type('12345678'); |
| 87 | + cy.get('localize[key="textbox_characters_left"]').should('not.exist'); |
| 88 | + cy.umbracoButtonByLabelKey('buttons_saveAndPublish').click(); |
| 89 | + cy.umbracoSuccessNotification().should('be.visible'); |
| 90 | + cy.get('.property-error').should('not.be.visible'); |
| 91 | + |
| 92 | + // Add char and assert helptext appears - no publish to save time & has been asserted above & below |
| 93 | + cy.get('input[name="textbox"]').type('9'); |
| 94 | + cy.get('localize[key="textbox_characters_left"]').contains('characters left').should('exist'); |
| 95 | + cy.get('.property-error').should('not.be.visible'); |
| 96 | + |
| 97 | + // Add char and assert errortext appears and can't save |
| 98 | + cy.get('input[name="textbox"]').type('10'); // 1 char over max |
| 99 | + cy.get('localize[key="textbox_characters_exceed"]').contains('too many').should('exist'); |
| 100 | + cy.umbracoButtonByLabelKey('buttons_saveAndPublish').click(); |
| 101 | + cy.get('.property-error').should('be.visible'); |
| 102 | + |
| 103 | + // Clean |
| 104 | + cy.umbracoEnsureDataTypeNameNotExists(name); |
| 105 | + cy.umbracoEnsureDocumentTypeNameNotExists(name); |
| 106 | + }) |
| 107 | + |
65 | 108 | // it('Tests Checkbox List', () => {
|
66 | 109 | // const name = 'CheckBox List';
|
67 | 110 | // const alias = AliasHelper.toAlias(name);
|
|
0 commit comments