From e3e3fb57eb0e46d542a52fa31a0a5a0854c5cb09 Mon Sep 17 00:00:00 2001 From: fabrizzio-dotCMS Date: Fri, 6 Dec 2024 16:45:04 -0600 Subject: [PATCH 01/11] #30780 --- .../business/ESContentletAPIImpl.java | 4 +++ .../PageAPIGraphQLFieldsProvider.java | 4 +++ .../page/ContainersDataFetcher.java | 3 -- .../datafetcher/page/PageDataFetcher.java | 29 +++++++++++++++++++ .../velocity/services/PageRenderUtil.java | 12 ++++---- .../render/HTMLPageAssetRenderedAPIImpl.java | 20 ++++++------- 6 files changed, 53 insertions(+), 19 deletions(-) diff --git a/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ESContentletAPIImpl.java b/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ESContentletAPIImpl.java index 09f233bc0120..13964e867f5c 100644 --- a/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ESContentletAPIImpl.java +++ b/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ESContentletAPIImpl.java @@ -686,6 +686,10 @@ public Contentlet findContentletByIdentifier(final String identifier, final long final Date timeMachineDate, final User user, final boolean respectFrontendRoles) throws DotDataException, DotSecurityException, DotContentletStateException{ final Contentlet contentlet = contentFactory.findContentletByIdentifier(identifier, languageId, variantId, timeMachineDate); + if (contentlet == null) { + Logger.debug(this, "Contentlet not found for identifier: " + identifier + " lang:" + languageId + " variant:" + variantId + " date:" + timeMachineDate); + return null; + } if (permissionAPI.doesUserHavePermission(contentlet, PermissionAPI.PERMISSION_READ, user, respectFrontendRoles)) { return contentlet; } else { diff --git a/dotCMS/src/main/java/com/dotcms/graphql/business/PageAPIGraphQLFieldsProvider.java b/dotCMS/src/main/java/com/dotcms/graphql/business/PageAPIGraphQLFieldsProvider.java index 8d17d5ff43a5..36fa9bff8e3b 100644 --- a/dotCMS/src/main/java/com/dotcms/graphql/business/PageAPIGraphQLFieldsProvider.java +++ b/dotCMS/src/main/java/com/dotcms/graphql/business/PageAPIGraphQLFieldsProvider.java @@ -50,6 +50,10 @@ public Collection getFields() throws DotDataException { .name("site") .type(GraphQLString) .build()) + .argument(GraphQLArgument.newArgument() //This is time machine + .name("publishDate") + .type(GraphQLString) + .build()) .type(PageAPIGraphQLTypesProvider.INSTANCE.getTypesMap().get(DOT_PAGE)) .dataFetcher(new PageDataFetcher()).build()); } diff --git a/dotCMS/src/main/java/com/dotcms/graphql/datafetcher/page/ContainersDataFetcher.java b/dotCMS/src/main/java/com/dotcms/graphql/datafetcher/page/ContainersDataFetcher.java index 1ea5b74a62a7..84e6d17e4818 100644 --- a/dotCMS/src/main/java/com/dotcms/graphql/datafetcher/page/ContainersDataFetcher.java +++ b/dotCMS/src/main/java/com/dotcms/graphql/datafetcher/page/ContainersDataFetcher.java @@ -14,7 +14,6 @@ import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; import java.util.List; -import javax.servlet.http.HttpServletRequest; /** * This DataFetcher returns the {@link TemplateLayout} associated to the requested {@link HTMLPageAsset}. @@ -31,8 +30,6 @@ public List get(final DataFetchingEnvironment environment) throws final String languageId = (String) context.getParam("languageId"); final PageMode mode = PageMode.get(pageModeAsString); - final HttpServletRequest request = context.getHttpServletRequest(); - final HTMLPageAsset pageAsset = APILocator.getHTMLPageAssetAPI() .fromContentlet(page); diff --git a/dotCMS/src/main/java/com/dotcms/graphql/datafetcher/page/PageDataFetcher.java b/dotCMS/src/main/java/com/dotcms/graphql/datafetcher/page/PageDataFetcher.java index 719e99bc1c44..6539b07e4ab0 100644 --- a/dotCMS/src/main/java/com/dotcms/graphql/datafetcher/page/PageDataFetcher.java +++ b/dotCMS/src/main/java/com/dotcms/graphql/datafetcher/page/PageDataFetcher.java @@ -2,6 +2,8 @@ import com.dotcms.graphql.DotGraphQLContext; import com.dotcms.graphql.exception.PermissionDeniedGraphQLException; +import com.dotcms.rest.api.v1.page.PageResource; +import com.dotcms.variant.VariantAPI; import com.dotmarketing.beans.Host; import com.dotmarketing.business.APILocator; import com.dotmarketing.exception.DotSecurityException; @@ -15,6 +17,7 @@ import com.dotmarketing.portlets.htmlpageasset.model.HTMLPageAsset; import com.dotmarketing.portlets.rules.business.RulesEngine; import com.dotmarketing.portlets.rules.model.Rule.FireOn; +import com.dotmarketing.util.DateUtil; import com.dotmarketing.util.Logger; import com.dotmarketing.util.PageMode; import com.dotmarketing.util.UtilMethods; @@ -22,6 +25,9 @@ import com.liferay.portal.model.User; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; +import io.vavr.control.Try; +import java.time.Instant; +import java.util.Date; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -53,6 +59,8 @@ public Contentlet get(final DataFetchingEnvironment environment) throws Exceptio final boolean fireRules = environment.getArgument("fireRules"); final String persona = environment.getArgument("persona"); final String site = environment.getArgument("site"); + final String variant = environment.getArgument("variant"); + final String publishDate = environment.getArgument("publishDate"); context.addParam("url", url); context.addParam("languageId", languageId); @@ -60,6 +68,7 @@ public Contentlet get(final DataFetchingEnvironment environment) throws Exceptio context.addParam("fireRules", fireRules); context.addParam("persona", persona); context.addParam("site", site); + context.addParam("publishDate", publishDate); final PageMode mode = PageMode.get(pageModeAsString); PageMode.setPageMode(request, mode); @@ -73,10 +82,30 @@ public Contentlet get(final DataFetchingEnvironment environment) throws Exceptio request.setAttribute(WebKeys.CMS_PERSONA_PARAMETER, persona); } + if (UtilMethods.isSet(variant)) { + request.setAttribute(VariantAPI.VARIANT_KEY, variant); + } + if(UtilMethods.isSet(site)) { request.setAttribute(Host.HOST_VELOCITY_VAR_NAME, site); } + Date publishDateObj = null; + + if(UtilMethods.isSet(publishDate)) { + publishDateObj = Try.of(()-> DateUtil.convertDate(publishDate)).getOrElse(() -> { + Logger.error(this, "Invalid publish date: " + publishDate); + return null; + }); + if(null != publishDateObj) { + //We get a valid time machine date + final Instant instant = publishDateObj.toInstant(); + final long epochMilli = instant.toEpochMilli(); + context.addParam(PageResource.TM_DATE, epochMilli); + request.setAttribute(PageResource.TM_DATE, epochMilli); + } + } + Logger.debug(this, ()-> "Fetching page for URL: " + url); final PageContext pageContext = PageContextBuilder.builder() diff --git a/dotCMS/src/main/java/com/dotcms/rendering/velocity/services/PageRenderUtil.java b/dotCMS/src/main/java/com/dotcms/rendering/velocity/services/PageRenderUtil.java index 14c2eb885f77..d1daac3664c2 100644 --- a/dotCMS/src/main/java/com/dotcms/rendering/velocity/services/PageRenderUtil.java +++ b/dotCMS/src/main/java/com/dotcms/rendering/velocity/services/PageRenderUtil.java @@ -356,27 +356,27 @@ private Optional timeMachineDate(final HttpServletRequest request) { return Optional.empty(); } - Optional millis = Optional.empty(); + Optional millis = Optional.empty(); final HttpSession session = request.getSession(false); if (session != null) { - millis = Optional.ofNullable ((String)session.getAttribute(PageResource.TM_DATE)); + millis = Optional.ofNullable (session.getAttribute(PageResource.TM_DATE)); } if (millis.isEmpty()) { - millis = Optional.ofNullable((String)request.getAttribute(PageResource.TM_DATE)); + millis = Optional.ofNullable(request.getAttribute(PageResource.TM_DATE)); } if (millis.isEmpty()) { return Optional.empty(); } - + final Object object = millis.get(); try { - final long milliseconds = Long.parseLong(millis.get()); + final long milliseconds = object instanceof Number ? (Long) object : Long.parseLong(object.toString()); return milliseconds > 0 ? Optional.of(Date.from(Instant.ofEpochMilli(milliseconds))) : Optional.empty(); } catch (NumberFormatException e) { - Logger.error(this, "Invalid timestamp format: " + millis.get(), e); + Logger.error(this, "Invalid timestamp format: " + object, e); return Optional.empty(); } diff --git a/dotCMS/src/main/java/com/dotmarketing/portlets/htmlpageasset/business/render/HTMLPageAssetRenderedAPIImpl.java b/dotCMS/src/main/java/com/dotmarketing/portlets/htmlpageasset/business/render/HTMLPageAssetRenderedAPIImpl.java index 5301f3ab334c..c5e606d445ef 100644 --- a/dotCMS/src/main/java/com/dotmarketing/portlets/htmlpageasset/business/render/HTMLPageAssetRenderedAPIImpl.java +++ b/dotCMS/src/main/java/com/dotmarketing/portlets/htmlpageasset/business/render/HTMLPageAssetRenderedAPIImpl.java @@ -367,7 +367,7 @@ private HTMLPageUrl getHtmlPageAsset(final PageContext context, final Host host, throws DotDataException, DotSecurityException { Logger.debug(this, "--HTMLPageAssetRenderedAPIImpl_getHtmlPageAsset--"); - Optional htmlPageUrlOptional = findPageByContext(host, context); + Optional htmlPageUrlOptional = findPageByContext(host, context, request); if (htmlPageUrlOptional.isEmpty()) { Logger.debug(this, "HTMLPageAssetRenderedAPIImpl_getHtmlPageAsset htmlPageUrlOptional is Empty trying to find by URL Map"); @@ -428,17 +428,18 @@ private void checkPagePermission(final PageContext context, final IHTMLPage html * @throws DotSecurityException The User accessing the APIs does not have the required permissions to perform * this action. */ - private Optional findPageByContext(final Host host, final PageContext context) + private Optional findPageByContext(final Host host, final PageContext context, final HttpServletRequest request) throws DotDataException, DotSecurityException { final User user = context.getUser(); - final String uri = context.getPageUri(); final PageMode mode = context.getPageMode(); - final String pageUri = (UUIDUtil.isUUID(uri) ||( uri.length()>0 && '/' == uri.charAt(0))) ? uri : ("/" + uri); - Logger.debug(this, "HTMLPageAssetRenderedAPIImpl_findPageByContext user: " + user + " uri: " + uri + " mode: " + mode + " host: " + host + " pageUri: " + pageUri); - final HTMLPageAsset htmlPageAsset = (HTMLPageAsset) (UUIDUtil.isUUID(pageUri) ? - this.htmlPageAssetAPI.findPage(pageUri, user, mode.respectAnonPerms) : - getPageByUri(mode, host, pageUri)); + String uri = context.getPageUri(); + uri = uri == null ? StringPool.BLANK : uri; + final String pageUriOrInode = (UUIDUtil.isUUID(uri) ||(!uri.isEmpty() && '/' == uri.charAt(0))) ? uri : ("/" + uri); + Logger.debug(this, "HTMLPageAssetRenderedAPIImpl_findPageByContext user: " + user + " uri: " + uri + " mode: " + mode + " host: " + host + " pageUriOrInode: " + pageUriOrInode); + final HTMLPageAsset htmlPageAsset = (HTMLPageAsset) (UUIDUtil.isUUID(pageUriOrInode) ? + this.htmlPageAssetAPI.findPage(pageUriOrInode, user, mode.respectAnonPerms) : + getPageByUri(mode, host, pageUriOrInode, request)); Logger.debug(this, "HTMLPageAssetRenderedAPIImpl_findPageByContext htmlPageAsset: " + (htmlPageAsset == null ? "Not Found" : htmlPageAsset.toString())); return Optional.ofNullable(htmlPageAsset == null ? null : new HTMLPageUrl(htmlPageAsset)); @@ -494,10 +495,9 @@ private Optional findByURLMap( } } - private IHTMLPage getPageByUri(final PageMode mode, final Host host, final String pageUri) + private IHTMLPage getPageByUri(final PageMode mode, final Host host, final String pageUri, final HttpServletRequest request) throws DotDataException, DotSecurityException { - final HttpServletRequest request = HttpServletRequestThreadLocal.INSTANCE.getRequest(); final Language defaultLanguage = this.languageAPI.getDefaultLanguage(); final Language language = this.getCurrentLanguage(request); Logger.debug(this, "HTMLPageAssetRenderedAPIImpl_getPageByUri pageUri: " + pageUri + " host: " + host + " language: " + language + " mode: " + mode); From 3ac8f0230a3e4cc8545db5bbc320e33b2045b30a Mon Sep 17 00:00:00 2001 From: fabrizzio-dotCMS Date: Mon, 9 Dec 2024 10:34:42 -0600 Subject: [PATCH 02/11] #30780 --- test-karate/src/test/java/karate-config.js | 21 +++- .../graphql/ftm/CheckingTimeMachine.feature | 13 ++ .../ftm/CheckingTimeMachineRunner.java | 12 ++ .../graphql/ftm/setup/newContainer.feature | 28 +++++ .../graphql/ftm/setup/newContent.feature | 26 ++++ .../graphql/ftm/setup/newContentType.feature | 117 ++++++++++++++++++ .../graphql/ftm/setup/newTemplate.feature | 65 ++++++++++ .../graphql/ftm/setup/publishTemplate.feature | 16 +++ 8 files changed, 293 insertions(+), 5 deletions(-) create mode 100644 test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature create mode 100644 test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachineRunner.java create mode 100644 test-karate/src/test/java/tests/graphql/ftm/setup/newContainer.feature create mode 100644 test-karate/src/test/java/tests/graphql/ftm/setup/newContent.feature create mode 100644 test-karate/src/test/java/tests/graphql/ftm/setup/newContentType.feature create mode 100644 test-karate/src/test/java/tests/graphql/ftm/setup/newTemplate.feature create mode 100644 test-karate/src/test/java/tests/graphql/ftm/setup/publishTemplate.feature diff --git a/test-karate/src/test/java/karate-config.js b/test-karate/src/test/java/karate-config.js index d28f0028725c..d33a045d38f0 100644 --- a/test-karate/src/test/java/karate-config.js +++ b/test-karate/src/test/java/karate-config.js @@ -1,19 +1,30 @@ function fn() { - var env = karate.env; // get system property 'karate.env' + let env = karate.env; // get system property 'karate.env' karate.log('karate.env system property was:', env); if (!env) { env = 'dev'; } - var config = { + let baseUrl = karate.properties['karate.base.url'] || 'http://localhost:8080'; + let authString = 'admin@dotcms.com:admin'; + let encodedAuth = function(s) { + return java.util.Base64.getEncoder().encodeToString(s.getBytes('UTF-8')); + }; + let authHeader = 'Basic ' + encodedAuth(authString); + let config = { env: env, - baseUrl: karate.properties['karate.base.url'] || 'http://localhost:8080' + baseUrl: baseUrl, + commonHeaders : { + 'Content-Type': 'application/json', + 'Authorization': authHeader + } } - if (env == 'dev') { + if (env === 'dev') { // customize // e.g. config.foo = 'bar'; - } else if (env == 'e2e') { + } else if (env === 'e2e') { // customize } karate.log('Base URL set to:', config.baseUrl); + return config; } \ No newline at end of file diff --git a/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature b/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature new file mode 100644 index 000000000000..239b5525256e --- /dev/null +++ b/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature @@ -0,0 +1,13 @@ +Feature: Test Time Machine functionality + + Background: + # Setup required data + * def contentTypeResult = callonce read('classpath:tests/graphql/ftm/setup/newContentType.feature') + * def contentTypeId = contentTypeResult.response.entity[0].id + * def containerResult = callonce read('classpath:tests/graphql/ftm/setup/newContainer.feature') { contentTypeId: '#(contentTypeId' } + * def containerId = containerResult.response.entity.identifier + * def templateResult = callonce read('classpath:tests/graphql/ftm/setup/newTemplate.feature') { containerId: '#(containerId)' } + * def templateId = templateResult.response.entity.identifier + * callonce read('classpath:tests/graphql/ftm/setup/publishTemplate.feature') { templateId: '#(templateId)' } + * def contentResult = callonce read('classpath:tests/graphql/ftm/setup/newContent.feature') { contentTypeId: '#(contentTypeId)', containerId: '' } + Scenario: \ No newline at end of file diff --git a/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachineRunner.java b/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachineRunner.java new file mode 100644 index 000000000000..d5a7c06824c2 --- /dev/null +++ b/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachineRunner.java @@ -0,0 +1,12 @@ +package tests.graphql.ftm; + +import com.intuit.karate.junit5.Karate; + +public class CheckingTimeMachineRunner { + + @Karate.Test + Karate testCheckingTimeMachine() { + return Karate.run("CheckingTimeMachine").relativeTo(getClass()); + } + +} diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newContainer.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newContainer.feature new file mode 100644 index 000000000000..52cce6aad5d4 --- /dev/null +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newContainer.feature @@ -0,0 +1,28 @@ +Feature: Create a Content Type + Background: + * def containerNameVariable = 'MyContainer' + Math.floor(Math.random() * 1000) + + Scenario Outline: Create a content type and expect 200 OK + Given url baseUrl + '/api/v1/containers' + And headers commonHeaders + And request + """ + { + "title":"#(containerNameVariable)", + "friendlyName":"My test container.", + "maxContentlets":10, + "notes":"Notes", + "containerStructures":[ + { + "structureId":"#(contentTypeId)", + "code":"$!{dotContentMap.title}" + } + ] + } + """ + When method POST + Then status 200 + + Examples: + | name | description | + | newC | THE DESCRIPTION 1 | diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newContent.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newContent.feature new file mode 100644 index 000000000000..1dd550e5d1ba --- /dev/null +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newContent.feature @@ -0,0 +1,26 @@ +Feature: Create an instance of a new Content Type and expect 200 OK + + Scenario Outline: Create an instance of a new Content Type and expect 200 OK + Given url baseUrl + '/api/v1/workflow/actions/default/fire/PUBLISH?indexPolicy=WAIT_FOR' + And headers commonHeaders + And request + """ + { + "contentlets": [ + { + "contentType": "#(contentTypeVariable)", + "title": "#(title)", + "publishDate": "#(publishDate)", + "expiresOn": "#(expiresOn)", + "contentHost": "default" + } + ] + } + """ + When method POST + Then status 200 + + Examples: + | name | description | + | newC | THE DESCRIPTION 1 | + diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newContentType.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newContentType.feature new file mode 100644 index 000000000000..4609e5ed8ed1 --- /dev/null +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newContentType.feature @@ -0,0 +1,117 @@ +Feature: Create a Content Type + Background: + * def contentTypeVariable = 'MyContentType' + Math.floor(Math.random() * 1000) + + Scenario Outline: Create a content type and expect 200 OK + Given url baseUrl + '/api/v1/contenttype' + And headers commonHeaders + And request + """ + { + "baseType":"CONTENT", + "clazz":"com.dotcms.contenttype.model.type.ImmutableSimpleContentType", + "defaultType":false, + "expireDateVar":"expiresOn", + "fields":[ + { + "clazz":"com.dotcms.contenttype.model.field.ImmutableTextField", + "dataType":"TEXT", + "fieldType":"Text", + "fieldTypeLabel":"Text", + "fieldVariables":[ + + ], + "fixed":false, + "forceIncludeInApi":false, + "indexed":true, + "listed":false, + "name":"title", + "readOnly":false, + "required":true, + "searchable":true, + "sortOrder":2, + "unique":false, + "variable":"title" + }, + { + "clazz":"com.dotcms.contenttype.model.field.ImmutableDateTimeField", + "dataType":"DATE", + "fieldType":"Date-and-Time", + "fieldTypeLabel":"Date and Time", + "fieldVariables":[ + + ], + "fixed":false, + "forceIncludeInApi":false, + "indexed":true, + "listed":false, + "name":"publishDate", + "readOnly":false, + "required":false, + "searchable":true, + "sortOrder":3, + "unique":false, + "variable":"publishDate" + }, + { + "clazz":"com.dotcms.contenttype.model.field.ImmutableDateTimeField", + "dataType":"DATE", + "fieldType":"Date-and-Time", + "fieldTypeLabel":"Date and Time", + "fieldVariables":[ + + ], + "fixed":false, + "forceIncludeInApi":false, + "indexed":true, + "listed":false, + "name":"expiresOn", + "readOnly":false, + "required":false, + "searchable":true, + "sortOrder":4, + "unique":false, + "variable":"expiresOn" + }, + { + "clazz":"com.dotcms.contenttype.model.field.ImmutableTagField", + "dataType":"SYSTEM", + "fieldType":"Tag", + "fieldTypeLabel":"Tag", + "fieldVariables":[ + + ], + "fixed":false, + "forceIncludeInApi":false, + "indexed":true, + "listed":false, + "name":"tags", + "readOnly":false, + "required":false, + "searchable":false, + "sortOrder":5, + "unique":false, + "variable":"tags" + } + ], + "fixed":false, + "folder":"SYSTEM_FOLDER", + "folderPath":"/", + "host":"48190c8c-42c4-46af-8d1a-0cd5db894797", + "icon":"adjust", + "multilingualable":false, + "name":"#(contentTypeVariable)", + "publishDateVar":"publishDate", + "sortOrder":0, + "system":false, + "variable":"#(contentTypeVariable)", + "versionable":true + } + """ + When method POST + Then status 200 + And match response.entity[0].id != null + And match response.entity[0].variable == contentTypeVariable + Examples: + | name | description | + | TestImportJob1 | THE DESCRIPTION 1 | \ No newline at end of file diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newTemplate.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newTemplate.feature new file mode 100644 index 000000000000..aaff5fe9259a --- /dev/null +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newTemplate.feature @@ -0,0 +1,65 @@ +Feature: Create a new Template for later use during Time Machine testing + Background: + * def templateName = 'MyTemplate' + Math.floor(Math.random() * 1000) + Scenario Outline: Create a new Template + Given url baseUrl + '/api/v1/templates' + And headers commonHeaders + And request + """ + { + "title":"#(templateName)", + "theme":"13f88067-1e25-4e30-bc64-7e8f42ad542f", + "friendlyName":"Test Template.", + "layout":{ + "body":{ + "rows":[ + { + "styleClass":"", + "columns":[ + { + "styleClass":"", + "leftOffset":1, + "width":100, + "containers":[ + { + "identifier":"#(containerId)", + } + ] + } + ] + },{ + "styleClass":"", + "columns":[ + { + "styleClass":"", + "leftOffset":1, + "width":100, + "containers":[ + { + "identifier":"#(containerId)", + } + ] + } + ] + } + ] + }, + "header":true, + "footer":true, + "sidebar":{ + "location":"", + "containers":[ + + ], + "width":"small" + } + } + } + """ + When method post + Then status 200 + + + Examples: + | name | description | + | newTemplate | THE DESCRIPTION 1 | \ No newline at end of file diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/publishTemplate.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/publishTemplate.feature new file mode 100644 index 000000000000..1c005d4d8f75 --- /dev/null +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/publishTemplate.feature @@ -0,0 +1,16 @@ +Feature: Publish a Template + Background: + + Scenario Outline: Create a new Template + Given url baseUrl + '/api/v1/templates/_publish' + And headers commonHeaders + And request + """ + ["#(templateId)"] + """ + When method PUT + Then status 200 + + Examples: + | name | description | + | publish template | THE DESCRIPTION 1 | From 7dc989bb326e4153d9e7b49637138d7e9b95dd37 Mon Sep 17 00:00:00 2001 From: fabrizzio-dotCMS Date: Tue, 10 Dec 2024 09:06:39 -0600 Subject: [PATCH 03/11] #30780 --- .../graphql/ftm/CheckingTimeMachine.feature | 13 +++- .../graphql/ftm/setup/newContent.feature | 64 ++++++++++++++----- .../graphql/ftm/setup/newContentType.feature | 10 ++- .../ftm/setup/newContentVersion.feature | 26 ++++++++ .../tests/graphql/ftm/setup/newPage.feature | 24 +++++++ 5 files changed, 117 insertions(+), 20 deletions(-) create mode 100644 test-karate/src/test/java/tests/graphql/ftm/setup/newContentVersion.feature create mode 100644 test-karate/src/test/java/tests/graphql/ftm/setup/newPage.feature diff --git a/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature b/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature index 239b5525256e..7f9d9bb1eb4b 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature @@ -4,10 +4,19 @@ Feature: Test Time Machine functionality # Setup required data * def contentTypeResult = callonce read('classpath:tests/graphql/ftm/setup/newContentType.feature') * def contentTypeId = contentTypeResult.response.entity[0].id - * def containerResult = callonce read('classpath:tests/graphql/ftm/setup/newContainer.feature') { contentTypeId: '#(contentTypeId' } + * def contentTypeVariable = contentTypeResult.response.entity[0].variable + * def containerResult = callonce read('classpath:tests/graphql/ftm/setup/newContainer.feature') { contentTypeId: '#(contentTypeId)' } * def containerId = containerResult.response.entity.identifier * def templateResult = callonce read('classpath:tests/graphql/ftm/setup/newTemplate.feature') { containerId: '#(containerId)' } * def templateId = templateResult.response.entity.identifier * callonce read('classpath:tests/graphql/ftm/setup/publishTemplate.feature') { templateId: '#(templateId)' } - * def contentResult = callonce read('classpath:tests/graphql/ftm/setup/newContent.feature') { contentTypeId: '#(contentTypeId)', containerId: '' } + * def createContentPieceOneResult = callonce read('classpath:tests/graphql/ftm/setup/newContent.feature') { contentTypeId: '#(contentTypeId)', title: 'test 1' } + * def contentPieceOneId = createContentPieceOneResult.response.entity.results[0].identifier + * def createContentPieceTwoResult = callonce read('classpath:tests/graphql/ftm/setup/newContent.feature') { contentTypeId: '#(contentTypeId)', title: 'test 2' } + * def contentPieceTwoId = createContentPieceTwoResult.response.entity.results[0].identifier + + * def newContentPiceOneVrsion2 = callonce read('classpath:tests/graphql/ftm/setup/newContentVersion.feature') { contentTypeId: '#(contentTypeId)', identifier: '#(contentPieceOneId)', title: 'test 1 v2' } + * def newContentPiceTwoVrsion2 = callonce read('classpath:tests/graphql/ftm/setup/newContentVersion.feature') { contentTypeId: '#(contentTypeId)', identifier: '#(contentPieceTwoId)', title: 'test 2 v2' } + + * def createPageResult = callonce read('classpath:tests/graphql/ftm/setup/newPage.feature') { title: 'test page' } Scenario: \ No newline at end of file diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newContent.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newContent.feature index 1dd550e5d1ba..d6162d3e4255 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/setup/newContent.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newContent.feature @@ -1,26 +1,60 @@ Feature: Create an instance of a new Content Type and expect 200 OK - - Scenario Outline: Create an instance of a new Content Type and expect 200 OK - Given url baseUrl + '/api/v1/workflow/actions/default/fire/PUBLISH?indexPolicy=WAIT_FOR' - And headers commonHeaders - And request - """ - { +Background: + * def extractErrors = + """ + function(response) { + var errors = []; + var results = response.entity.results; + if (results && results.length > 0) { + for (var i = 0; i < results.length; i++) { + var result = results[i]; + // Handle both nested error messages and direct error messages + for (var key in result) { + if (result[key] && result[key].errorMessage) { + errors.push(result[key].errorMessage); + } + } + } + } + return errors; + } + """ + * def buildRequestPayload = + """ + function(contentType, title, publishDate, expiresOn) { + var payload = { "contentlets": [ { - "contentType": "#(contentTypeVariable)", - "title": "#(title)", - "publishDate": "#(publishDate)", - "expiresOn": "#(expiresOn)", + "contentType": contentType, + "title": title, "contentHost": "default" } ] - } - """ + }; + if (publishDate) payload.contentlets[0].publishDate = publishDate; + if (expiresOn) payload.contentlets[0].expiresOn = expiresOn; + return payload; + } + """ + Scenario Outline: Create an instance of a new Content Type and expect 200 OK + Given url baseUrl + '/api/v1/workflow/actions/default/fire/PUBLISH?indexPolicy=WAIT_FOR' + And headers commonHeaders + + * karate.log('args:::', __arg) + # Params are expected as arguments to the feature file + * def contentTypeId = __arg.contentTypeId + * def title = __arg.title + * def publishDate = __arg.publishDate + * def expiresOn = __arg.expiresOn + + * def requestPayload = buildRequestPayload (contentTypeId, title, publishDate, expiresOn) + And request requestPayload + When method POST Then status 200 - + * def errors = call extractErrors response + * match errors == [] Examples: | name | description | - | newC | THE DESCRIPTION 1 | + | new | THE DESCRIPTION 1 | diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newContentType.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newContentType.feature index 4609e5ed8ed1..251ad22b6a94 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/setup/newContentType.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newContentType.feature @@ -11,7 +11,6 @@ Feature: Create a Content Type "baseType":"CONTENT", "clazz":"com.dotcms.contenttype.model.type.ImmutableSimpleContentType", "defaultType":false, - "expireDateVar":"expiresOn", "fields":[ { "clazz":"com.dotcms.contenttype.model.field.ImmutableTextField", @@ -97,15 +96,20 @@ Feature: Create a Content Type "fixed":false, "folder":"SYSTEM_FOLDER", "folderPath":"/", - "host":"48190c8c-42c4-46af-8d1a-0cd5db894797", + "host":"8a7d5e23-da1e-420a-b4f0-471e7da8ea2d", "icon":"adjust", "multilingualable":false, "name":"#(contentTypeVariable)", "publishDateVar":"publishDate", + "expireDateVar":"expiresOn", "sortOrder":0, "system":false, "variable":"#(contentTypeVariable)", - "versionable":true + "versionable":true, + "workflows" : [ { + "id" : "d61a59e1-a49c-46f2-a929-db2b4bfa88b2", + "variableName" : "SystemWorkflow" + } ] } """ When method POST diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newContentVersion.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newContentVersion.feature new file mode 100644 index 000000000000..c8fad3f014c1 --- /dev/null +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newContentVersion.feature @@ -0,0 +1,26 @@ +Feature: Create a new version of a piece of content + + Scenario Outline: Create a new version of a piece of content + Given url baseUrl + '/api/v1/workflow/actions/default/fire/PUBLISH?identifier='+identifier+'&indexPolicy=WAIT_FOR' + And headers commonHeaders + And request + """ + { + "contentlets": [ + { + "identifier":"#(identifier)", + "contentType": "#(contentType)", + "title": "#(title)", + "publishDate": "#(publishDate)", + "expiresOn": "#(expiresOn)", + "contentHost": "default" + } + ] + } + """ + When method POST + Then status 200 + + Examples: + | name | description | + | new | THE DESCRIPTION 1 | diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newPage.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newPage.feature new file mode 100644 index 000000000000..ae260991d193 --- /dev/null +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newPage.feature @@ -0,0 +1,24 @@ +Feature: Create a Page + + Scenario Outline: Create a new version of a piece of content + Given url baseUrl + '/api/v1/workflow/actions/default/fire/PUBLISH?indexPolicy=WAIT_FOR' + And headers commonHeaders + And request + """ + { + "contentlet" : { + "title" : "lol", + "url": "lol", + "languageId" : 1, + "stInode": "c541abb1-69b3-4bc5-8430-5e09e5239cc8", + "template": "SYSTEM_TEMPLATE", + "friendlyName": "friendlyName", + "contentHost": "default" + } + } + """ + When method POST + Then status 200 + Examples: + | name | description | + | new | THE DESCRIPTION 1 | From d94cc227dba7f76d83e9c5e407c1a8b2c6749a40 Mon Sep 17 00:00:00 2001 From: fabrizzio-dotCMS Date: Thu, 12 Dec 2024 10:06:04 -0600 Subject: [PATCH 04/11] #30780 --- .../graphql/ftm/CheckingTimeMachine.feature | 75 ++++++++++++++-- .../tests/graphql/ftm/setup/helpers.feature | 86 +++++++++++++++++++ .../graphql/ftm/setup/newContainer.feature | 6 +- .../graphql/ftm/setup/newContent.feature | 50 ++--------- .../graphql/ftm/setup/newContentType.feature | 6 +- .../ftm/setup/newContentVersion.feature | 29 +++---- .../tests/graphql/ftm/setup/newPage.feature | 22 +++-- .../graphql/ftm/setup/newTemplate.feature | 4 +- .../graphql/ftm/setup/publishPage.feature | 39 +++++++++ 9 files changed, 236 insertions(+), 81 deletions(-) create mode 100644 test-karate/src/test/java/tests/graphql/ftm/setup/helpers.feature create mode 100644 test-karate/src/test/java/tests/graphql/ftm/setup/publishPage.feature diff --git a/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature b/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature index 7f9d9bb1eb4b..a7142bdd74a1 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature @@ -1,22 +1,85 @@ Feature: Test Time Machine functionality Background: + * callonce read('classpath:tests/graphql/ftm/setup/helpers.feature') + + # Make the prefix available to the scenario # Setup required data + # Lets start by creating a new content type, container, template and publish the template + # First the Content Type * def contentTypeResult = callonce read('classpath:tests/graphql/ftm/setup/newContentType.feature') * def contentTypeId = contentTypeResult.response.entity[0].id * def contentTypeVariable = contentTypeResult.response.entity[0].variable + # Now the container, template and publish the template * def containerResult = callonce read('classpath:tests/graphql/ftm/setup/newContainer.feature') { contentTypeId: '#(contentTypeId)' } * def containerId = containerResult.response.entity.identifier * def templateResult = callonce read('classpath:tests/graphql/ftm/setup/newTemplate.feature') { containerId: '#(containerId)' } * def templateId = templateResult.response.entity.identifier * callonce read('classpath:tests/graphql/ftm/setup/publishTemplate.feature') { templateId: '#(templateId)' } + + # Create a couple of new pieces of content * def createContentPieceOneResult = callonce read('classpath:tests/graphql/ftm/setup/newContent.feature') { contentTypeId: '#(contentTypeId)', title: 'test 1' } - * def contentPieceOneId = createContentPieceOneResult.response.entity.results[0].identifier + * def contentPieceOne = createContentPieceOneResult.response.entity.results + * def contentPieceOneId = contentPieceOne.map(result => Object.keys(result)[0]) + * def contentPieceOneId = contentPieceOneId[0] + * def createContentPieceTwoResult = callonce read('classpath:tests/graphql/ftm/setup/newContent.feature') { contentTypeId: '#(contentTypeId)', title: 'test 2' } - * def contentPieceTwoId = createContentPieceTwoResult.response.entity.results[0].identifier + * def contentPieceTwo = createContentPieceTwoResult.response.entity.results + * def contentPieceTwoId = contentPieceTwo.map(result => Object.keys(result)[0]) + * def contentPieceTwoId = contentPieceTwoId[0] + + # Now lets create a new version for each piece of content + * def formatter = java.time.format.DateTimeFormatter.ofPattern('yyyy-MM-dd HH:mm:ss') + * def now = java.time.LocalDateTime.now() + * def futureDateTime = now.plusDays(10) + * def formattedFutureDateTime = futureDateTime.format(formatter) + + * def newContentPiceOneVersion2 = callonce read('classpath:tests/graphql/ftm/setup/newContentVersion.feature') { contentTypeId: '#(contentTypeId)', identifier: '#(contentPieceOneId)', title: 'test 1 v2 (This ver will be publshed in the future)', publishDate: '#(formattedFutureDateTime)' } + * def newContentPiceTwoVersion2 = callonce read('classpath:tests/graphql/ftm/setup/newContentVersion.feature') { contentTypeId: '#(contentTypeId)', identifier: '#(contentPieceTwoId)', title: 'test 2 v2' } + + * def pageUrl = 'ftm-test-page' + Math.floor(Math.random() * 10000) + # Finally lets create a new page + * def createPageResult = callonce read('classpath:tests/graphql/ftm/setup/newPage.feature') { pageUrl:'#(pageUrl)' ,title: 'Future Time Machine Test page', templateId:'#(templateId)' } + * karate.log('createPageResult:', createPageResult) + * def pages = createPageResult.response.entity.results + * def pageId = pages.map(result => Object.keys(result)[0]) + * def pageId = pageId[0] + + * def publishPageResult = callonce read('classpath:tests/graphql/ftm/setup/publishPage.feature') { page_id: '#(pageId)', content1_id: '#(contentPieceOneId)', content2_id: '#(contentPieceTwoId)', container_id: '#(containerId)' } + # + @smoke + Scenario Outline: Test Time Machine functionality when no publish date is provided + Given url baseUrl + '/api/v1/page/render/'+pageUrl+'?language_id=1&mode=LIVE' + And headers commonHeaders + When method GET + Then status 200 + * def pageContents = call extractContentlets response + * karate.log('pageContents:', pageContents) + + * def contentPieceOne = getContentletByUUID(contentPieceOne, contentPieceOneId) + * def contentPieceTwo = getContentletByUUID(contentPieceTwo, contentPieceTwoId) + + # This is the first version of the content, test 1 v2 as the title says it will be published in the future + * match pageContents[0].title == 'test 1' + # This is the second version of the content, Thisone is already published therefore it should be displayed + * match pageContents[1].title == 'test 2 v2' - * def newContentPiceOneVrsion2 = callonce read('classpath:tests/graphql/ftm/setup/newContentVersion.feature') { contentTypeId: '#(contentTypeId)', identifier: '#(contentPieceOneId)', title: 'test 1 v2' } - * def newContentPiceTwoVrsion2 = callonce read('classpath:tests/graphql/ftm/setup/newContentVersion.feature') { contentTypeId: '#(contentTypeId)', identifier: '#(contentPieceTwoId)', title: 'test 2 v2' } + Examples: + | scenario | expected result | + | We simply create a new Piece Content which we will use to work on. No publishDate is provided here | We should succeed creating the piece of content | - * def createPageResult = callonce read('classpath:tests/graphql/ftm/setup/newPage.feature') { title: 'test page' } - Scenario: \ No newline at end of file + Scenario Outline: Send GraphQL query to fetch page details + Given url baseUrl + '/api/v1/graphql' + And headers { "Content-Type": "application/json" } + And request + """ + { + "query": "query Page { page(url: \"#(pageUrl)\") { containers { containerContentlets { contentlets { title } } } } }" + } + """ + When method post + Then status 200 + * print response + Examples: + | scenario | expected result | + | We simply create a new Piece Content which we will use to work on. No publishDate is provided here | We should succeed creating the piece of content | diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/helpers.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/helpers.feature new file mode 100644 index 000000000000..ceea05aebad7 --- /dev/null +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/helpers.feature @@ -0,0 +1,86 @@ +Feature: Reusable Functions and Helpers + + Scenario: Define reusable functions + + ## Builds a payload for creating a new content version + * def buildContentRequestPayload = + """ + function(contentType, title, publishDate, expiresOn, identifier) { + var payload = { + "contentlets": [ + { + "contentType": contentType, + "title": title, + "host":"8a7d5e23-da1e-420a-b4f0-471e7da8ea2d" + } + ] + }; + if (publishDate) payload.contentlets[0].publishDate = publishDate; + if (expiresOn) payload.contentlets[0].expiresOn = expiresOn; + if (identifier) payload.contentlets[0].identifier = identifier; + return payload; + } + """ + ## Extracts all errors from a response + * def extractErrors = + """ + function(response) { + var errors = []; + var results = response.entity.results; + if (results && results.length > 0) { + for (var i = 0; i < results.length; i++) { + var result = results[i]; + // Handle both nested error messages and direct error messages + for (var key in result) { + if (result[key] && result[key].errorMessage) { + errors.push(result[key].errorMessage); + } + } + } + } + return errors; + } + """ + + ## Extracts all contentlets from a response + * def extractContentlets = + """ + function(response) { + var containers = response.entity.containers; + var allContentlets = []; + for (var key in containers) { + if (containers[key].contentlets) { + for (var contentletKey in containers[key].contentlets) { + allContentlets = allContentlets.concat(containers[key].contentlets[contentletKey]); + } + } + } + return allContentlets; + } + """ + + ## Generates a random suffix for test data + * def testSuffix = + """ + function() { + if (!karate.get('testSuffix')) { + var prefix = '__' + Math.floor(Math.random() * 100000); + karate.set('testSuffix', prefix); + } + return karate.get('testSuffix'); + } + """ + + ## Extracts a specific object from a JSON array by UUID + * def getContentletByUUID = + """ + function(jsonArray, uuid) { + for (var i = 0; i < jsonArray.length; i++) { + var keys = Object.keys(jsonArray[i]); + if (keys.includes(uuid)) { + return jsonArray[i][uuid]; + } + } + return null; // Return null if not found + } + """ \ No newline at end of file diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newContainer.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newContainer.feature index 52cce6aad5d4..93934a343dcb 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/setup/newContainer.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newContainer.feature @@ -1,6 +1,6 @@ Feature: Create a Content Type Background: - * def containerNameVariable = 'MyContainer' + Math.floor(Math.random() * 1000) + * def containerNameVariable = 'MyContainer' + Math.floor(Math.random() * 100000) Scenario Outline: Create a content type and expect 200 OK Given url baseUrl + '/api/v1/containers' @@ -24,5 +24,5 @@ Feature: Create a Content Type Then status 200 Examples: - | name | description | - | newC | THE DESCRIPTION 1 | + | scenario | expected result | + | We create a new Container using a random name | The container gets created just fine | diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newContent.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newContent.feature index d6162d3e4255..3509f22d8754 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/setup/newContent.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newContent.feature @@ -1,53 +1,18 @@ Feature: Create an instance of a new Content Type and expect 200 OK Background: - * def extractErrors = - """ - function(response) { - var errors = []; - var results = response.entity.results; - if (results && results.length > 0) { - for (var i = 0; i < results.length; i++) { - var result = results[i]; - // Handle both nested error messages and direct error messages - for (var key in result) { - if (result[key] && result[key].errorMessage) { - errors.push(result[key].errorMessage); - } - } - } - } - return errors; - } - """ - * def buildRequestPayload = - """ - function(contentType, title, publishDate, expiresOn) { - var payload = { - "contentlets": [ - { - "contentType": contentType, - "title": title, - "contentHost": "default" - } - ] - }; - if (publishDate) payload.contentlets[0].publishDate = publishDate; - if (expiresOn) payload.contentlets[0].expiresOn = expiresOn; - return payload; - } - """ + Scenario Outline: Create an instance of a new Content Type and expect 200 OK - Given url baseUrl + '/api/v1/workflow/actions/default/fire/PUBLISH?indexPolicy=WAIT_FOR' - And headers commonHeaders - * karate.log('args:::', __arg) # Params are expected as arguments to the feature file * def contentTypeId = __arg.contentTypeId * def title = __arg.title * def publishDate = __arg.publishDate * def expiresOn = __arg.expiresOn - * def requestPayload = buildRequestPayload (contentTypeId, title, publishDate, expiresOn) + Given url baseUrl + '/api/v1/workflow/actions/default/fire/PUBLISH?indexPolicy=WAIT_FOR' + And headers commonHeaders + + * def requestPayload = buildContentRequestPayload (contentTypeId, title, publishDate, expiresOn) And request requestPayload When method POST @@ -55,6 +20,5 @@ Background: * def errors = call extractErrors response * match errors == [] Examples: - | name | description | - | new | THE DESCRIPTION 1 | - + | scenario | expected result | + | We simply create a new Piece Content which we will use to work on. No publishDate is provided here | We should succeed creating the piece of content | \ No newline at end of file diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newContentType.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newContentType.feature index 251ad22b6a94..b272c7a435b5 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/setup/newContentType.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newContentType.feature @@ -1,6 +1,6 @@ Feature: Create a Content Type Background: - * def contentTypeVariable = 'MyContentType' + Math.floor(Math.random() * 1000) + * def contentTypeVariable = 'MyContentType' + Math.floor(Math.random() * 100000) Scenario Outline: Create a content type and expect 200 OK Given url baseUrl + '/api/v1/contenttype' @@ -117,5 +117,5 @@ Feature: Create a Content Type And match response.entity[0].id != null And match response.entity[0].variable == contentTypeVariable Examples: - | name | description | - | TestImportJob1 | THE DESCRIPTION 1 | \ No newline at end of file + | scenario | expected result | + | We create a new Container using a random name | The container gets created just fine | \ No newline at end of file diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newContentVersion.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newContentVersion.feature index c8fad3f014c1..c7870ed3dee5 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/setup/newContentVersion.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newContentVersion.feature @@ -1,26 +1,23 @@ Feature: Create a new version of a piece of content +Background: Scenario Outline: Create a new version of a piece of content + + # Params are expected as arguments to the feature file + * def identifier = __arg.identifier + * def contentTypeId = __arg.contentTypeId + * def title = __arg.title + * def publishDate = __arg.publishDate + * def expiresOn = __arg.expiresOn + Given url baseUrl + '/api/v1/workflow/actions/default/fire/PUBLISH?identifier='+identifier+'&indexPolicy=WAIT_FOR' And headers commonHeaders - And request - """ - { - "contentlets": [ - { - "identifier":"#(identifier)", - "contentType": "#(contentType)", - "title": "#(title)", - "publishDate": "#(publishDate)", - "expiresOn": "#(expiresOn)", - "contentHost": "default" - } - ] - } - """ + * def requestPayload = buildContentRequestPayload (contentTypeId, title, publishDate, expiresOn, identifier) + And request requestPayload When method POST Then status 200 - + * def errors = call extractErrors response + * match errors == [] Examples: | name | description | | new | THE DESCRIPTION 1 | diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newPage.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newPage.feature index ae260991d193..6b4f563963b5 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/setup/newPage.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newPage.feature @@ -1,24 +1,30 @@ Feature: Create a Page - + Background: Scenario Outline: Create a new version of a piece of content Given url baseUrl + '/api/v1/workflow/actions/default/fire/PUBLISH?indexPolicy=WAIT_FOR' And headers commonHeaders + * def pageUrl = (__arg.pageUrl ? __arg.pageUrl : 'ftm-test-page' + Math.floor(Math.random() * 10000)) + * def templateId = (__arg.templateId ? __arg.templateId : 'SYSTEM_TEMPLATE') And request """ { "contentlet" : { - "title" : "lol", - "url": "lol", + "title" : "#(title)", + "url": "#(pageUrl)", "languageId" : 1, "stInode": "c541abb1-69b3-4bc5-8430-5e09e5239cc8", - "template": "SYSTEM_TEMPLATE", - "friendlyName": "friendlyName", - "contentHost": "default" + "template": "#(templateId)", + "friendlyName": "#(title)", + "hostFolder": "8a7d5e23-da1e-420a-b4f0-471e7da8ea2d", + "cachettl": 0, + "sortOrder": 0 } } """ When method POST Then status 200 + * def errors = call extractErrors response + * match errors == [] Examples: - | name | description | - | new | THE DESCRIPTION 1 | + | scenario | expected result | + | We simply create a Page to hold the template/container and therefore the contents | We should succeed creating the page | diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newTemplate.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newTemplate.feature index aaff5fe9259a..febe9346472e 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/setup/newTemplate.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newTemplate.feature @@ -61,5 +61,5 @@ Feature: Create a new Template for later use during Time Machine testing Examples: - | name | description | - | newTemplate | THE DESCRIPTION 1 | \ No newline at end of file + | scenario | expected result | + | We create a Template to hold the containers/contents served by the page | We should succeed creating the template | \ No newline at end of file diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/publishPage.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/publishPage.feature new file mode 100644 index 000000000000..d22b73908684 --- /dev/null +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/publishPage.feature @@ -0,0 +1,39 @@ +Feature: Add pieces of content then Publish the Page + Background: + + * def validateNoErrors = + """ + function (response) { + const errors = response.errors; + if (errors) { + return errors; + } + return []; + } + """ + + * def page_id = __arg.page_id + * def content1_id = __arg.content1_id + * def content2_id = __arg.content2_id + * def container_id = __arg.container_id + + Scenario Outline: Create a new version of a piece of content + Given url baseUrl + '/api/v1/page/'+page_id+'/content' + And headers commonHeaders + And request + """ + [ + { + "contentletsId": ["#(content1_id)", "#(content2_id)"], + "identifier": "#(container_id)", + "uuid": "1" + } + ] + """ + When method POST + Then status 200 + * def errors = call validateNoErrors response + * match errors == [] + Examples: + | name | description | + | new | THE DESCRIPTION 1 | \ No newline at end of file From 50034130b427353e25c2e6887ec9088e10823c40 Mon Sep 17 00:00:00 2001 From: fabrizzio-dotCMS Date: Fri, 13 Dec 2024 10:22:22 -0600 Subject: [PATCH 05/11] #30780 --- test-karate/src/test/java/KarateCITests.java | 5 +- .../graphql/ftm/CheckingTimeMachine.feature | 110 +++++++----------- .../tests/graphql/ftm/setup/helpers.feature | 36 +++++- .../graphql/ftm/setup/newContainer.feature | 6 +- .../graphql/ftm/setup/newContent.feature | 7 +- .../graphql/ftm/setup/newContentType.feature | 7 +- .../ftm/setup/newContentVersion.feature | 7 +- .../tests/graphql/ftm/setup/newPage.feature | 12 +- .../graphql/ftm/setup/newTemplate.feature | 9 +- .../graphql/ftm/setup/publishPage.feature | 7 +- .../graphql/ftm/setup/publishTemplate.feature | 6 +- .../tests/graphql/ftm/setup/setup.feature | 52 +++++++++ 12 files changed, 150 insertions(+), 114 deletions(-) create mode 100644 test-karate/src/test/java/tests/graphql/ftm/setup/setup.feature diff --git a/test-karate/src/test/java/KarateCITests.java b/test-karate/src/test/java/KarateCITests.java index a2a990e0fe84..07152e558a97 100644 --- a/test-karate/src/test/java/KarateCITests.java +++ b/test-karate/src/test/java/KarateCITests.java @@ -9,7 +9,10 @@ public class KarateCITests { @Test void defaults() { - Results results = Runner.path("classpath:tests/defaults").tags("~@ignore") + Results results = Runner.path( + "classpath:tests/defaults", + "classpath:tests/graphql/ftm" + ).tags("~@ignore") .outputHtmlReport(true) .outputJunitXml(true) .outputCucumberJson(true) diff --git a/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature b/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature index a7142bdd74a1..e44bfe5a544a 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature @@ -1,60 +1,32 @@ Feature: Test Time Machine functionality Background: - * callonce read('classpath:tests/graphql/ftm/setup/helpers.feature') + * callonce read('classpath:tests/graphql/ftm/setup/setup.feature') - # Make the prefix available to the scenario - # Setup required data - # Lets start by creating a new content type, container, template and publish the template - # First the Content Type - * def contentTypeResult = callonce read('classpath:tests/graphql/ftm/setup/newContentType.feature') - * def contentTypeId = contentTypeResult.response.entity[0].id - * def contentTypeVariable = contentTypeResult.response.entity[0].variable - # Now the container, template and publish the template - * def containerResult = callonce read('classpath:tests/graphql/ftm/setup/newContainer.feature') { contentTypeId: '#(contentTypeId)' } - * def containerId = containerResult.response.entity.identifier - * def templateResult = callonce read('classpath:tests/graphql/ftm/setup/newTemplate.feature') { containerId: '#(containerId)' } - * def templateId = templateResult.response.entity.identifier - * callonce read('classpath:tests/graphql/ftm/setup/publishTemplate.feature') { templateId: '#(templateId)' } - - # Create a couple of new pieces of content - * def createContentPieceOneResult = callonce read('classpath:tests/graphql/ftm/setup/newContent.feature') { contentTypeId: '#(contentTypeId)', title: 'test 1' } - * def contentPieceOne = createContentPieceOneResult.response.entity.results - * def contentPieceOneId = contentPieceOne.map(result => Object.keys(result)[0]) - * def contentPieceOneId = contentPieceOneId[0] - - * def createContentPieceTwoResult = callonce read('classpath:tests/graphql/ftm/setup/newContent.feature') { contentTypeId: '#(contentTypeId)', title: 'test 2' } - * def contentPieceTwo = createContentPieceTwoResult.response.entity.results - * def contentPieceTwoId = contentPieceTwo.map(result => Object.keys(result)[0]) - * def contentPieceTwoId = contentPieceTwoId[0] + @smoke @positive + Scenario: Test Time Machine functionality when no publish date is provided + Given url baseUrl + '/api/v1/page/render/'+pageUrl+'?language_id=1&mode=LIVE' + And headers commonHeaders + When method GET + Then status 200 + * def pageContents = extractContentlets (response) - # Now lets create a new version for each piece of content - * def formatter = java.time.format.DateTimeFormatter.ofPattern('yyyy-MM-dd HH:mm:ss') - * def now = java.time.LocalDateTime.now() - * def futureDateTime = now.plusDays(10) - * def formattedFutureDateTime = futureDateTime.format(formatter) + * def contentPieceOne = getContentletByUUID(contentPieceOne, contentPieceOneId) + * def contentPieceTwo = getContentletByUUID(contentPieceTwo, contentPieceTwoId) - * def newContentPiceOneVersion2 = callonce read('classpath:tests/graphql/ftm/setup/newContentVersion.feature') { contentTypeId: '#(contentTypeId)', identifier: '#(contentPieceOneId)', title: 'test 1 v2 (This ver will be publshed in the future)', publishDate: '#(formattedFutureDateTime)' } - * def newContentPiceTwoVersion2 = callonce read('classpath:tests/graphql/ftm/setup/newContentVersion.feature') { contentTypeId: '#(contentTypeId)', identifier: '#(contentPieceTwoId)', title: 'test 2 v2' } + # This is the first version of the content, test 1 v2 as the title says it will be published in the future + * match pageContents[0].title == 'test 1' + # This is the second version of the content, Thisone is already published therefore it should be displayed + * match pageContents[1].title == 'test 2 v2' - * def pageUrl = 'ftm-test-page' + Math.floor(Math.random() * 10000) - # Finally lets create a new page - * def createPageResult = callonce read('classpath:tests/graphql/ftm/setup/newPage.feature') { pageUrl:'#(pageUrl)' ,title: 'Future Time Machine Test page', templateId:'#(templateId)' } - * karate.log('createPageResult:', createPageResult) - * def pages = createPageResult.response.entity.results - * def pageId = pages.map(result => Object.keys(result)[0]) - * def pageId = pageId[0] + @positive + Scenario: Test Time Machine functionality when a publish date is provided expect the future content to be displayed - * def publishPageResult = callonce read('classpath:tests/graphql/ftm/setup/publishPage.feature') { page_id: '#(pageId)', content1_id: '#(contentPieceOneId)', content2_id: '#(contentPieceTwoId)', container_id: '#(containerId)' } - # - @smoke - Scenario Outline: Test Time Machine functionality when no publish date is provided - Given url baseUrl + '/api/v1/page/render/'+pageUrl+'?language_id=1&mode=LIVE' + Given url baseUrl + '/api/v1/page/render/'+pageUrl+'?language_id=1&mode=LIVE&publishDate='+formattedFutureDateTime And headers commonHeaders When method GET Then status 200 - * def pageContents = call extractContentlets response - * karate.log('pageContents:', pageContents) + * def pageContents = extractContentlets (response) * def contentPieceOne = getContentletByUUID(contentPieceOne, contentPieceOneId) * def contentPieceTwo = getContentletByUUID(contentPieceTwo, contentPieceTwoId) @@ -62,24 +34,32 @@ Feature: Test Time Machine functionality # This is the first version of the content, test 1 v2 as the title says it will be published in the future * match pageContents[0].title == 'test 1' # This is the second version of the content, Thisone is already published therefore it should be displayed - * match pageContents[1].title == 'test 2 v2' + * match pageContents[1].title == 'test 1 v2 (This ver will be publshed in the future)' + + @smoke @positive + Scenario: Send GraphQL query to fetch page details no publish date is sent + * def graphQLRequestPayLoad = buildGraphQLRequestPayload (pageUrl) + Given url baseUrl + '/api/v1/graphql' + And headers commonHeaders + And request graphQLRequestPayLoad - Examples: - | scenario | expected result | - | We simply create a new Piece Content which we will use to work on. No publishDate is provided here | We should succeed creating the piece of content | + When method post + Then status 200 + * def contentlets = contentletsFromGraphQlResponse(response) + * karate.log('contentlets:', contentlets) + * match contentlets contains 'test 1' + * match contentlets contains 'test 2 v2' - Scenario Outline: Send GraphQL query to fetch page details - Given url baseUrl + '/api/v1/graphql' - And headers { "Content-Type": "application/json" } - And request - """ - { - "query": "query Page { page(url: \"#(pageUrl)\") { containers { containerContentlets { contentlets { title } } } } }" - } - """ - When method post - Then status 200 - * print response - Examples: - | scenario | expected result | - | We simply create a new Piece Content which we will use to work on. No publishDate is provided here | We should succeed creating the piece of content | + @smoke @positive + Scenario: Send GraphQL query to fetch page details, publish date is sent expect the future content to be displayed + * def graphQLRequestPayLoad = buildGraphQLRequestPayload (pageUrl, formattedFutureDateTime) + Given url baseUrl + '/api/v1/graphql' + And headers commonHeaders + And request graphQLRequestPayLoad + + When method post + Then status 200 + * def contentlets = contentletsFromGraphQlResponse(response) + * karate.log('contentlets:', contentlets) + * match contentlets contains 'test 1' + * match contentlets contains 'test 1 v2 (This ver will be publshed in the future)' diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/helpers.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/helpers.feature index ceea05aebad7..9990dc02fe74 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/setup/helpers.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/helpers.feature @@ -83,4 +83,38 @@ Feature: Reusable Functions and Helpers } return null; // Return null if not found } - """ \ No newline at end of file + """ + + ## Builds a payload for creating a new GraphQL request + * def buildGraphQLRequestPayload = + """ + function(pageUri, publishDate) { + if (!pageUri.startsWith('/')) { + pageUri = '/' + pageUri; + } + var query = 'query Page { page(url: "' + pageUri + '"'; + if (publishDate) { + query += ' publishDate: "' + publishDate + '"'; + } + query += ') { containers { containerContentlets { contentlets { title } } } } }'; + return { query: query }; + } + """ + + ## Extracts all contentlet titles from a GraphQL response + * def contentletsFromGraphQlResponse = + """ + function(response) { + var containers = response.data.page.containers; + var allTitles = []; + containers.forEach(container => { + container.containerContentlets.forEach(cc => { + cc.contentlets.forEach(contentlet => { + allTitles.push(contentlet.title); + }); + }); + }); + return allTitles; + } + """ + ## \ No newline at end of file diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newContainer.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newContainer.feature index 93934a343dcb..0698e5df097e 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/setup/newContainer.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newContainer.feature @@ -2,7 +2,7 @@ Feature: Create a Content Type Background: * def containerNameVariable = 'MyContainer' + Math.floor(Math.random() * 100000) - Scenario Outline: Create a content type and expect 200 OK + Scenario: Create a content type and expect 200 OK Given url baseUrl + '/api/v1/containers' And headers commonHeaders And request @@ -22,7 +22,3 @@ Feature: Create a Content Type """ When method POST Then status 200 - - Examples: - | scenario | expected result | - | We create a new Container using a random name | The container gets created just fine | diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newContent.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newContent.feature index 3509f22d8754..64affd0890be 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/setup/newContent.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newContent.feature @@ -1,7 +1,7 @@ Feature: Create an instance of a new Content Type and expect 200 OK Background: - Scenario Outline: Create an instance of a new Content Type and expect 200 OK + Scenario: Create an instance of a new Content Type and expect 200 OK # Params are expected as arguments to the feature file * def contentTypeId = __arg.contentTypeId @@ -18,7 +18,4 @@ Background: When method POST Then status 200 * def errors = call extractErrors response - * match errors == [] - Examples: - | scenario | expected result | - | We simply create a new Piece Content which we will use to work on. No publishDate is provided here | We should succeed creating the piece of content | \ No newline at end of file + * match errors == [] \ No newline at end of file diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newContentType.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newContentType.feature index b272c7a435b5..cba1f9b210ff 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/setup/newContentType.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newContentType.feature @@ -2,7 +2,7 @@ Feature: Create a Content Type Background: * def contentTypeVariable = 'MyContentType' + Math.floor(Math.random() * 100000) - Scenario Outline: Create a content type and expect 200 OK + Scenario: Create a content type and expect 200 OK Given url baseUrl + '/api/v1/contenttype' And headers commonHeaders And request @@ -115,7 +115,4 @@ Feature: Create a Content Type When method POST Then status 200 And match response.entity[0].id != null - And match response.entity[0].variable == contentTypeVariable - Examples: - | scenario | expected result | - | We create a new Container using a random name | The container gets created just fine | \ No newline at end of file + And match response.entity[0].variable == contentTypeVariable \ No newline at end of file diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newContentVersion.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newContentVersion.feature index c7870ed3dee5..e6594519efc1 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/setup/newContentVersion.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newContentVersion.feature @@ -1,7 +1,5 @@ Feature: Create a new version of a piece of content -Background: - - Scenario Outline: Create a new version of a piece of content + Scenario: Create a new version of a piece of content # Params are expected as arguments to the feature file * def identifier = __arg.identifier @@ -18,6 +16,3 @@ Background: Then status 200 * def errors = call extractErrors response * match errors == [] - Examples: - | name | description | - | new | THE DESCRIPTION 1 | diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newPage.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newPage.feature index 6b4f563963b5..5d5f7b52ac94 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/setup/newPage.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newPage.feature @@ -1,10 +1,7 @@ -Feature: Create a Page - Background: - Scenario Outline: Create a new version of a piece of content + Feature: Create a Page + Scenario: Create a new version of a piece of content Given url baseUrl + '/api/v1/workflow/actions/default/fire/PUBLISH?indexPolicy=WAIT_FOR' And headers commonHeaders - * def pageUrl = (__arg.pageUrl ? __arg.pageUrl : 'ftm-test-page' + Math.floor(Math.random() * 10000)) - * def templateId = (__arg.templateId ? __arg.templateId : 'SYSTEM_TEMPLATE') And request """ { @@ -24,7 +21,4 @@ Feature: Create a Page When method POST Then status 200 * def errors = call extractErrors response - * match errors == [] - Examples: - | scenario | expected result | - | We simply create a Page to hold the template/container and therefore the contents | We should succeed creating the page | + * match errors == [] \ No newline at end of file diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newTemplate.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/newTemplate.feature index febe9346472e..652ee787ddd6 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/setup/newTemplate.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/newTemplate.feature @@ -1,7 +1,7 @@ Feature: Create a new Template for later use during Time Machine testing Background: * def templateName = 'MyTemplate' + Math.floor(Math.random() * 1000) - Scenario Outline: Create a new Template + Scenario: Create a new Template Given url baseUrl + '/api/v1/templates' And headers commonHeaders And request @@ -57,9 +57,4 @@ Feature: Create a new Template for later use during Time Machine testing } """ When method post - Then status 200 - - - Examples: - | scenario | expected result | - | We create a Template to hold the containers/contents served by the page | We should succeed creating the template | \ No newline at end of file + Then status 200 \ No newline at end of file diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/publishPage.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/publishPage.feature index d22b73908684..3e71001fb606 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/setup/publishPage.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/publishPage.feature @@ -17,7 +17,7 @@ Feature: Add pieces of content then Publish the Page * def content2_id = __arg.content2_id * def container_id = __arg.container_id - Scenario Outline: Create a new version of a piece of content + Scenario: Create a new version of a piece of content Given url baseUrl + '/api/v1/page/'+page_id+'/content' And headers commonHeaders And request @@ -33,7 +33,4 @@ Feature: Add pieces of content then Publish the Page When method POST Then status 200 * def errors = call validateNoErrors response - * match errors == [] - Examples: - | name | description | - | new | THE DESCRIPTION 1 | \ No newline at end of file + * match errors == [] \ No newline at end of file diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/publishTemplate.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/publishTemplate.feature index 1c005d4d8f75..d2f314c5dc87 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/setup/publishTemplate.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/publishTemplate.feature @@ -1,7 +1,7 @@ Feature: Publish a Template Background: - Scenario Outline: Create a new Template + Scenario: Create a new Template Given url baseUrl + '/api/v1/templates/_publish' And headers commonHeaders And request @@ -10,7 +10,3 @@ Feature: Publish a Template """ When method PUT Then status 200 - - Examples: - | name | description | - | publish template | THE DESCRIPTION 1 | diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/setup.feature b/test-karate/src/test/java/tests/graphql/ftm/setup/setup.feature new file mode 100644 index 000000000000..218c8b812337 --- /dev/null +++ b/test-karate/src/test/java/tests/graphql/ftm/setup/setup.feature @@ -0,0 +1,52 @@ +Feature: Setting up the Future Time Machine Test + + Background: + * callonce read('classpath:tests/graphql/ftm/setup/helpers.feature') + # Make the prefix available to the scenario + # Setup required data + # Lets start by creating a new content type, container, template and publish the template + # First the Content Type + * def contentTypeResult = callonce read('classpath:tests/graphql/ftm/setup/newContentType.feature') + * def contentTypeId = contentTypeResult.response.entity[0].id + * def contentTypeVariable = contentTypeResult.response.entity[0].variable + # Now the container, template and publish the template + * def containerResult = callonce read('classpath:tests/graphql/ftm/setup/newContainer.feature') { contentTypeId: '#(contentTypeId)' } + * def containerId = containerResult.response.entity.identifier + * def templateResult = callonce read('classpath:tests/graphql/ftm/setup/newTemplate.feature') { containerId: '#(containerId)' } + * def templateId = templateResult.response.entity.identifier + * callonce read('classpath:tests/graphql/ftm/setup/publishTemplate.feature') { templateId: '#(templateId)' } + + # Create a couple of new pieces of content + * def createContentPieceOneResult = callonce read('classpath:tests/graphql/ftm/setup/newContent.feature') { contentTypeId: '#(contentTypeId)', title: 'test 1' } + * def contentPieceOne = createContentPieceOneResult.response.entity.results + * def contentPieceOneId = contentPieceOne.map(result => Object.keys(result)[0]) + * def contentPieceOneId = contentPieceOneId[0] + + * def createContentPieceTwoResult = callonce read('classpath:tests/graphql/ftm/setup/newContent.feature') { contentTypeId: '#(contentTypeId)', title: 'test 2' } + * def contentPieceTwo = createContentPieceTwoResult.response.entity.results + * def contentPieceTwoId = contentPieceTwo.map(result => Object.keys(result)[0]) + * def contentPieceTwoId = contentPieceTwoId[0] + + # Now lets create a new version for each piece of content + * def formatter = java.time.format.DateTimeFormatter.ofPattern('yyyy-MM-dd') + * def now = java.time.LocalDateTime.now() + * def futureDateTime = now.plusDays(10) + * def formattedFutureDateTime = futureDateTime.format(formatter) + + * def newContentPiceOneVersion2 = callonce read('classpath:tests/graphql/ftm/setup/newContentVersion.feature') { contentTypeId: '#(contentTypeId)', identifier: '#(contentPieceOneId)', title: 'test 1 v2 (This ver will be publshed in the future)', publishDate: '#(formattedFutureDateTime)' } + * def newContentPiceTwoVersion2 = callonce read('classpath:tests/graphql/ftm/setup/newContentVersion.feature') { contentTypeId: '#(contentTypeId)', identifier: '#(contentPieceTwoId)', title: 'test 2 v2' } + + * def pageUrl = 'ftm-test-page' + Math.floor(Math.random() * 10000) + + # Finally lets create a new page + * def createPageResult = callonce read('classpath:tests/graphql/ftm/setup/newPage.feature') { pageUrl:'#(pageUrl)' ,title: 'Future Time Machine Test page', templateId:'#(templateId)' } + + * def pages = createPageResult.response.entity.results + * def pageId = pages.map(result => Object.keys(result)[0]) + * def pageId = pageId[0] + + * def publishPageResult = callonce read('classpath:tests/graphql/ftm/setup/publishPage.feature') { page_id: '#(pageId)', content1_id: '#(contentPieceOneId)', content2_id: '#(contentPieceTwoId)', container_id: '#(containerId)' } + + * karate.log('Page created and Published ::', pageUrl) + + Scenario: \ No newline at end of file From 148e5183194214189f1444a5345db88bc1fbfa78 Mon Sep 17 00:00:00 2001 From: fabrizzio-dotCMS Date: Fri, 13 Dec 2024 17:44:33 -0600 Subject: [PATCH 06/11] #30780 --- .../java/{tests/graphql/ftm/setup => graphql/ftm}/helpers.feature | 0 .../{tests/graphql/ftm/setup => graphql/ftm}/newContainer.feature | 0 .../{tests/graphql/ftm/setup => graphql/ftm}/newContent.feature | 0 .../graphql/ftm/setup => graphql/ftm}/newContentType.feature | 0 .../graphql/ftm/setup => graphql/ftm}/newContentVersion.feature | 0 .../java/{tests/graphql/ftm/setup => graphql/ftm}/newPage.feature | 0 .../{tests/graphql/ftm/setup => graphql/ftm}/newTemplate.feature | 0 .../{tests/graphql/ftm/setup => graphql/ftm}/publishPage.feature | 0 .../graphql/ftm/setup => graphql/ftm}/publishTemplate.feature | 0 .../java/{tests/graphql/ftm/setup => graphql/ftm}/setup.feature | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename test-karate/src/test/java/{tests/graphql/ftm/setup => graphql/ftm}/helpers.feature (100%) rename test-karate/src/test/java/{tests/graphql/ftm/setup => graphql/ftm}/newContainer.feature (100%) rename test-karate/src/test/java/{tests/graphql/ftm/setup => graphql/ftm}/newContent.feature (100%) rename test-karate/src/test/java/{tests/graphql/ftm/setup => graphql/ftm}/newContentType.feature (100%) rename test-karate/src/test/java/{tests/graphql/ftm/setup => graphql/ftm}/newContentVersion.feature (100%) rename test-karate/src/test/java/{tests/graphql/ftm/setup => graphql/ftm}/newPage.feature (100%) rename test-karate/src/test/java/{tests/graphql/ftm/setup => graphql/ftm}/newTemplate.feature (100%) rename test-karate/src/test/java/{tests/graphql/ftm/setup => graphql/ftm}/publishPage.feature (100%) rename test-karate/src/test/java/{tests/graphql/ftm/setup => graphql/ftm}/publishTemplate.feature (100%) rename test-karate/src/test/java/{tests/graphql/ftm/setup => graphql/ftm}/setup.feature (100%) diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/helpers.feature b/test-karate/src/test/java/graphql/ftm/helpers.feature similarity index 100% rename from test-karate/src/test/java/tests/graphql/ftm/setup/helpers.feature rename to test-karate/src/test/java/graphql/ftm/helpers.feature diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newContainer.feature b/test-karate/src/test/java/graphql/ftm/newContainer.feature similarity index 100% rename from test-karate/src/test/java/tests/graphql/ftm/setup/newContainer.feature rename to test-karate/src/test/java/graphql/ftm/newContainer.feature diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newContent.feature b/test-karate/src/test/java/graphql/ftm/newContent.feature similarity index 100% rename from test-karate/src/test/java/tests/graphql/ftm/setup/newContent.feature rename to test-karate/src/test/java/graphql/ftm/newContent.feature diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newContentType.feature b/test-karate/src/test/java/graphql/ftm/newContentType.feature similarity index 100% rename from test-karate/src/test/java/tests/graphql/ftm/setup/newContentType.feature rename to test-karate/src/test/java/graphql/ftm/newContentType.feature diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newContentVersion.feature b/test-karate/src/test/java/graphql/ftm/newContentVersion.feature similarity index 100% rename from test-karate/src/test/java/tests/graphql/ftm/setup/newContentVersion.feature rename to test-karate/src/test/java/graphql/ftm/newContentVersion.feature diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newPage.feature b/test-karate/src/test/java/graphql/ftm/newPage.feature similarity index 100% rename from test-karate/src/test/java/tests/graphql/ftm/setup/newPage.feature rename to test-karate/src/test/java/graphql/ftm/newPage.feature diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/newTemplate.feature b/test-karate/src/test/java/graphql/ftm/newTemplate.feature similarity index 100% rename from test-karate/src/test/java/tests/graphql/ftm/setup/newTemplate.feature rename to test-karate/src/test/java/graphql/ftm/newTemplate.feature diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/publishPage.feature b/test-karate/src/test/java/graphql/ftm/publishPage.feature similarity index 100% rename from test-karate/src/test/java/tests/graphql/ftm/setup/publishPage.feature rename to test-karate/src/test/java/graphql/ftm/publishPage.feature diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/publishTemplate.feature b/test-karate/src/test/java/graphql/ftm/publishTemplate.feature similarity index 100% rename from test-karate/src/test/java/tests/graphql/ftm/setup/publishTemplate.feature rename to test-karate/src/test/java/graphql/ftm/publishTemplate.feature diff --git a/test-karate/src/test/java/tests/graphql/ftm/setup/setup.feature b/test-karate/src/test/java/graphql/ftm/setup.feature similarity index 100% rename from test-karate/src/test/java/tests/graphql/ftm/setup/setup.feature rename to test-karate/src/test/java/graphql/ftm/setup.feature From 4cb1811bace2b4a1e49a750db44a4edc7aea476c Mon Sep 17 00:00:00 2001 From: fabrizzio-dotCMS Date: Fri, 13 Dec 2024 20:11:29 -0600 Subject: [PATCH 07/11] #30780 --- .../src/test/java/graphql/ftm/setup.feature | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test-karate/src/test/java/graphql/ftm/setup.feature b/test-karate/src/test/java/graphql/ftm/setup.feature index 218c8b812337..1d8b6a2f5628 100644 --- a/test-karate/src/test/java/graphql/ftm/setup.feature +++ b/test-karate/src/test/java/graphql/ftm/setup.feature @@ -1,28 +1,28 @@ Feature: Setting up the Future Time Machine Test Background: - * callonce read('classpath:tests/graphql/ftm/setup/helpers.feature') + * callonce read('classpath:graphql/ftm/helpers.feature') # Make the prefix available to the scenario # Setup required data # Lets start by creating a new content type, container, template and publish the template # First the Content Type - * def contentTypeResult = callonce read('classpath:tests/graphql/ftm/setup/newContentType.feature') + * def contentTypeResult = callonce read('classpath:graphql/ftm/newContentType.feature') * def contentTypeId = contentTypeResult.response.entity[0].id * def contentTypeVariable = contentTypeResult.response.entity[0].variable # Now the container, template and publish the template - * def containerResult = callonce read('classpath:tests/graphql/ftm/setup/newContainer.feature') { contentTypeId: '#(contentTypeId)' } + * def containerResult = callonce read('classpath:graphql/ftm/newContainer.feature') { contentTypeId: '#(contentTypeId)' } * def containerId = containerResult.response.entity.identifier - * def templateResult = callonce read('classpath:tests/graphql/ftm/setup/newTemplate.feature') { containerId: '#(containerId)' } + * def templateResult = callonce read('classpath:graphql/ftm/newTemplate.feature') { containerId: '#(containerId)' } * def templateId = templateResult.response.entity.identifier - * callonce read('classpath:tests/graphql/ftm/setup/publishTemplate.feature') { templateId: '#(templateId)' } + * callonce read('classpath:graphql/ftm/publishTemplate.feature') { templateId: '#(templateId)' } # Create a couple of new pieces of content - * def createContentPieceOneResult = callonce read('classpath:tests/graphql/ftm/setup/newContent.feature') { contentTypeId: '#(contentTypeId)', title: 'test 1' } + * def createContentPieceOneResult = callonce read('classpath:graphql/ftm/newContent.feature') { contentTypeId: '#(contentTypeId)', title: 'test 1' } * def contentPieceOne = createContentPieceOneResult.response.entity.results * def contentPieceOneId = contentPieceOne.map(result => Object.keys(result)[0]) * def contentPieceOneId = contentPieceOneId[0] - * def createContentPieceTwoResult = callonce read('classpath:tests/graphql/ftm/setup/newContent.feature') { contentTypeId: '#(contentTypeId)', title: 'test 2' } + * def createContentPieceTwoResult = callonce read('classpath:graphql/ftm/newContent.feature') { contentTypeId: '#(contentTypeId)', title: 'test 2' } * def contentPieceTwo = createContentPieceTwoResult.response.entity.results * def contentPieceTwoId = contentPieceTwo.map(result => Object.keys(result)[0]) * def contentPieceTwoId = contentPieceTwoId[0] @@ -33,19 +33,19 @@ Feature: Setting up the Future Time Machine Test * def futureDateTime = now.plusDays(10) * def formattedFutureDateTime = futureDateTime.format(formatter) - * def newContentPiceOneVersion2 = callonce read('classpath:tests/graphql/ftm/setup/newContentVersion.feature') { contentTypeId: '#(contentTypeId)', identifier: '#(contentPieceOneId)', title: 'test 1 v2 (This ver will be publshed in the future)', publishDate: '#(formattedFutureDateTime)' } - * def newContentPiceTwoVersion2 = callonce read('classpath:tests/graphql/ftm/setup/newContentVersion.feature') { contentTypeId: '#(contentTypeId)', identifier: '#(contentPieceTwoId)', title: 'test 2 v2' } + * def newContentPiceOneVersion2 = callonce read('classpath:graphql/ftm/newContentVersion.feature') { contentTypeId: '#(contentTypeId)', identifier: '#(contentPieceOneId)', title: 'test 1 v2 (This ver will be publshed in the future)', publishDate: '#(formattedFutureDateTime)' } + * def newContentPiceTwoVersion2 = callonce read('classpath:graphql/ftm/newContentVersion.feature') { contentTypeId: '#(contentTypeId)', identifier: '#(contentPieceTwoId)', title: 'test 2 v2' } * def pageUrl = 'ftm-test-page' + Math.floor(Math.random() * 10000) # Finally lets create a new page - * def createPageResult = callonce read('classpath:tests/graphql/ftm/setup/newPage.feature') { pageUrl:'#(pageUrl)' ,title: 'Future Time Machine Test page', templateId:'#(templateId)' } + * def createPageResult = callonce read('classpath:graphql/ftm/newPage.feature') { pageUrl:'#(pageUrl)' ,title: 'Future Time Machine Test page', templateId:'#(templateId)' } * def pages = createPageResult.response.entity.results * def pageId = pages.map(result => Object.keys(result)[0]) * def pageId = pageId[0] - * def publishPageResult = callonce read('classpath:tests/graphql/ftm/setup/publishPage.feature') { page_id: '#(pageId)', content1_id: '#(contentPieceOneId)', content2_id: '#(contentPieceTwoId)', container_id: '#(containerId)' } + * def publishPageResult = callonce read('classpath:graphql/ftm/publishPage.feature') { page_id: '#(pageId)', content1_id: '#(contentPieceOneId)', content2_id: '#(contentPieceTwoId)', container_id: '#(containerId)' } * karate.log('Page created and Published ::', pageUrl) From 334eafd776dba208c2dad85a24959881215aaf18 Mon Sep 17 00:00:00 2001 From: fabrizzio-dotCMS Date: Fri, 13 Dec 2024 20:21:57 -0600 Subject: [PATCH 08/11] #30780 --- .../graphql/ftm/CheckingTimeMachine.feature | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature b/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature index e44bfe5a544a..1f3b384403d9 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature @@ -1,9 +1,9 @@ Feature: Test Time Machine functionality Background: - * callonce read('classpath:tests/graphql/ftm/setup/setup.feature') + * callonce read('classpath:graphql/ftm/setup.feature') - @smoke @positive + @ignore @smoke @positive Scenario: Test Time Machine functionality when no publish date is provided Given url baseUrl + '/api/v1/page/render/'+pageUrl+'?language_id=1&mode=LIVE' And headers commonHeaders @@ -14,10 +14,11 @@ Feature: Test Time Machine functionality * 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 pageContents[0].title == 'test 1' + * match titles contains 'test 1' # This is the second version of the content, Thisone is already published therefore it should be displayed - * match pageContents[1].title == 'test 2 v2' + * match titles contains 'test 2 v2' @positive Scenario: Test Time Machine functionality when a publish date is provided expect the future content to be displayed @@ -31,12 +32,10 @@ Feature: Test Time Machine functionality * def contentPieceOne = getContentletByUUID(contentPieceOne, contentPieceOneId) * def contentPieceTwo = getContentletByUUID(contentPieceTwo, contentPieceTwoId) - # This is the first version of the content, test 1 v2 as the title says it will be published in the future - * match pageContents[0].title == 'test 1' - # This is the second version of the content, Thisone is already published therefore it should be displayed - * match pageContents[1].title == 'test 1 v2 (This ver will be publshed in the future)' + * def titles = pageContents.map(x => x.title) + * match titles contains 'test 1 v2 (This ver will be publshed in the future)' - @smoke @positive + @ignore @smoke @positive Scenario: Send GraphQL query to fetch page details no publish date is sent * def graphQLRequestPayLoad = buildGraphQLRequestPayload (pageUrl) Given url baseUrl + '/api/v1/graphql' @@ -61,5 +60,4 @@ 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 1 v2 (This ver will be publshed in the future)' From 63436c9a82001ddaa2154932e8ac43de43e4c7d9 Mon Sep 17 00:00:00 2001 From: fabrizzio-dotCMS Date: Mon, 16 Dec 2024 09:52:52 -0600 Subject: [PATCH 09/11] #30780 --- .../com/dotcms/graphql/datafetcher/page/PageDataFetcher.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/dotCMS/src/main/java/com/dotcms/graphql/datafetcher/page/PageDataFetcher.java b/dotCMS/src/main/java/com/dotcms/graphql/datafetcher/page/PageDataFetcher.java index 6539b07e4ab0..a885e60fb2d5 100644 --- a/dotCMS/src/main/java/com/dotcms/graphql/datafetcher/page/PageDataFetcher.java +++ b/dotCMS/src/main/java/com/dotcms/graphql/datafetcher/page/PageDataFetcher.java @@ -59,7 +59,6 @@ public Contentlet get(final DataFetchingEnvironment environment) throws Exceptio final boolean fireRules = environment.getArgument("fireRules"); final String persona = environment.getArgument("persona"); final String site = environment.getArgument("site"); - final String variant = environment.getArgument("variant"); final String publishDate = environment.getArgument("publishDate"); context.addParam("url", url); @@ -82,10 +81,6 @@ public Contentlet get(final DataFetchingEnvironment environment) throws Exceptio request.setAttribute(WebKeys.CMS_PERSONA_PARAMETER, persona); } - if (UtilMethods.isSet(variant)) { - request.setAttribute(VariantAPI.VARIANT_KEY, variant); - } - if(UtilMethods.isSet(site)) { request.setAttribute(Host.HOST_VELOCITY_VAR_NAME, site); } From ee30506b0210ce6b3514af4c2d068f8965cd3690 Mon Sep 17 00:00:00 2001 From: fabrizzio-dotCMS Date: Mon, 16 Dec 2024 09:55:09 -0600 Subject: [PATCH 10/11] #30780 --- .../test/java/tests/graphql/ftm/CheckingTimeMachine.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature b/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature index 1f3b384403d9..4bd6dd382506 100644 --- a/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature +++ b/test-karate/src/test/java/tests/graphql/ftm/CheckingTimeMachine.feature @@ -3,7 +3,7 @@ Feature: Test Time Machine functionality Background: * callonce read('classpath:graphql/ftm/setup.feature') - @ignore @smoke @positive + @smoke @positive Scenario: Test Time Machine functionality when no publish date is provided Given url baseUrl + '/api/v1/page/render/'+pageUrl+'?language_id=1&mode=LIVE' And headers commonHeaders @@ -35,7 +35,7 @@ Feature: Test Time Machine functionality * def titles = pageContents.map(x => x.title) * match titles contains 'test 1 v2 (This ver will be publshed in the future)' - @ignore @smoke @positive + @smoke @positive Scenario: Send GraphQL query to fetch page details no publish date is sent * def graphQLRequestPayLoad = buildGraphQLRequestPayload (pageUrl) Given url baseUrl + '/api/v1/graphql' From f97b0fb0cc38f9f7ee39b53d04f4ec7ad240f4f6 Mon Sep 17 00:00:00 2001 From: fabrizzio-dotCMS Date: Mon, 16 Dec 2024 13:31:31 -0600 Subject: [PATCH 11/11] #30780 --- .../src/test/java/graphql/ftm/helpers.feature | 42 ++++++++++++------- .../java/graphql/ftm/newContainer.feature | 2 +- .../test/java/graphql/ftm/publishPage.feature | 11 ----- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/test-karate/src/test/java/graphql/ftm/helpers.feature b/test-karate/src/test/java/graphql/ftm/helpers.feature index 9990dc02fe74..c33701d4ed6f 100644 --- a/test-karate/src/test/java/graphql/ftm/helpers.feature +++ b/test-karate/src/test/java/graphql/ftm/helpers.feature @@ -2,11 +2,23 @@ Feature: Reusable Functions and Helpers Scenario: Define reusable functions + ## General error free validation + * def validateNoErrors = + """ + function (response) { + const errors = response.errors; + if (errors) { + return errors; + } + return []; + } + """ + ## Builds a payload for creating a new content version * def buildContentRequestPayload = """ function(contentType, title, publishDate, expiresOn, identifier) { - var payload = { + let payload = { "contentlets": [ { "contentType": contentType, @@ -25,13 +37,13 @@ Feature: Reusable Functions and Helpers * def extractErrors = """ function(response) { - var errors = []; - var results = response.entity.results; + let errors = []; + let results = response.entity.results; if (results && results.length > 0) { - for (var i = 0; i < results.length; i++) { - var result = results[i]; + for (let i = 0; i < results.length; i++) { + let result = results[i]; // Handle both nested error messages and direct error messages - for (var key in result) { + for (let key in result) { if (result[key] && result[key].errorMessage) { errors.push(result[key].errorMessage); } @@ -46,11 +58,11 @@ Feature: Reusable Functions and Helpers * def extractContentlets = """ function(response) { - var containers = response.entity.containers; - var allContentlets = []; - for (var key in containers) { + let containers = response.entity.containers; + let allContentlets = []; + for (let key in containers) { if (containers[key].contentlets) { - for (var contentletKey in containers[key].contentlets) { + for (let contentletKey in containers[key].contentlets) { allContentlets = allContentlets.concat(containers[key].contentlets[contentletKey]); } } @@ -64,7 +76,7 @@ Feature: Reusable Functions and Helpers """ function() { if (!karate.get('testSuffix')) { - var prefix = '__' + Math.floor(Math.random() * 100000); + let prefix = '__' + Math.floor(Math.random() * 100000); karate.set('testSuffix', prefix); } return karate.get('testSuffix'); @@ -75,8 +87,8 @@ Feature: Reusable Functions and Helpers * def getContentletByUUID = """ function(jsonArray, uuid) { - for (var i = 0; i < jsonArray.length; i++) { - var keys = Object.keys(jsonArray[i]); + for (let i = 0; i < jsonArray.length; i++) { + let keys = Object.keys(jsonArray[i]); if (keys.includes(uuid)) { return jsonArray[i][uuid]; } @@ -105,8 +117,8 @@ Feature: Reusable Functions and Helpers * def contentletsFromGraphQlResponse = """ function(response) { - var containers = response.data.page.containers; - var allTitles = []; + let containers = response.data.page.containers; + let allTitles = []; containers.forEach(container => { container.containerContentlets.forEach(cc => { cc.contentlets.forEach(contentlet => { diff --git a/test-karate/src/test/java/graphql/ftm/newContainer.feature b/test-karate/src/test/java/graphql/ftm/newContainer.feature index 0698e5df097e..b52636cb9147 100644 --- a/test-karate/src/test/java/graphql/ftm/newContainer.feature +++ b/test-karate/src/test/java/graphql/ftm/newContainer.feature @@ -1,4 +1,4 @@ -Feature: Create a Content Type +Feature: Create a Container Background: * def containerNameVariable = 'MyContainer' + Math.floor(Math.random() * 100000) diff --git a/test-karate/src/test/java/graphql/ftm/publishPage.feature b/test-karate/src/test/java/graphql/ftm/publishPage.feature index 3e71001fb606..68b9b9923732 100644 --- a/test-karate/src/test/java/graphql/ftm/publishPage.feature +++ b/test-karate/src/test/java/graphql/ftm/publishPage.feature @@ -1,17 +1,6 @@ Feature: Add pieces of content then Publish the Page Background: - * def validateNoErrors = - """ - function (response) { - const errors = response.errors; - if (errors) { - return errors; - } - return []; - } - """ - * def page_id = __arg.page_id * def content1_id = __arg.content1_id * def content2_id = __arg.content2_id