Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress test for textbox max length #11245

Merged
merged 2 commits into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import {
AliasHelper,
ApprovedColorPickerDataTypeBuilder,
TextBoxDataTypeBuilder,
} from 'umbraco-cypress-testhelpers';

context('DataTypes', () => {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
context('User Groups', () => {
context('Member Groups', () => {

beforeEach(() => {
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
Expand Down