/**
  * Verify QuickFix works when we load a component that exists but contains an inner component that
  * does not.
  */
 public void testCreateInnerCmp() throws Exception {
   String namespace = "auratest";
   String cmpName = "innerCmpThatDoesntExist";
   String parentFullName;
   String parentCmpName;
   BaseComponentQuickFixWidget quickFixUIWidget;
   DefDescriptor<?> defDescriptorChild;
   // We're actually creating a .cmp file here so use that helper class
   quickFixUIWidget = new BaseComponentQuickFixWidget(DefType.COMPONENT, this);
   parentFullName =
       String.format("/%s/createInnerCmpQuickFix%s%s", namespace, capType, typeSuffix);
   parentCmpName = String.format("createInnerCmpQuickFix%s", capType);
   defDescriptorChild =
       Aura.getDefinitionService().getDefDescriptor(namespace + ":" + cmpName, ComponentDef.class);
   try {
     open(parentFullName, Mode.DEV);
     quickFixUIWidget.verifyToolbarAndClickCreate(defDescriptorChild.getQualifiedName());
     quickFixUIWidget.verifyCustomizationMenu();
     quickFixUIWidget.clickFix(
         true, String.format("TODO: %s:%s\nIn component " + parentCmpName, namespace, cmpName));
     assertTrue(
         "Failed to locate the definition: " + defDescriptorChild, defDescriptorChild.exists());
   } finally {
     quickFixUIWidget.deleteFiles(defDescriptorChild);
   }
 }
 /**
  * Verify error message that is displayed when attempting to create a cmp bundle with a
  * non-existing namespace.
  */
 public void testCreationQuickFixNonexistentNamespace() throws Exception {
   String namespace = String.format("nonExistentNamespace%s", System.currentTimeMillis());
   String cmpName = String.format("nonExistent%s%s", defType.name(), System.currentTimeMillis());
   DefDescriptor<?> defDescriptor = createComponentDefDescriptor(namespace, cmpName);
   BaseComponentQuickFixWidget quickFixUIWidget;
   quickFixUIWidget = new BaseComponentQuickFixWidget(defType, this);
   try {
     open(String.format("/%s/%s%s", namespace, cmpName, typeSuffix), Mode.DEV);
     quickFixUIWidget.verifyToolbarAndClickCreate(defDescriptor.getQualifiedName());
     quickFixUIWidget.verifyCustomizationMenu();
     quickFixUIWidget.clickFix(false, "Cannot find location to save definition");
     assertFalse("Should not have created component bundle", defDescriptor.exists());
   } finally {
     quickFixUIWidget.deleteFiles(defDescriptor);
   }
 }
 /** Verify error message when creating inner component with a bad namespace. */
 public void testCreateInnerCmpBadNamespace() throws Exception {
   String namespace = "auratest";
   String cmpName = "innerCmpThatDoesntExist";
   String parentFullName;
   BaseComponentQuickFixWidget quickFixUIWidget;
   DefDescriptor<?> defDescriptorChild;
   // We're actually creating a .cmp file here so use that helper class
   quickFixUIWidget = new BaseComponentQuickFixWidget(DefType.COMPONENT, this);
   parentFullName =
       String.format("/%s/createInnerCmpQuickFix%s%s", namespace, capType, typeSuffix);
   defDescriptorChild =
       Aura.getDefinitionService().getDefDescriptor(namespace + ":" + cmpName, ComponentDef.class);
   try {
     open(parentFullName, Mode.DEV);
     quickFixUIWidget.verifyToolbarAndClickCreate(defDescriptorChild.getQualifiedName());
     quickFixUIWidget.verifyCustomizationMenu();
     quickFixUIWidget.setDescriptorNames("auratestasdf:innerCmpThatDoesntExist");
     quickFixUIWidget.clickFix(false, "Cannot find location to save definition.");
     assertFalse(
         "Should not have created the component bundle with bad namespace",
         defDescriptorChild.exists());
   } finally {
     quickFixUIWidget.deleteFiles(defDescriptorChild);
   }
 }
 /** Verify .cmp/.app and .css files are created through QuickFix screen. */
 public void testCreationQuickFix() throws Exception {
   String namespace = "auratest";
   String cmpName = String.format("nonExistent%s%s", defType.name(), System.currentTimeMillis());
   DefDescriptor<?> defDescriptor = createComponentDefDescriptor(namespace, cmpName);
   DefDescriptor<?> defDescriptorCss =
       Aura.getDefinitionService().getDefDescriptor(namespace + "." + cmpName, StyleDef.class);
   BaseComponentQuickFixWidget quickFixUIWidget;
   quickFixUIWidget = new BaseComponentQuickFixWidget(defType, this);
   try {
     open(String.format("/%s/%s%s", namespace, cmpName, typeSuffix), Mode.DEV);
     quickFixUIWidget.verifyToolbarAndClickCreate(defDescriptor.getQualifiedName());
     quickFixUIWidget.verifyCustomizationMenu();
     quickFixUIWidget.selectCssCheckbox(true);
     quickFixUIWidget.clickFix(true, String.format("TODO: %s:%s", namespace, cmpName));
     //
     // Serverside verification
     // This needs to be very careful, as static registries can stay constant.
     //
     getAuraTestingUtil().restartContext();
     assertTrue("Failed to locate the definition", defDescriptor.exists());
     assertTrue("Failed to locate the css definition", defDescriptorCss.exists());
   } finally {
     quickFixUIWidget.deleteFiles(defDescriptor);
   }
 }
 /**
  * Verify that multiple component bundles can be created by entering the DefDescriptors in, comma
  * separated.
  */
 public void testMultipleDescriptors() throws Exception {
   String namespace = String.format("auratest", System.currentTimeMillis());
   String cmpName1 = String.format("nonExistent1%s%s", defType.name(), System.currentTimeMillis());
   String cmpName2 = String.format("nonExistent2%s%s", defType.name(), System.currentTimeMillis());
   DefDescriptor<?> defDescriptor1 = createComponentDefDescriptor(namespace, cmpName1);
   DefDescriptor<?> defDescriptor2 = createComponentDefDescriptor(namespace, cmpName2);
   BaseComponentQuickFixWidget quickFixUIWidget;
   quickFixUIWidget = new BaseComponentQuickFixWidget(defType, this);
   try {
     open(String.format("/%s/%s%s", namespace, cmpName1, typeSuffix), Mode.DEV);
     quickFixUIWidget.verifyToolbarAndClickCreate(defDescriptor1.getQualifiedName());
     quickFixUIWidget.verifyCustomizationMenu();
     quickFixUIWidget.setDescriptorNames(
         namespace + ":" + cmpName1 + ", " + namespace + ":" + cmpName2);
     quickFixUIWidget.clickFix(true, String.format("TODO: %s:%s", namespace, cmpName1));
     assertTrue("Should not have created component bundle", defDescriptor1.exists());
     assertTrue("Should not have created component bundle", defDescriptor2.exists());
   } finally {
     quickFixUIWidget.deleteFiles(defDescriptor1);
     quickFixUIWidget.deleteFiles(defDescriptor2);
   }
 }