diff --git a/core/src/test/java/google/registry/testing/AppEngineRule.java b/core/src/test/java/google/registry/testing/AppEngineRule.java index 7684856fa..2a005cf99 100644 --- a/core/src/test/java/google/registry/testing/AppEngineRule.java +++ b/core/src/test/java/google/registry/testing/AppEngineRule.java @@ -193,6 +193,7 @@ public final class AppEngineRule extends ExternalResource { .setPassword("foo-BAR2") .setPhoneNumber("+1.3334445555") .setPhonePasscode("12345") + .setRegistryLockAllowed(false) .build(); } @@ -206,6 +207,7 @@ public final class AppEngineRule extends ExternalResource { .setPassword("password2") .setPhoneNumber("+1.2223334444") .setPhonePasscode("22222") + .setRegistryLockAllowed(true) .build(); } @@ -241,6 +243,19 @@ public final class AppEngineRule extends ExternalResource { .build(); } + public static RegistrarContact makeRegistrarContact3() { + return new RegistrarContact.Builder() + .setParent(makeRegistrar2()) + .setName("Marla Singer") + .setEmailAddress("Marla.Singer@crr.com") + .setPhoneNumber("+1.2128675309") + .setTypes(ImmutableSet.of(RegistrarContact.Type.TECH)) + .setGaeUserId(THE_REGISTRAR_GAE_USER_ID) + .setAllowedToSetRegistryLockPassword(true) + .setRegistryLockPassword("hi") + .build(); + } + /** Hack to make sure AppEngineRule is always wrapped in a TemporaryFolder rule. */ @Override public Statement apply(Statement base, Description description) { @@ -412,6 +427,10 @@ public final class AppEngineRule extends ExternalResource { public static void loadInitialData() { persistSimpleResources( ImmutableList.of( - makeRegistrar1(), makeRegistrarContact1(), makeRegistrar2(), makeRegistrarContact2())); + makeRegistrar1(), + makeRegistrarContact1(), + makeRegistrar2(), + makeRegistrarContact2(), + makeRegistrarContact3())); } } diff --git a/core/src/test/java/google/registry/tools/ResaveEnvironmentEntitiesCommandTest.java b/core/src/test/java/google/registry/tools/ResaveEnvironmentEntitiesCommandTest.java index 7b754cd7e..85f6931d0 100644 --- a/core/src/test/java/google/registry/tools/ResaveEnvironmentEntitiesCommandTest.java +++ b/core/src/test/java/google/registry/tools/ResaveEnvironmentEntitiesCommandTest.java @@ -21,6 +21,7 @@ import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.loadRegistrar; +import com.google.common.collect.ImmutableSortedSet; import google.registry.model.ImmutableObject; import google.registry.model.ofy.CommitLogManifest; import google.registry.model.ofy.CommitLogMutation; @@ -62,13 +63,16 @@ public class ResaveEnvironmentEntitiesCommandTest transform( ofy().load().type(CommitLogMutation.class).list(), mutation -> ofy().load().fromEntity(mutation.getEntity())); + ImmutableSortedSet theRegistrarContacts = + loadRegistrar("TheRegistrar").getContacts(); assertThat(savedEntities) .containsExactly( // The Registrars and RegistrarContacts are created by AppEngineRule. loadRegistrar("TheRegistrar"), loadRegistrar("NewRegistrar"), Registry.get("tld"), - getOnlyElement(loadRegistrar("TheRegistrar").getContacts()), + theRegistrarContacts.first(), + theRegistrarContacts.last(), getOnlyElement(loadRegistrar("NewRegistrar").getContacts())); } diff --git a/core/src/test/java/google/registry/webdriver/RegistrarConsoleWebTest.java b/core/src/test/java/google/registry/webdriver/RegistrarConsoleWebTest.java index 5615b00a4..942ad1cca 100644 --- a/core/src/test/java/google/registry/webdriver/RegistrarConsoleWebTest.java +++ b/core/src/test/java/google/registry/webdriver/RegistrarConsoleWebTest.java @@ -35,6 +35,7 @@ import org.junit.Test; import org.junit.rules.Timeout; import org.junit.runner.RunWith; import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; /** WebDriver tests for Registrar Console UI. */ @RunWith(RepeatableRunner.class) @@ -78,6 +79,12 @@ public class RegistrarConsoleWebTest extends WebDriverTestCase { assertThat(driver.waitForElement(By.id(eltId)).isDisplayed()).isFalse(); } + /** Checks that searching with the given By produces at least one element with the given text. */ + void assertEltTextPresent(By by, String toFind) { + assertThat(driver.findElements(by).stream().map(WebElement::getText).anyMatch(toFind::equals)) + .isTrue(); + } + @Test public void testEditButtonsVisibility_owner() throws Throwable { driver.get(server.getUrl("/registrar#whois-settings")); @@ -190,9 +197,11 @@ public class RegistrarConsoleWebTest extends WebDriverTestCase { ImmutableList contacts = server.runInAppEngineEnvironment( () -> loadRegistrar("TheRegistrar").getContacts().asList()); - assertEltText("contacts[0].name", contacts.get(0).getName()); - assertEltText("contacts[0].emailAddress", contacts.get(0).getEmailAddress()); - assertEltText("contacts[0].phoneNumber", contacts.get(0).getPhoneNumber()); + for (RegistrarContact contact : contacts) { + assertEltTextPresent(By.id("contacts[0].name"), contact.getName()); + assertEltTextPresent(By.id("contacts[0].emailAddress"), contact.getEmailAddress()); + assertEltTextPresent(By.id("contacts[0].phoneNumber"), contact.getPhoneNumber()); + } } @Test diff --git a/core/src/test/resources/google/registry/ui/server/registrar/update_registrar_email.txt b/core/src/test/resources/google/registry/ui/server/registrar/update_registrar_email.txt index e1b2cf009..46d6546ef 100644 --- a/core/src/test/resources/google/registry/ui/server/registrar/update_registrar_email.txt +++ b/core/src/test/resources/google/registry/ui/server/registrar/update_registrar_email.txt @@ -13,6 +13,7 @@ contacts: ADDED: {parent=Key(EntityGroupRoot("cross-tld")/Registrar("TheRegistrar")), name=Extra Terrestrial, emailAddress=etphonehome@example.com, phoneNumber=+1.2345678901, faxNumber=null, types=[ADMIN, BILLING, TECH, WHOIS], gaeUserId=null, visibleInWhoisAsAdmin=true, visibleInWhoisAsTech=false, visibleInDomainWhoisAsAbuse=false, allowedToSetRegistryLockPassword=false} REMOVED: + {parent=Key(EntityGroupRoot("cross-tld")/Registrar("TheRegistrar")), name=Marla Singer, emailAddress=Marla.Singer@crr.com, phoneNumber=+1.2128675309, faxNumber=null, types=[TECH], gaeUserId=31337, visibleInWhoisAsAdmin=false, visibleInWhoisAsTech=false, visibleInDomainWhoisAsAbuse=false, allowedToSetRegistryLockPassword=false}, {parent=Key(EntityGroupRoot("cross-tld")/Registrar("TheRegistrar")), name=John Doe, emailAddress=johndoe@theregistrar.com, phoneNumber=+1.1234567890, faxNumber=null, types=[ADMIN], gaeUserId=31337, visibleInWhoisAsAdmin=false, visibleInWhoisAsTech=false, visibleInDomainWhoisAsAbuse=false, allowedToSetRegistryLockPassword=false}, {parent=Key(EntityGroupRoot("cross-tld")/Registrar("TheRegistrar")), name=Jian-Yang, emailAddress=jyang@bachman.accelerator, phoneNumber=+1.1234567890, faxNumber=null, types=[TECH], gaeUserId=null, visibleInWhoisAsAdmin=false, visibleInWhoisAsTech=false, visibleInDomainWhoisAsAbuse=false, allowedToSetRegistryLockPassword=false} FINAL CONTENTS: diff --git a/core/src/test/resources/google/registry/webdriver/goldens/chrome-linux/RegistrarConsoleScreenshotTest_settingsContactEdit_page.png b/core/src/test/resources/google/registry/webdriver/goldens/chrome-linux/RegistrarConsoleScreenshotTest_settingsContactEdit_page.png index fc6ea173c..479686a7b 100644 Binary files a/core/src/test/resources/google/registry/webdriver/goldens/chrome-linux/RegistrarConsoleScreenshotTest_settingsContactEdit_page.png and b/core/src/test/resources/google/registry/webdriver/goldens/chrome-linux/RegistrarConsoleScreenshotTest_settingsContactEdit_page.png differ diff --git a/core/src/test/resources/google/registry/webdriver/goldens/chrome-linux/RegistrarConsoleScreenshotTest_settingsContact_page.png b/core/src/test/resources/google/registry/webdriver/goldens/chrome-linux/RegistrarConsoleScreenshotTest_settingsContact_page.png index 711ff9f4b..9f61d115f 100644 Binary files a/core/src/test/resources/google/registry/webdriver/goldens/chrome-linux/RegistrarConsoleScreenshotTest_settingsContact_page.png and b/core/src/test/resources/google/registry/webdriver/goldens/chrome-linux/RegistrarConsoleScreenshotTest_settingsContact_page.png differ