-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 25732 we are breaking the page when editing variant layout and …
…pushing changes (#26202) * Fixing bug when decide if create a Anonymous Template * Fixing error on DotPageRenderService * #25732 Sending the Variant Template when Push an Experiment * #25732 Testing * #25732 Doc * Fixing testing * Fixing testing * removing change * #25697 Not reset the Scheduling on the forceStart method (#26243) * Fixing test --------- Co-authored-by: Daniel Silva <[email protected]>
- Loading branch information
1 parent
43d58b1
commit 86dc2de
Showing
13 changed files
with
409 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
dotCMS/src/integration-test/java/com/dotcms/test/util/assertion/ExperimentChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package com.dotcms.test.util.assertion; | ||
|
||
import static com.dotcms.util.CollectionsUtils.list; | ||
import static com.dotcms.util.CollectionsUtils.map; | ||
import static com.dotcms.variant.VariantAPI.DEFAULT_VARIANT; | ||
import static com.dotmarketing.beans.Host.HOST_NAME_KEY; | ||
|
||
import com.dotcms.experiments.model.Experiment; | ||
import com.dotcms.experiments.model.ExperimentVariant; | ||
import com.dotcms.variant.VariantAPI; | ||
import com.dotmarketing.beans.Host; | ||
import com.dotmarketing.business.APILocator; | ||
import com.dotmarketing.exception.DotDataException; | ||
import com.dotmarketing.exception.DotSecurityException; | ||
import com.dotmarketing.portlets.containers.model.Container; | ||
import com.dotmarketing.portlets.contentlet.model.Contentlet; | ||
import com.dotmarketing.portlets.htmlpageasset.model.HTMLPageAsset; | ||
import com.dotmarketing.util.UtilMethods; | ||
import java.io.File; | ||
import java.util.Collection; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* {@link AssertionChecker} concrete class for {@link Experiment} | ||
*/ | ||
public class ExperimentChecker implements AssertionChecker<Experiment>{ | ||
|
||
@Override | ||
public Map<String, Object> getFileArguments(final Experiment experiment, final File file) { | ||
try { | ||
final Contentlet pageAsContent = APILocator.getContentletAPI() | ||
.findContentletByIdentifierAnyLanguage(experiment.pageId(), DEFAULT_VARIANT.name(), true); | ||
|
||
final HTMLPageAsset htmlPageAsset = APILocator.getHTMLPageAssetAPI() | ||
.fromContentlet(pageAsContent); | ||
|
||
final ExperimentVariant experimentNoDefaultVariant = experiment.trafficProportion().variants() | ||
.stream() | ||
.filter(experimentVariant -> !DEFAULT_VARIANT.name().equals(experimentVariant.id())) | ||
.findFirst() | ||
.orElseThrow(); | ||
return map( | ||
"name", experiment.name(), | ||
"description", experiment.description().orElseThrow(), | ||
"id", experiment.id().orElseThrow(), | ||
"page_url", htmlPageAsset.getURI(), | ||
"no_default_variant_id", experimentNoDefaultVariant.id(), | ||
"no_default_variant_name", experimentNoDefaultVariant.description(), | ||
"page_id", htmlPageAsset.getIdentifier() | ||
|
||
); | ||
} catch (DotDataException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public String getFilePathExpected(File file) { | ||
return "/bundlers-test/experiment/experiment.json"; | ||
} | ||
|
||
@Override | ||
public File getFileInner(final Experiment experiment, File bundleRoot) { | ||
try { | ||
final Contentlet pageAsContentlet = APILocator.getContentletAPI() | ||
.findContentletByIdentifierAnyLanguage(experiment.pageId()); | ||
|
||
final Host host = APILocator.getHostAPI().find(pageAsContentlet.getHost(), APILocator.systemUser(), false); | ||
|
||
final String path = bundleRoot.getPath() + File.separator + "live" + File.separator + | ||
host.getHostname() + File.separator + experiment.id().orElseThrow() + ".experiment.json"; | ||
|
||
return new File(path); | ||
} catch (DotDataException | DotSecurityException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public Collection<String> getRegExToRemove(final File file) { | ||
return list( | ||
"\"creationDate\":.*,\"modDate\":.*" | ||
); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
dotCMS/src/integration-test/java/com/dotcms/test/util/assertion/VariantChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.dotcms.test.util.assertion; | ||
|
||
import static com.dotcms.util.CollectionsUtils.map; | ||
|
||
import com.dotcms.experiments.model.Experiment; | ||
import com.dotcms.variant.model.Variant; | ||
import java.io.File; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* {@link AssertionChecker} concrete class for {@link Variant} | ||
*/ | ||
public class VariantChecker implements AssertionChecker<Variant> { | ||
|
||
@Override | ||
public Map<String, Object> getFileArguments(final Variant variant, final File file) { | ||
return map( | ||
"name", variant.name(), | ||
"description", variant.description().get() | ||
); | ||
|
||
} | ||
|
||
@Override | ||
public String getFilePathExpected(final File file) { | ||
return "/bundlers-test/variant/variant.json"; | ||
} | ||
|
||
public File getFileInner(Variant asset, File bundleRoot) { | ||
final String path = bundleRoot.getPath() + File.separator + "live" + File.separator + | ||
"System Host" + File.separator + asset.name() + ".variant.json"; | ||
|
||
return new File(path); | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
dotCMS/src/integration-test/resources/bundlers-test/experiment/experiment.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"experiment":{"name":"__name__","description":"__description__","id":"__id__","status":"DRAFT","trafficProportion":{"type":"SPLIT_EVENLY","variants":[{"id":"DEFAULT","name":"Original","weight":50.0,"url":"__page_url__?variantName=DEFAULT","promoted":false},{"id":"__no_default_variant_id__","name":"__no_default_variant_name__","weight":50.0,"url":"__page_url__?variantName=__no_default_variant_id__","promoted":false}]},"scheduling":null,"trafficAllocation":100.0,"creationDate":1695142069104,"modDate":1695142069813,"pageId":"__page_id__","createdBy":"system","lastModifiedBy":"system","goals":{"primary":{"conditions":[{"operator":"EQUALS","parameter":"url","value":"test-page-url-1695142066545"},{"operator":"REGEX","parameter":"visitBefore","value":"^(http|https):\\/\\/(localhost|127.0.0.1|\\b(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]{2,})(:\\d{1,5})?\\/test-page-url-1695142066545(\\/?\\?.*)?$"}],"name":"Testing Metric","type":"REACH_PAGE"}},"targetingConditions":null,"lookBackWindowExpireTime":1800000,"runningIds":{"ids":[]}},"operation":"PUBLISH"} |
1 change: 1 addition & 0 deletions
1
dotCMS/src/integration-test/resources/bundlers-test/variant/variant.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"variant":{"name":"__name__","description":"__description__","archived":false},"operation":"PUBLISH"} |
Oops, something went wrong.