diff options
author | Stefan Seelmann <mail@stefan-seelmann.de> | 2022-05-17 09:26:30 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-17 09:26:30 +0300 |
commit | 3c6114e5bd4520ce4bed2fc956fe73de2fc20aff (patch) | |
tree | 9a3ab97f9007c6b162068e08f4c38bc4eb746247 | |
parent | 5251dfb5f83d42f89e0dcbdb65ed14ed5c6ee115 (diff) |
DIRSTUDIO-1298: Add address editor UI test (#34)
5 files changed, 138 insertions, 0 deletions
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java index 220dc2073..7c2b53ca7 100644 --- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java +++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java @@ -54,6 +54,7 @@ import org.apache.directory.studio.test.integration.junit5.LdapServersSource; import org.apache.directory.studio.test.integration.junit5.TestLdapServer; import org.apache.directory.studio.test.integration.junit5.LdapServersSource.Mode; import org.apache.directory.studio.test.integration.ui.bots.AciItemEditorDialogBot; +import org.apache.directory.studio.test.integration.ui.bots.AddressEditorDialogBot; import org.apache.directory.studio.test.integration.ui.bots.CertificateEditorDialogBot; import org.apache.directory.studio.test.integration.ui.bots.DnEditorDialogBot; import org.apache.directory.studio.test.integration.ui.bots.EditAttributeWizardBot; @@ -568,6 +569,76 @@ public class EntryEditorTest extends AbstractTestBase /** + * DIRSTUDIO-1298: The RFC 4517 Postal Address value editor en-/decoding is incomplete + */ + @ParameterizedTest + @LdapServersSource + public void testAddressValueEditor( TestLdapServer server ) throws Exception + { + connectionsViewBot.createTestConnection( server ); + browserViewBot.selectEntry( path( BJENSEN_DN ) ); + + EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( BJENSEN_DN.getName() ); + entryEditorBot.activate(); + String dn = entryEditorBot.getDnText(); + assertEquals( "DN: " + BJENSEN_DN.getName(), dn ); + assertEquals( 8, entryEditorBot.getAttributeValues().size() ); + assertEquals( "", modificationLogsViewBot.getModificationLogsText() ); + + // add postalAddress attribute and verify value is correctly encoded + entryEditorBot.activate(); + NewAttributeWizardBot wizardBot = entryEditorBot.openNewAttributeWizard(); + assertTrue( wizardBot.isVisible() ); + wizardBot.typeAttributeType( "postalAddress" ); + AddressEditorDialogBot addressEditorDialogBot = wizardBot.clickFinishButtonExpectingAddressEditor(); + assertTrue( addressEditorDialogBot.isVisible() ); + addressEditorDialogBot.setText( "1234 Main St.\nAnytown, CA 12345\nUSA" ); + addressEditorDialogBot.clickOkButton(); + assertEquals( 9, entryEditorBot.getAttributeValues().size() ); + assertTrue( + entryEditorBot.getAttributeValues().contains( "postalAddress: 1234 Main St., Anytown, CA 12345, USA" ) ); + modificationLogsViewBot.waitForText( "add: postalAddress\npostalAddress: 1234 Main St.$Anytown, CA 12345$USA" ); + + // verify value is correctly decoded + addressEditorDialogBot = entryEditorBot.editValueExpectingAddressEditor( "postalAddress", + "1234 Main St., Anytown, CA 12345, USA" ); + assertTrue( addressEditorDialogBot.isVisible() ); + assertEquals( "1234 Main St.\nAnytown, CA 12345\nUSA", addressEditorDialogBot.getText() ); + addressEditorDialogBot.clickCancelButton(); + + // edit value with a complex address and verify value is correctly encoded + addressEditorDialogBot = entryEditorBot.editValueExpectingAddressEditor( "postalAddress", + "1234 Main St., Anytown, CA 12345, USA" ); + assertTrue( addressEditorDialogBot.isVisible() ); + assertEquals( "1234 Main St.\nAnytown, CA 12345\nUSA", addressEditorDialogBot.getText() ); + // TODO: $1,000,000 Sweepstakes + addressEditorDialogBot.setText( "1,000,000 Sweepstakes\nPO Box 1000000\nAnytown, CA 12345\nUSA" ); + addressEditorDialogBot.clickOkButton(); + assertEquals( 9, entryEditorBot.getAttributeValues().size() ); + assertFalse( entryEditorBot.getAttributeValues() + .contains( "postalAddress: 1234 Main St., Anytown, CA 12345, USA" ) ); + assertTrue( entryEditorBot.getAttributeValues() + // TODO: $1,000,000 Sweepstakes + .contains( "postalAddress: 1,000,000 Sweepstakes, PO Box 1000000, Anytown, CA 12345, USA" ) ); + modificationLogsViewBot + .waitForText( "delete: postalAddress\npostalAddress: 1234 Main St.$Anytown, CA 12345$USA" ); + modificationLogsViewBot.waitForText( + // TODO: $1,000,000 Sweepstakes + "add: postalAddress\npostalAddress: 1,000,000 Sweepstakes$PO Box 1000000$Anytown, CA 12345$USA" ); + + // verify value is correctly decoded + // TODO: $1,000,000 Sweepstakes + addressEditorDialogBot = entryEditorBot.editValueExpectingAddressEditor( "postalAddress", + "1,000,000 Sweepstakes, PO Box 1000000, Anytown, CA 12345, USA" ); + assertTrue( addressEditorDialogBot.isVisible() ); + // TODO: $1,000,000 Sweepstakes + assertEquals( "1,000,000 Sweepstakes\nPO Box 1000000\nAnytown, CA 12345\nUSA", + addressEditorDialogBot.getText() ); + addressEditorDialogBot.clickCancelButton(); + } + + + /** * DIRSTUDIO-1199, DIRSTUDIO-1204, DIRSTUDIO-1267: Binary attributes. * Test adding, editing and deleting of attributes with binary option in the entry editor. */ diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/AddressEditorDialogBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/AddressEditorDialogBot.java new file mode 100644 index 000000000..83a7719da --- /dev/null +++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/AddressEditorDialogBot.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.studio.test.integration.ui.bots; + + +import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages; + + +public class AddressEditorDialogBot extends DialogBot +{ + + public AddressEditorDialogBot() + { + super( "Address Editor" ); + super.setWaitAfterClickOkButton( true, BrowserCoreMessages.jobs__execute_ldif_name ); + } + + + public String getText() + { + return bot.text( 0 ).getText(); + } + + + public void setText( String text ) + { + bot.text( 0 ).setText( text ); + } + +} diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java index 0012f6868..fa61a4062 100644 --- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java +++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java @@ -144,6 +144,12 @@ public class EntryEditorBot } + public AddressEditorDialogBot editValueExpectingAddressEditor( String attributeType, String value ) + { + return editorBot.editValueExpectingAddressEditor( attributeType, value ); + } + + public TextEditorDialogBot editValueWithTextEditor( String attributeType, String value ) { return editorBot.editValueWithTextEditor( attributeType, value ); diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java index 15bfdecdb..a39ec122d 100644 --- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java +++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java @@ -196,6 +196,13 @@ class EntryEditorWidgetBot } + AddressEditorDialogBot editValueExpectingAddressEditor( String attributeType, String value ) + { + editValue( attributeType, value ); + return new AddressEditorDialogBot(); + } + + TextEditorDialogBot editValueWithTextEditor( String attributeType, String value ) { editValueWith( attributeType, value, "^Text Editor$" ); diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java index 62877bd30..7532df0aa 100644 --- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java +++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java @@ -82,4 +82,11 @@ public class NewAttributeWizardBot extends WizardBot return new HexEditorDialogBot(); } + + public AddressEditorDialogBot clickFinishButtonExpectingAddressEditor() + { + clickFinishButton(); + return new AddressEditorDialogBot(); + } + } |