Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
fabrizzio-dotCMS committed Dec 17, 2024
1 parent 298188f commit 3087559
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,29 +125,17 @@ public static Contentlet find(final String inodeOrIdentifierIn, final User user,

// time-machine
if (tmDate != null) {
// timemachine future dates
// This should take care of the rendering bits for the time machine
final Date ffdate = new Date(Long.parseLong(tmDate));
//final Identifier ident = APILocator.getIdentifierAPI().find(inodeOrIdentifier);
//if (ident == null || !UtilMethods.isSet(ident.getId())) {
// return null;
//}

// timemachine content has expired. return nothing
//if (UtilMethods.isSet(ident.getSysExpireDate()) && ffdate.after(ident.getSysExpireDate())) {
// return null;
//}

// timemachine content to be published in the future, return the working version
//if (UtilMethods.isSet(ident.getSysPublishDate()) && ffdate.after(ident.getSysPublishDate())) {
//return conAPI.findContentletByIdentifierOrFallback(inodeOrIdentifier, false, sessionLang, user, true).orElse(null);
final PageMode pageMode = PageMode.get();
final Optional<Contentlet> futureContent = conAPI.findContentletByIdentifierOrFallback(
inodeOrIdentifier, sessionLang, VariantAPI.DEFAULT_VARIANT.name(),
ffdate, user, pageMode.respectAnonPerms);
if (futureContent.isPresent()) {
return futureContent.get();
}
//}
// If the content is not found or has expired
// No need to return null we continue to the next step to try to find the content in the live or working version
}

final ContentletVersionInfo contentletVersionInfoByFallback = WebAPILocator.getVariantWebAPI()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Feature: Test Time Machine functionality

Background:

* def CONTENTLET_ONE_V1 = 'test 1'
* def CONTENTLET_ONE_V2 = 'test 1 v2 (This ver will be publshed in the future)'
* def CONTENTLET_TWO_V2 = 'test 2 v2'

* callonce read('classpath:graphql/ftm/setup.feature')

@smoke @positive
Expand All @@ -10,15 +15,11 @@ Feature: Test Time Machine functionality
When method GET
Then status 200
* def pageContents = extractContentlets (response)

* def contentPieceOne = getContentletByUUID(contentPieceOne, contentPieceOneId)
* def contentPieceTwo = getContentletByUUID(contentPieceTwo, contentPieceTwoId)

* def titles = pageContents.map(x => x.title)
# This is the first version of the content, test 1 v2 as the title says it will be published in the future
* match titles contains 'test 1'
* match titles contains CONTENTLET_ONE_V1
# This is the second version of the content, Thisone is already published therefore it should be displayed
* match titles contains 'test 2 v2'
* match titles contains CONTENTLET_TWO_V2

@positive
Scenario: Test Time Machine functionality when a publish date is provided expect the future content to be displayed
Expand All @@ -27,13 +28,11 @@ Feature: Test Time Machine functionality
And headers commonHeaders
When method GET
Then status 200
* def rendered = response.entity.page.rendered
* match rendered contains CONTENTLET_ONE_V2
* def pageContents = extractContentlets (response)

* def contentPieceOne = getContentletByUUID(contentPieceOne, contentPieceOneId)
* def contentPieceTwo = getContentletByUUID(contentPieceTwo, contentPieceTwoId)

* def titles = pageContents.map(x => x.title)
* match titles contains 'test 1 v2 (This ver will be publshed in the future)'
* match titles contains CONTENTLET_TWO_V2

@smoke @positive
Scenario: Send GraphQL query to fetch page details no publish date is sent
Expand All @@ -46,8 +45,8 @@ Feature: Test Time Machine functionality
Then status 200
* def contentlets = contentletsFromGraphQlResponse(response)
* karate.log('contentlets:', contentlets)
* match contentlets contains 'test 1'
* match contentlets contains 'test 2 v2'
* match contentlets contains CONTENTLET_ONE_V1
* match contentlets contains CONTENTLET_TWO_V2

@smoke @positive
Scenario: Send GraphQL query to fetch page details, publish date is sent expect the future content to be displayed
Expand All @@ -60,4 +59,4 @@ Feature: Test Time Machine functionality
Then status 200
* def contentlets = contentletsFromGraphQlResponse(response)
* karate.log('contentlets:', contentlets)
* match contentlets contains 'test 1 v2 (This ver will be publshed in the future)'
* match contentlets contains CONTENTLET_ONE_V2

0 comments on commit 3087559

Please sign in to comment.