@ministryofjustice/hmpps-digital-prison-reporting-frontend 4.17.6 → 4.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dpr/components/_filters/utils.js +1 -1
  2. package/dpr/components/_filters/utils.js.map +3 -3
  3. package/dpr/components/_filters/utils.ts +10 -6
  4. package/dpr/components/_reports/report-actions/view.njk +15 -13
  5. package/dpr/components/user-reports/utils.js +1 -1
  6. package/dpr/components/user-reports/utils.js.map +2 -2
  7. package/dpr/components/user-reports/utils.ts +1 -1
  8. package/dpr/data/dashboardClient.js +1 -1
  9. package/dpr/data/dashboardClient.js.map +3 -3
  10. package/dpr/data/dashboardClient.ts +4 -1
  11. package/dpr/data/reportingClient.js +1 -1
  12. package/dpr/data/reportingClient.js.map +3 -3
  13. package/dpr/data/reportingClient.ts +4 -1
  14. package/dpr/routes/journeys/view-report/async/dashboard/utils.js +1 -1
  15. package/dpr/routes/journeys/view-report/async/dashboard/utils.js.map +3 -3
  16. package/dpr/routes/journeys/view-report/async/dashboard/utils.ts +22 -9
  17. package/dpr/routes/journeys/view-report/async/report/tests.cy.js +1 -1
  18. package/dpr/routes/journeys/view-report/async/report/tests.cy.js.map +2 -2
  19. package/dpr/routes/journeys/view-report/async/report/tests.cy.ts +0 -3
  20. package/dpr/routes/journeys/view-report/async/report/utils.js +1 -1
  21. package/dpr/routes/journeys/view-report/async/report/utils.js.map +3 -3
  22. package/dpr/routes/journeys/view-report/async/report/utils.ts +6 -5
  23. package/dpr/services/dashboardService.js +1 -1
  24. package/dpr/services/dashboardService.js.map +3 -3
  25. package/dpr/services/dashboardService.ts +2 -1
  26. package/dpr/services/reportingService.js +1 -1
  27. package/dpr/services/reportingService.js.map +2 -2
  28. package/dpr/services/reportingService.ts +2 -1
  29. package/package.json +1 -1
@@ -91,11 +91,14 @@ class ReportingClient {
91
91
  reportId: string,
92
92
  variantId: string,
93
93
  definitionsPath?: string,
94
+ queryData?: Dict<string | string[]>,
94
95
  ): Promise<components['schemas']['SingleVariantReportDefinition']> {
95
96
  const query = {
97
+ ...queryData,
96
98
  dataProductDefinitionsPath: definitionsPath,
97
99
  }
98
- this.logInfo('Get definition', { reportId, variantId })
100
+
101
+ this.logInfo('Get definition', { reportId, variantId, ...query })
99
102
 
100
103
  return this.restClient
101
104
  .get({
@@ -1,2 +1,2 @@
1
- "use strict";var x=Object.create;var b=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var H=(t,e)=>{for(var r in e)b(t,r,{get:e[r],enumerable:!0})},T=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of N(e))!_.call(t,a)&&a!==r&&b(t,a,{get:()=>e[a],enumerable:!(o=M(e,a))||o.enumerable});return t};var d=(t,e,r)=>(r=t!=null?x(O(t)):{},T(e||!t||!t.__esModule?b(r,"default",{value:t,enumerable:!0}):r,t)),Q=t=>T(b({},"__esModule",{value:!0}),t);var z={};H(z,{default:()=>j,renderAsyncDashboard:()=>B});module.exports=Q(z);var m=require("../../../../../components/_dashboards/dashboard-visualisation/types"),S=require("../../../../../types/UserReports"),y=d(require("../../../../../components/_charts/utils")),E=d(require("../../../../../utils/definitionUtils")),w=d(require("../../../../../components/user-reports/utils")),V=d(require("../../../../../components/_dashboards/dashboard-list/utils")),g=d(require("../../../../../components/_filters/utils")),P=d(require("../../../../../components/_dashboards/scorecard/utils")),A=d(require("../../../../../components/_dashboards/scorecard/Scorecard")),q=d(require("../../../../../components/_reports/report-actions/utils")),F=d(require("../../../../../types/ReportQuery")),I=d(require("../../../../../utils/localsHelper")),C=require("../../../../../components/_filters/filtersTypeEnum");const G=(t,e,r)=>{const o=e.name,{name:a}=t,i=r?.url?.request?.fullUrl,n=r?.executionId;let s={};return i&&(s={share:{reportName:o,name:a,url:i},copy:{url:i}},n&&(s={...s,refresh:{url:i,executionId:n}})),q.default.getActions(s)},v=async({req:t,res:e,services:r})=>{const{token:o}=I.default.getValues(e),{reportId:a,id:i}=t.params,n=t.query.dataProductDefinitionsPath,s=await r.dashboardService.getDefinition(o,a,i,n),l=await E.default.getReportSummary(a,r.reportingService,o,n),c=await g.default.getFilters({fields:s.filterFields||[],req:t,filtersType:C.FiltersType.INTERACTIVE}),u=g.default.setRequestQueryFromFilterValues(c.filters);return{query:new F.default({fields:s.filterFields||[],queryParams:u,definitionsPath:n,reportType:S.ReportType.DASHBOARD}).toRecordWithFilterPrefix(!0),filters:c,dashboardDefinition:s,reportDefinition:l}},W=(t,e,r)=>t.sections.map(o=>{const{id:a,display:i,description:n}=o;let s=!1;const l=o.visualisations.map(c=>{const{type:u,display:f,description:D,id:R}=c;let p;switch(u){case m.DashboardVisualisationType.LIST:p=V.default.createList(c,e);break;case m.DashboardVisualisationType.SCORECARD:s=!0,p=new A.default(e,c).build();break;case m.DashboardVisualisationType.SCORECARD_GROUP:p=new A.default(e,c,!0).build();break;case m.DashboardVisualisationType.BAR:case m.DashboardVisualisationType.LINE:case m.DashboardVisualisationType.DONUT:{p=y.default.createChart(c,e);break}case m.DashboardVisualisationType.MATRIX_TIMESERIES:{p=y.default.createMatrixChart(c,e,r);break}case m.DashboardVisualisationType.BAR_TIMESERIES:case m.DashboardVisualisationType.LINE_TIMESERIES:{p=y.default.createTimeseriesCharts(c,e);break}default:break}return{id:R,title:f||"",description:D||"",type:u,data:p}});return s&&P.default.mergeScorecardsIntoGroup(l),{id:a,title:i||"",description:n||"",visualisations:l}}),X=async(t,e,r,o,a,i)=>{const{requestedReportService:n}=t,s=n?await n.getReportByTableId(e,r):void 0;return o&&o.length&&s&&w.default.updateLastViewed({services:t,reportStateData:s,userId:r,req:a,filters:i}),s},B=async({req:t,res:e,services:r})=>{const{token:o,csrfToken:a,dprUser:i,nestedBaseUrl:n}=I.default.getValues(e),{reportId:s,id:l,tableId:c}=t.params,{bookmarkService:u,requestedReportService:f}=r,{query:D,filters:R,reportDefinition:p,dashboardDefinition:h}=await v({req:t,res:e,services:r}),L=(await r.dashboardService.getAsyncDashboard(o,l,s,c,D)).flat(),U=W(h,L,D);let k;return f&&(k=await X(r,c,i.id,U,t,R.filters)),{dashboardData:{token:o,id:l,reportId:s,name:h.name,description:h.description,reportName:p.name,bookmarked:u?await u.isBookmarked(l,s,i.id):!1,nestedBaseUrl:n,csrfToken:a,sections:U,filters:R,type:S.ReportType.DASHBOARD,actions:G(h,p,k)}}};var j={renderAsyncDashboard:B};0&&(module.exports={renderAsyncDashboard});
1
+ "use strict";var M=Object.create;var y=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var Q=(e,t)=>{for(var r in t)y(e,r,{get:t[r],enumerable:!0})},E=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _(t))!H.call(e,o)&&o!==r&&y(e,o,{get:()=>t[o],enumerable:!(a=O(t,o))||a.enumerable});return e};var d=(e,t,r)=>(r=e!=null?M(v(e)):{},E(t||!e||!e.__esModule?y(r,"default",{value:e,enumerable:!0}):r,e)),G=e=>E(y({},"__esModule",{value:!0}),e);var K={};Q(K,{default:()=>z,renderAsyncDashboard:()=>N});module.exports=G(K);var m=require("../../../../../components/_dashboards/dashboard-visualisation/types"),S=require("../../../../../types/UserReports"),b=d(require("../../../../../components/_charts/utils")),w=d(require("../../../../../utils/definitionUtils")),V=d(require("../../../../../components/user-reports/utils")),P=d(require("../../../../../components/_dashboards/dashboard-list/utils")),g=d(require("../../../../../components/_filters/utils")),F=d(require("../../../../../components/_dashboards/scorecard/utils")),I=d(require("../../../../../components/_dashboards/scorecard/Scorecard")),C=d(require("../../../../../components/_reports/report-actions/utils")),B=d(require("../../../../../types/ReportQuery")),A=d(require("../../../../../utils/localsHelper")),L=require("../../../../../components/_filters/filtersTypeEnum");const J=(e,t,r)=>{const a=t.name,{name:o}=e,i=r?.url?.request?.fullUrl,c=r?.executionId;let s={};return i&&(s={share:{reportName:a,name:o,url:i},copy:{url:i}},c&&(s={...s,refresh:{url:i,executionId:c}})),C.default.getActions(s)},W=async({req:e,res:t,services:r,queryData:a})=>{const{token:o}=A.default.getValues(t),{reportId:i,id:c}=e.params,s=e.query.dataProductDefinitionsPath,p=await r.dashboardService.getDefinition(o,i,c,s,a),n=await w.default.getReportSummary(i,r.reportingService,o,s),u=await g.default.getFilters({fields:p.filterFields||[],req:e,filtersType:L.FiltersType.INTERACTIVE}),f=g.default.setRequestQueryFromFilterValues(u.filters);return{query:new B.default({fields:p.filterFields||[],queryParams:f,definitionsPath:s,reportType:S.ReportType.DASHBOARD}).toRecordWithFilterPrefix(!0),filters:u,dashboardDefinition:p,reportDefinition:n}},X=(e,t,r)=>e.sections.map(a=>{const{id:o,display:i,description:c}=a;let s=!1;const p=a.visualisations.map(n=>{const{type:u,display:f,description:R,id:D}=n;let l;switch(u){case m.DashboardVisualisationType.LIST:l=P.default.createList(n,t);break;case m.DashboardVisualisationType.SCORECARD:s=!0,l=new I.default(t,n).build();break;case m.DashboardVisualisationType.SCORECARD_GROUP:l=new I.default(t,n,!0).build();break;case m.DashboardVisualisationType.BAR:case m.DashboardVisualisationType.LINE:case m.DashboardVisualisationType.DONUT:{l=b.default.createChart(n,t);break}case m.DashboardVisualisationType.MATRIX_TIMESERIES:{l=b.default.createMatrixChart(n,t,r);break}case m.DashboardVisualisationType.BAR_TIMESERIES:case m.DashboardVisualisationType.LINE_TIMESERIES:{l=b.default.createTimeseriesCharts(n,t);break}default:break}return{id:D,title:f||"",description:R||"",type:u,data:l}});return s&&F.default.mergeScorecardsIntoGroup(p),{id:o,title:i||"",description:c||"",visualisations:p}}),j=async(e,t,r,a,o,i)=>{const{requestedReportService:c}=e,s=await c.getReportByTableId(t,r);return a&&a.length&&s&&V.default.updateLastViewed({services:e,reportStateData:s,userId:r,req:o,filters:i}),s},N=async({req:e,res:t,services:r})=>{const{token:a,csrfToken:o,dprUser:i,nestedBaseUrl:c}=A.default.getValues(t),{reportId:s,id:p,tableId:n}=e.params,{bookmarkService:u,requestedReportService:f}=r,{id:R}=i;let D=await f.getReportByTableId(n,R);const l=D?.query?.data,{query:U,filters:q,reportDefinition:T,dashboardDefinition:h}=await W({req:e,res:t,services:r,queryData:l}),x=(await r.dashboardService.getAsyncDashboard(a,p,s,n,U)).flat(),k=X(h,x,U);return f&&(D=await j(r,n,i.id,k,e,q.filters)),{dashboardData:{token:a,id:p,reportId:s,name:h.name,description:h.description,reportName:T.name,bookmarked:u?await u.isBookmarked(p,s,i.id):!1,nestedBaseUrl:c,csrfToken:o,sections:k,filters:q,type:S.ReportType.DASHBOARD,actions:J(h,T,D)}}};var z={renderAsyncDashboard:N};0&&(module.exports={renderAsyncDashboard});
2
2
  //# sourceMappingURL=utils.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/dpr/routes/journeys/view-report/async/dashboard/utils.ts"],
4
- "sourcesContent": ["import { Request } from 'express'\nimport { Services } from '../../../../../types/Services'\nimport {\n DashboardSection,\n DashboardVisualisation,\n DashboardVisualisationType,\n} from '../../../../../components/_dashboards/dashboard-visualisation/types'\nimport type { AsyncReportUtilsParams } from '../../../../../types/AsyncReportUtils'\n\nimport type { DashboardDataResponse } from '../../../../../types/Metrics'\nimport type { RequestedReport } from '../../../../../types/UserReports'\nimport { ReportType } from '../../../../../types/UserReports'\nimport type { components } from '../../../../../types/api'\n\nimport ChartUtils from '../../../../../components/_charts/utils'\nimport DefinitionUtils from '../../../../../utils/definitionUtils'\nimport UserReportsUtils from '../../../../../components/user-reports/utils'\nimport DashboardListUtils from '../../../../../components/_dashboards/dashboard-list/utils'\nimport FilterUtils from '../../../../../components/_filters/utils'\nimport ScorecardsUtils from '../../../../../components/_dashboards/scorecard/utils'\nimport ScorecardVisualisation from '../../../../../components/_dashboards/scorecard/Scorecard'\nimport ReportActionsUtils from '../../../../../components/_reports/report-actions/utils'\nimport ReportQuery from '../../../../../types/ReportQuery'\nimport LocalsHelper from '../../../../../utils/localsHelper'\nimport { FilterValue } from '../../../../../components/_filters/types'\nimport { FiltersType } from '../../../../../components/_filters/filtersTypeEnum'\n\nconst setDashboardActions = (\n dashboardDefinition: components['schemas']['DashboardDefinition'],\n reportDefinition: components['schemas']['ReportDefinitionSummary'],\n requestData?: RequestedReport,\n) => {\n const reportName = reportDefinition.name\n const { name } = dashboardDefinition\n const actionsUrl = requestData?.url?.request?.fullUrl\n const executionId = requestData?.executionId\n\n let actions = {}\n if (actionsUrl) {\n actions = {\n share: {\n reportName,\n name,\n url: actionsUrl,\n },\n copy: {\n url: actionsUrl,\n },\n }\n if (executionId) {\n actions = {\n ...actions,\n refresh: {\n url: actionsUrl,\n executionId,\n },\n }\n }\n }\n\n return ReportActionsUtils.getActions(actions)\n}\n\nconst getDefinitionData = async ({ req, res, services }: AsyncReportUtilsParams) => {\n const { token } = LocalsHelper.getValues(res)\n const { reportId, id } = req.params\n const dataProductDefinitionsPath = <string>req.query['dataProductDefinitionsPath']\n\n // Dashboard Definition,\n const dashboardDefinition: components['schemas']['DashboardDefinition'] =\n await services.dashboardService.getDefinition(token, reportId, id, dataProductDefinitionsPath)\n\n // Report summary data\n const reportDefinition = await DefinitionUtils.getReportSummary(\n reportId,\n services.reportingService,\n token,\n <string>dataProductDefinitionsPath,\n )\n\n // Get the filters\n const filtersData = await FilterUtils.getFilters({\n fields: dashboardDefinition.filterFields || [],\n req,\n filtersType: FiltersType.INTERACTIVE,\n })\n\n const filtersQuery = FilterUtils.setRequestQueryFromFilterValues(filtersData.filters)\n\n // Create the query\n const query = new ReportQuery({\n fields: dashboardDefinition.filterFields || [],\n queryParams: filtersQuery,\n definitionsPath: <string>dataProductDefinitionsPath,\n reportType: ReportType.DASHBOARD,\n }).toRecordWithFilterPrefix(true)\n\n return {\n query,\n filters: filtersData,\n dashboardDefinition,\n reportDefinition,\n }\n}\n\nconst getSections = (\n dashboardDefinition: components['schemas']['DashboardDefinition'],\n dashboardData: DashboardDataResponse[],\n query: Record<string, string | string[]>,\n): DashboardSection[] => {\n return dashboardDefinition.sections.map((section: components['schemas']['DashboardSectionDefinition']) => {\n const { id, display: title, description } = section\n\n let hasScorecard = false\n const visualisations: DashboardVisualisation[] = section.visualisations.map(\n (visDefinition: components['schemas']['DashboardVisualisationDefinition']) => {\n const { type, display, description: visDescription, id: visId } = visDefinition\n\n let data: DashboardVisualisation['data'] | undefined\n\n switch (type) {\n case DashboardVisualisationType.LIST:\n data = DashboardListUtils.createList(visDefinition, dashboardData)\n break\n\n case DashboardVisualisationType.SCORECARD:\n hasScorecard = true\n data = new ScorecardVisualisation(dashboardData, visDefinition).build()\n break\n\n case DashboardVisualisationType.SCORECARD_GROUP:\n data = new ScorecardVisualisation(dashboardData, visDefinition, true).build()\n break\n\n case DashboardVisualisationType.BAR:\n case DashboardVisualisationType.LINE:\n case DashboardVisualisationType.DONUT: {\n data = ChartUtils.createChart(visDefinition, dashboardData)\n break\n }\n case DashboardVisualisationType.MATRIX_TIMESERIES: {\n data = ChartUtils.createMatrixChart(visDefinition, dashboardData, query)\n break\n }\n case DashboardVisualisationType.BAR_TIMESERIES:\n case DashboardVisualisationType.LINE_TIMESERIES: {\n data = ChartUtils.createTimeseriesCharts(visDefinition, dashboardData)\n break\n }\n default:\n break\n }\n\n return {\n id: visId,\n title: display || '',\n description: visDescription || '',\n type,\n data,\n }\n },\n )\n\n if (hasScorecard) ScorecardsUtils.mergeScorecardsIntoGroup(visualisations)\n\n return { id, title: title || '', description: description || '', visualisations }\n })\n}\n\nconst updateStore = async (\n services: Services,\n tableId: string,\n userId: string,\n sections: DashboardSection[],\n req: Request,\n filters: FilterValue[],\n): Promise<RequestedReport | undefined> => {\n const { requestedReportService } = services\n const dashboardRequestData = requestedReportService\n ? await requestedReportService.getReportByTableId(tableId, userId)\n : undefined\n\n // Add to recently viewed\n if (sections && sections.length && dashboardRequestData) {\n UserReportsUtils.updateLastViewed({\n services,\n reportStateData: dashboardRequestData,\n userId,\n req,\n filters,\n })\n }\n\n return dashboardRequestData\n}\n\nexport const renderAsyncDashboard = async ({ req, res, services }: AsyncReportUtilsParams) => {\n const { token, csrfToken, dprUser, nestedBaseUrl } = LocalsHelper.getValues(res)\n const { reportId, id, tableId } = req.params\n const { bookmarkService, requestedReportService } = services\n\n // Get the definition Data\n const { query, filters, reportDefinition, dashboardDefinition } = await getDefinitionData({\n req,\n res,\n services,\n })\n\n // Get the results data\n const dashboardData: DashboardDataResponse[][] = await services.dashboardService.getAsyncDashboard(\n token,\n id,\n reportId,\n tableId,\n query,\n )\n\n const flattenedData: DashboardDataResponse[] = dashboardData.flat()\n\n // Get the dashboard parts\n const sections: DashboardSection[] = getSections(dashboardDefinition, flattenedData, query)\n\n // Update the store\n let dashboardRequestData\n if (requestedReportService) {\n dashboardRequestData = await updateStore(services, tableId, dprUser.id, sections, req, filters.filters)\n }\n\n return {\n dashboardData: {\n token,\n id,\n reportId,\n name: dashboardDefinition.name,\n description: dashboardDefinition.description,\n reportName: reportDefinition.name,\n bookmarked: bookmarkService ? await bookmarkService.isBookmarked(id, reportId, dprUser.id) : false,\n nestedBaseUrl,\n csrfToken,\n sections,\n filters,\n type: ReportType.DASHBOARD,\n actions: setDashboardActions(dashboardDefinition, reportDefinition, dashboardRequestData),\n },\n }\n}\n\nexport default {\n renderAsyncDashboard,\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,yBAAAC,IAAA,eAAAC,EAAAJ,GAEA,IAAAK,EAIO,+EAKPC,EAA2B,4CAG3BC,EAAuB,sDACvBC,EAA4B,mDAC5BD,EAA6B,2DAC7BA,EAA+B,yEAC/BA,EAAwB,uDACxBA,EAA4B,oEAC5BE,EAAmC,wEACnCF,EAA+B,sEAC/BG,EAAwB,+CACxBC,EAAyB,gDAEzBC,EAA4B,8DAE5B,MAAMC,EAAsB,CAC1BC,EACAC,EACAC,IACG,CACH,MAAMC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["utils_exports", "__export", "utils_default", "renderAsyncDashboard", "__toCommonJS", "import_types", "import_UserReports", "import_utils", "import_definitionUtils", "import_Scorecard", "import_ReportQuery", "import_localsHelper", "import_filtersTypeEnum", "setDashboardActions", "dashboardDefinition", "reportDefinition", "requestData", "reportName", "name", "actionsUrl", "executionId", "actions", "ReportActionsUtils", "getDefinitionData", "req", "res", "services", "token", "LocalsHelper", "reportId", "id", "dataProductDefinitionsPath", "DefinitionUtils", "filtersData", "FilterUtils", "filtersQuery", "ReportQuery", "getSections", "dashboardData", "query", "section", "title", "description", "hasScorecard", "visualisations", "visDefinition", "type", "display", "visDescription", "visId", "data", "DashboardListUtils", "ScorecardVisualisation", "ChartUtils", "ScorecardsUtils", "updateStore", "tableId", "userId", "sections", "filters", "requestedReportService", "dashboardRequestData", "UserReportsUtils", "csrfToken", "dprUser", "nestedBaseUrl", "bookmarkService", "flattenedData"]
4
+ "sourcesContent": ["import { Request, Response } from 'express'\nimport { Services } from '../../../../../types/Services'\nimport Dict = NodeJS.Dict\nimport {\n DashboardSection,\n DashboardVisualisation,\n DashboardVisualisationType,\n} from '../../../../../components/_dashboards/dashboard-visualisation/types'\nimport type { AsyncReportUtilsParams } from '../../../../../types/AsyncReportUtils'\n\nimport type { DashboardDataResponse } from '../../../../../types/Metrics'\nimport type { RequestedReport } from '../../../../../types/UserReports'\nimport { ReportType } from '../../../../../types/UserReports'\nimport type { components } from '../../../../../types/api'\n\nimport ChartUtils from '../../../../../components/_charts/utils'\nimport DefinitionUtils from '../../../../../utils/definitionUtils'\nimport UserReportsUtils from '../../../../../components/user-reports/utils'\nimport DashboardListUtils from '../../../../../components/_dashboards/dashboard-list/utils'\nimport FilterUtils from '../../../../../components/_filters/utils'\nimport ScorecardsUtils from '../../../../../components/_dashboards/scorecard/utils'\nimport ScorecardVisualisation from '../../../../../components/_dashboards/scorecard/Scorecard'\nimport ReportActionsUtils from '../../../../../components/_reports/report-actions/utils'\nimport ReportQuery from '../../../../../types/ReportQuery'\nimport LocalsHelper from '../../../../../utils/localsHelper'\nimport { FilterValue } from '../../../../../components/_filters/types'\nimport { FiltersType } from '../../../../../components/_filters/filtersTypeEnum'\n\nconst setDashboardActions = (\n dashboardDefinition: components['schemas']['DashboardDefinition'],\n reportDefinition: components['schemas']['ReportDefinitionSummary'],\n requestData?: RequestedReport,\n) => {\n const reportName = reportDefinition.name\n const { name } = dashboardDefinition\n const actionsUrl = requestData?.url?.request?.fullUrl\n const executionId = requestData?.executionId\n\n let actions = {}\n if (actionsUrl) {\n actions = {\n share: {\n reportName,\n name,\n url: actionsUrl,\n },\n copy: {\n url: actionsUrl,\n },\n }\n if (executionId) {\n actions = {\n ...actions,\n refresh: {\n url: actionsUrl,\n executionId,\n },\n }\n }\n }\n\n return ReportActionsUtils.getActions(actions)\n}\n\nconst getDefinitionData = async ({\n req,\n res,\n services,\n queryData,\n}: {\n req: Request\n res: Response\n services: Services\n queryData: Dict<string | string[]> | undefined\n}) => {\n const { token } = LocalsHelper.getValues(res)\n const { reportId, id } = req.params\n const dataProductDefinitionsPath = <string>req.query['dataProductDefinitionsPath']\n\n // Dashboard Definition,\n const dashboardDefinition: components['schemas']['DashboardDefinition'] =\n await services.dashboardService.getDefinition(token, reportId, id, dataProductDefinitionsPath, queryData)\n\n // Report summary data\n const reportDefinition = await DefinitionUtils.getReportSummary(\n reportId,\n services.reportingService,\n token,\n <string>dataProductDefinitionsPath,\n )\n\n // Get the filters\n const filtersData = await FilterUtils.getFilters({\n fields: dashboardDefinition.filterFields || [],\n req,\n filtersType: FiltersType.INTERACTIVE,\n })\n\n const filtersQuery = FilterUtils.setRequestQueryFromFilterValues(filtersData.filters)\n\n // Create the query\n const query = new ReportQuery({\n fields: dashboardDefinition.filterFields || [],\n queryParams: filtersQuery,\n definitionsPath: <string>dataProductDefinitionsPath,\n reportType: ReportType.DASHBOARD,\n }).toRecordWithFilterPrefix(true)\n\n return {\n query,\n filters: filtersData,\n dashboardDefinition,\n reportDefinition,\n }\n}\n\nconst getSections = (\n dashboardDefinition: components['schemas']['DashboardDefinition'],\n dashboardData: DashboardDataResponse[],\n query: Record<string, string | string[]>,\n): DashboardSection[] => {\n return dashboardDefinition.sections.map((section: components['schemas']['DashboardSectionDefinition']) => {\n const { id, display: title, description } = section\n\n let hasScorecard = false\n const visualisations: DashboardVisualisation[] = section.visualisations.map(\n (visDefinition: components['schemas']['DashboardVisualisationDefinition']) => {\n const { type, display, description: visDescription, id: visId } = visDefinition\n\n let data: DashboardVisualisation['data'] | undefined\n\n switch (type) {\n case DashboardVisualisationType.LIST:\n data = DashboardListUtils.createList(visDefinition, dashboardData)\n break\n\n case DashboardVisualisationType.SCORECARD:\n hasScorecard = true\n data = new ScorecardVisualisation(dashboardData, visDefinition).build()\n break\n\n case DashboardVisualisationType.SCORECARD_GROUP:\n data = new ScorecardVisualisation(dashboardData, visDefinition, true).build()\n break\n\n case DashboardVisualisationType.BAR:\n case DashboardVisualisationType.LINE:\n case DashboardVisualisationType.DONUT: {\n data = ChartUtils.createChart(visDefinition, dashboardData)\n break\n }\n case DashboardVisualisationType.MATRIX_TIMESERIES: {\n data = ChartUtils.createMatrixChart(visDefinition, dashboardData, query)\n break\n }\n case DashboardVisualisationType.BAR_TIMESERIES:\n case DashboardVisualisationType.LINE_TIMESERIES: {\n data = ChartUtils.createTimeseriesCharts(visDefinition, dashboardData)\n break\n }\n default:\n break\n }\n\n return {\n id: visId,\n title: display || '',\n description: visDescription || '',\n type,\n data,\n }\n },\n )\n\n if (hasScorecard) ScorecardsUtils.mergeScorecardsIntoGroup(visualisations)\n\n return { id, title: title || '', description: description || '', visualisations }\n })\n}\n\nconst updateStore = async (\n services: Services,\n tableId: string,\n userId: string,\n sections: DashboardSection[],\n req: Request,\n filters: FilterValue[],\n): Promise<RequestedReport | undefined> => {\n const { requestedReportService } = services\n const dashboardRequestData = await requestedReportService.getReportByTableId(tableId, userId)\n\n // Add to recently viewed\n if (sections && sections.length && dashboardRequestData) {\n UserReportsUtils.updateLastViewed({\n services,\n reportStateData: dashboardRequestData,\n userId,\n req,\n filters,\n })\n }\n\n return dashboardRequestData\n}\n\nexport const renderAsyncDashboard = async ({ req, res, services }: AsyncReportUtilsParams) => {\n const { token, csrfToken, dprUser, nestedBaseUrl } = LocalsHelper.getValues(res)\n const { reportId, id, tableId } = req.params\n const { bookmarkService, requestedReportService } = services\n const { id: userId } = dprUser\n\n let requestData: RequestedReport | undefined = await requestedReportService.getReportByTableId(tableId, userId)\n const queryData = requestData?.query?.data\n\n // Get the definition Data\n const { query, filters, reportDefinition, dashboardDefinition } = await getDefinitionData({\n req,\n res,\n services,\n queryData,\n })\n\n // Get the results data\n const dashboardData: DashboardDataResponse[][] = await services.dashboardService.getAsyncDashboard(\n token,\n id,\n reportId,\n tableId,\n query,\n )\n\n const flattenedData: DashboardDataResponse[] = dashboardData.flat()\n\n // Get the dashboard parts\n const sections: DashboardSection[] = getSections(dashboardDefinition, flattenedData, query)\n\n // Update the store\n if (requestedReportService) {\n requestData = await updateStore(services, tableId, dprUser.id, sections, req, filters.filters)\n }\n\n return {\n dashboardData: {\n token,\n id,\n reportId,\n name: dashboardDefinition.name,\n description: dashboardDefinition.description,\n reportName: reportDefinition.name,\n bookmarked: bookmarkService ? await bookmarkService.isBookmarked(id, reportId, dprUser.id) : false,\n nestedBaseUrl,\n csrfToken,\n sections,\n filters,\n type: ReportType.DASHBOARD,\n actions: setDashboardActions(dashboardDefinition, reportDefinition, requestData),\n },\n }\n}\n\nexport default {\n renderAsyncDashboard,\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,yBAAAC,IAAA,eAAAC,EAAAJ,GAGA,IAAAK,EAIO,+EAKPC,EAA2B,4CAG3BC,EAAuB,sDACvBC,EAA4B,mDAC5BD,EAA6B,2DAC7BA,EAA+B,yEAC/BA,EAAwB,uDACxBA,EAA4B,oEAC5BE,EAAmC,wEACnCF,EAA+B,sEAC/BG,EAAwB,+CACxBC,EA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C,EAAID,EAAUmC,EAAQ,EAAE,EAAI,GAC7F,cAAAC,EACA,UAAAF,EACA,SAAAL,EACA,QAAAC,EACA,KAAM,aAAW,UACjB,QAAS/C,EAAoBC,EAAqBC,EAAkBC,CAAW,CACjF,CACF,CACF,EAEA,IAAOd,EAAQ,CACb,qBAAAC,CACF",
6
+ "names": ["utils_exports", "__export", "utils_default", "renderAsyncDashboard", "__toCommonJS", "import_types", "import_UserReports", "import_utils", "import_definitionUtils", "import_Scorecard", "import_ReportQuery", "import_localsHelper", "import_filtersTypeEnum", "setDashboardActions", "dashboardDefinition", "reportDefinition", "requestData", "reportName", "name", "actionsUrl", "executionId", "actions", "ReportActionsUtils", "getDefinitionData", "req", "res", "services", "queryData", "token", "LocalsHelper", "reportId", "id", "dataProductDefinitionsPath", "DefinitionUtils", "filtersData", "FilterUtils", "filtersQuery", "ReportQuery", "getSections", "dashboardData", "query", "section", "title", "description", "hasScorecard", "visualisations", "visDefinition", "type", "display", "visDescription", "visId", "data", "DashboardListUtils", "ScorecardVisualisation", "ChartUtils", "ScorecardsUtils", "updateStore", "tableId", "userId", "sections", "filters", "requestedReportService", "dashboardRequestData", "UserReportsUtils", "csrfToken", "dprUser", "nestedBaseUrl", "bookmarkService", "flattenedData"]
7
7
  }
@@ -1,5 +1,6 @@
1
- import { Request } from 'express'
1
+ import { Request, Response } from 'express'
2
2
  import { Services } from '../../../../../types/Services'
3
+ import Dict = NodeJS.Dict
3
4
  import {
4
5
  DashboardSection,
5
6
  DashboardVisualisation,
@@ -61,14 +62,24 @@ const setDashboardActions = (
61
62
  return ReportActionsUtils.getActions(actions)
62
63
  }
63
64
 
64
- const getDefinitionData = async ({ req, res, services }: AsyncReportUtilsParams) => {
65
+ const getDefinitionData = async ({
66
+ req,
67
+ res,
68
+ services,
69
+ queryData,
70
+ }: {
71
+ req: Request
72
+ res: Response
73
+ services: Services
74
+ queryData: Dict<string | string[]> | undefined
75
+ }) => {
65
76
  const { token } = LocalsHelper.getValues(res)
66
77
  const { reportId, id } = req.params
67
78
  const dataProductDefinitionsPath = <string>req.query['dataProductDefinitionsPath']
68
79
 
69
80
  // Dashboard Definition,
70
81
  const dashboardDefinition: components['schemas']['DashboardDefinition'] =
71
- await services.dashboardService.getDefinition(token, reportId, id, dataProductDefinitionsPath)
82
+ await services.dashboardService.getDefinition(token, reportId, id, dataProductDefinitionsPath, queryData)
72
83
 
73
84
  // Report summary data
74
85
  const reportDefinition = await DefinitionUtils.getReportSummary(
@@ -176,9 +187,7 @@ const updateStore = async (
176
187
  filters: FilterValue[],
177
188
  ): Promise<RequestedReport | undefined> => {
178
189
  const { requestedReportService } = services
179
- const dashboardRequestData = requestedReportService
180
- ? await requestedReportService.getReportByTableId(tableId, userId)
181
- : undefined
190
+ const dashboardRequestData = await requestedReportService.getReportByTableId(tableId, userId)
182
191
 
183
192
  // Add to recently viewed
184
193
  if (sections && sections.length && dashboardRequestData) {
@@ -198,12 +207,17 @@ export const renderAsyncDashboard = async ({ req, res, services }: AsyncReportUt
198
207
  const { token, csrfToken, dprUser, nestedBaseUrl } = LocalsHelper.getValues(res)
199
208
  const { reportId, id, tableId } = req.params
200
209
  const { bookmarkService, requestedReportService } = services
210
+ const { id: userId } = dprUser
211
+
212
+ let requestData: RequestedReport | undefined = await requestedReportService.getReportByTableId(tableId, userId)
213
+ const queryData = requestData?.query?.data
201
214
 
202
215
  // Get the definition Data
203
216
  const { query, filters, reportDefinition, dashboardDefinition } = await getDefinitionData({
204
217
  req,
205
218
  res,
206
219
  services,
220
+ queryData,
207
221
  })
208
222
 
209
223
  // Get the results data
@@ -221,9 +235,8 @@ export const renderAsyncDashboard = async ({ req, res, services }: AsyncReportUt
221
235
  const sections: DashboardSection[] = getSections(dashboardDefinition, flattenedData, query)
222
236
 
223
237
  // Update the store
224
- let dashboardRequestData
225
238
  if (requestedReportService) {
226
- dashboardRequestData = await updateStore(services, tableId, dprUser.id, sections, req, filters.filters)
239
+ requestData = await updateStore(services, tableId, dprUser.id, sections, req, filters.filters)
227
240
  }
228
241
 
229
242
  return {
@@ -240,7 +253,7 @@ export const renderAsyncDashboard = async ({ req, res, services }: AsyncReportUt
240
253
  sections,
241
254
  filters,
242
255
  type: ReportType.DASHBOARD,
243
- actions: setDashboardActions(dashboardDefinition, reportDefinition, dashboardRequestData),
256
+ actions: setDashboardActions(dashboardDefinition, reportDefinition, requestData),
244
257
  },
245
258
  }
246
259
  }
@@ -1,2 +1,2 @@
1
- "use strict";var x=Object.create;var b=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var g=(n,a,s,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let i of v(a))!V.call(n,i)&&i!==s&&b(n,i,{get:()=>a[i],enumerable:!(o=B(a,i))||o.enumerable});return n};var w=(n,a,s)=>(s=n!=null?x(F(n)):{},g(a||!n||!n.__esModule?b(s,"default",{value:n,enumerable:!0}):s,n));var l=require("../../../../../../../cypress-tests/cypressUtils"),f=w(require("../../../../../utils/DateMapper/DateMapper"));context("Viewing a report",()=>{const n="/embedded/platform/";let a,s;describe("List report page",()=>{before(()=>{(0,l.executeReportStubs)(),cy.task("stubDefinitionRequestExamplesSuccess"),cy.task("stubRequestSuccessResult10"),cy.task("stubRequestSuccessResult20"),cy.task("stubRequestSuccessResult100"),(0,l.requestReport)({name:"Successful Report",description:"this will succeed",path:n}),cy.url().then(o=>{a=o;const i=o.split("/");s=i[i.length-2]})}),beforeEach(()=>{cy.visit(a)}),describe("Report details",()=>{it("should show the report details",()=>{cy.findAllByRole("group").contains("Report details").should("be.visible").click(),cy.findAllByRole("group").contains("Report details").parent().parent().within(()=>{cy.findAllByRole("row").each((o,i)=>{cy.wrap(o).within(()=>{switch(i){case 0:cy.findAllByRole("cell",{name:"Name:"}).should("exist"),cy.findAllByRole("cell",{name:"Successful Report"}).should("exist");break;case 1:cy.findAllByRole("cell",{name:"Product:"}).should("exist"),cy.findAllByRole("cell",{name:"Successful Report"}).should("exist");break;case 2:cy.findAllByRole("cell",{name:"Description:"}).should("exist"),cy.findAllByRole("cell",{name:"this will succeed"}).should("exist");break;case 3:cy.findAllByRole("cell",{name:"Classification:"}).should("exist"),cy.findAllByRole("cell",{name:"OFFICIAL"}).should("exist");break;case 4:cy.findAllByRole("cell",{name:"Requested at:"}).should("exist"),cy.findAllByRole("cell",{name:/\d{1,2}\/\d{1,2}\/\d{2,4}/}).should("exist");break;case 5:cy.findAllByRole("cell",{name:"Applied Filters:"}).should("exist"),cy.findAllByRole("listitem").each((c,e)=>{switch(e){case 0:cy.wrap(c).contains("Field 1: value1.2");break;case 1:cy.wrap(c).contains("Field 3 start: 01/02/2003");break;case 2:cy.wrap(c).contains("Field 3 end: 04/05/2006");break;case 3:cy.wrap(c).contains("Field 7: 01/02/2005");break;case 4:cy.wrap(c).contains("Field 8: value8.2,value8.3");break;case 5:cy.wrap(c).contains("Sort column: Field 1");break;case 6:cy.wrap(c).contains("Sort direction: Descending");break;default:break}});break;default:break}})})})})}),describe("Actions",()=>{it("should show the actions and go to the filters page when refresh action is clicked",()=>{cy.findByLabelText("Refresh report").should("be.visible"),cy.findByLabelText(/Print screen/).should("be.visible").should("be.disabled"),cy.findByLabelText(/download/).should("be.visible"),cy.findByLabelText(/Copy report link/).should("be.visible"),cy.findByRole("button",{name:/Add bookmark/}).should("be.visible"),cy.findByLabelText("Refresh report").should("be.visible").click(),cy.url().should("match",/.*\/embedded\/platform\/dpr\/request-report\/report\/request-examples\/request-example-success\/filters/i),cy.location().should(o=>{expect(o.search).to.contain("filters.field1=value1.2"),expect(o.search).to.contain("filters.field3.start=2003-02-01"),expect(o.search).to.contain("filters.field3.end=2006-05-04"),expect(o.search).to.contain("filters.field7=2005-02-01"),expect(o.search).to.contain("filters.field8=value8.2&filters.field8=value8.3")})})}),describe("Column interactions",()=>{const o=()=>{cy.findByRole("checkbox",{name:"Field 1"}).should("be.checked"),cy.findByRole("checkbox",{name:"Field 2"}).should("be.checked").should("be.disabled"),cy.findByRole("checkbox",{name:"Field 3"}).should("be.checked"),cy.findByRole("checkbox",{name:"Field 4"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 5"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 6"}).should("be.checked").should("be.disabled"),cy.findByRole("checkbox",{name:"Field 7"}).should("be.checked"),cy.findByRole("checkbox",{name:"Field 8"}).should("not.be.checked"),cy.location().should(e=>{expect(e.search).to.contain("columns=field1"),expect(e.search).to.contain("columns=field2"),expect(e.search).to.contain("columns=field3"),expect(e.search).not.to.contain("columns=field4"),expect(e.search).not.to.contain("columns=field5"),expect(e.search).to.contain("columns=field6"),expect(e.search).to.contain("columns=field7"),expect(e.search).not.to.contain("columns=field8")}),cy.findByLabelText(/Successful Report/).within(()=>{cy.findAllByRole("rowgroup").eq(0).within(()=>{cy.findAllByRole("row").eq(1).within(()=>{cy.findAllByRole("columnheader").should("have.length",5)})})})},i=()=>{cy.findByRole("checkbox",{name:"Field 1"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 2"}).should("be.checked").should("be.disabled"),cy.findByRole("checkbox",{name:"Field 3"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 4"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 5"}).should("be.checked"),cy.findByRole("checkbox",{name:"Field 6"}).should("be.checked").should("be.disabled"),cy.findByRole("checkbox",{name:"Field 7"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 8"}).should("be.checked"),cy.location().should(e=>{expect(e.search).not.to.contain("columns=field1"),expect(e.search).to.contain("columns=field2"),expect(e.search).not.to.contain("columns=field3"),expect(e.search).not.to.contain("columns=field4"),expect(e.search).to.contain("columns=field5"),expect(e.search).to.contain("columns=field6"),expect(e.search).not.to.contain("columns=field7"),expect(e.search).to.contain("columns=field8")}),cy.findByLabelText(/Successful Report/).within(()=>{cy.findAllByRole("rowgroup").eq(0).within(()=>{cy.findAllByRole("row").eq(1).within(()=>{cy.findAllByRole("columnheader").should("have.length",4)})})})},c=()=>{cy.findByRole("checkbox",{name:"Field 1"}).uncheck(),cy.findByRole("checkbox",{name:"Field 3"}).uncheck(),cy.findByRole("checkbox",{name:"Field 5"}).check(),cy.findByRole("checkbox",{name:"Field 7"}).uncheck(),cy.findByRole("checkbox",{name:"Field 8"}).check()};it("should initialise the column content correctly",()=>{cy.findAllByRole("group").contains(/Show columns/).should("be.visible").click(),o(),cy.findAllByRole("group").contains("Show columns (5 of 8 shown)"),cy.findByLabelText(/Successful Report/).within(()=>{cy.findAllByRole("rowgroup").eq(0).within(()=>{cy.findAllByRole("columnheader").each((e,d)=>{switch(d){case 0:cy.wrap(e).contains("Field 1");break;case 1:cy.wrap(e).contains("Field 2");break;case 2:cy.wrap(e).contains("Field 3");break;case 3:cy.wrap(e).contains("Field 6");break;case 4:cy.wrap(e).contains("Field 7");break;default:break}})})})}),it("should apply the columns",()=>{cy.findAllByRole("group").contains(/Show columns/).click(),c(),cy.findByRole("button",{name:"Apply columns"}).click(),i(),cy.findByLabelText(/Successful Report/).within(()=>{cy.findAllByRole("rowgroup").eq(0).within(()=>{cy.findAllByRole("columnheader").each((e,d)=>{switch(d){case 0:cy.wrap(e).contains("Field 2");break;case 1:cy.wrap(e).contains("Field 5");break;case 2:cy.wrap(e).contains("Field 6");break;case 3:cy.wrap(e).contains("Field 8");break;default:break}})})})}),it("should reset the columns to their DPD defaults",()=>{cy.findAllByRole("group").contains(/Show columns/).click(),c(),cy.findByRole("button",{name:"Apply columns"}).click(),i(),cy.findAllByRole("group").contains(/Show columns/).click(),cy.findByRole("link",{name:"Reset columns"}).click(),o()}),it("should apply the columns from the URL",()=>{cy.visit(`/embedded/platform/dpr/view-report/async/report/request-examples/request-example-success/${s}/report?columns=field1&columns=field5&columns=field8`),cy.findByRole("checkbox",{name:"Field 1"}).should("be.checked"),cy.findByRole("checkbox",{name:"Field 2"}).should("be.checked").should("be.disabled"),cy.findByRole("checkbox",{name:"Field 3"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 4"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 5"}).should("be.checked"),cy.findByRole("checkbox",{name:"Field 6"}).should("be.checked").should("be.disabled"),cy.findByRole("checkbox",{name:"Field 7"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 8"}).should("be.checked"),cy.findByLabelText(/Successful Report/).within(()=>{cy.findAllByRole("rowgroup").eq(0).within(()=>{cy.findAllByRole("columnheader").each((e,d)=>{switch(d){case 0:cy.wrap(e).contains("Field 1");break;case 1:cy.wrap(e).contains("Field 2");break;case 2:cy.wrap(e).contains("Field 5");break;case 3:cy.wrap(e).contains("Field 6");break;case 4:cy.wrap(e).contains("Field 8");break;default:break}})})})}),it("should only apply mandatory columms",()=>{cy.findAllByRole("group").contains(/Show columns/).click(),cy.findByRole("checkbox",{name:"Field 1"}).uncheck(),cy.findByRole("checkbox",{name:"Field 3"}).uncheck(),cy.findByRole("checkbox",{name:"Field 7"}).uncheck(),cy.findByRole("button",{name:"Apply columns"}).click(),cy.findByRole("checkbox",{name:"Field 1"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 2"}).should("be.checked").should("be.disabled"),cy.findByRole("checkbox",{name:"Field 3"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 4"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 5"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 6"}).should("be.checked").should("be.disabled"),cy.findByRole("checkbox",{name:"Field 7"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 8"}).should("not.be.checked"),cy.location().should(e=>{expect(e.search).not.to.contain("columns=field1"),expect(e.search).to.contain("columns=field2"),expect(e.search).not.to.contain("columns=field3"),expect(e.search).not.to.contain("columns=field4"),expect(e.search).not.to.contain("columns=field5"),expect(e.search).to.contain("columns=field6"),expect(e.search).not.to.contain("columns=field7"),expect(e.search).not.to.contain("columns=field8")}),cy.findByLabelText(/Successful Report/).within(()=>{cy.findAllByRole("rowgroup").eq(0).within(()=>{cy.findAllByRole("row").eq(1).within(()=>{cy.findAllByRole("columnheader").should("have.length",2)})})})})}),describe("Paging interaction",()=>{it("should show the table totals",()=>{cy.findAllByRole("paragraph").contains(/Showing \d{1,4} to \d{1,4} of \d{1,4} results/).should("exist"),cy.findByLabelText(/Successful Report/).within(()=>{cy.findAllByRole("rowgroup").eq(1).within(()=>{cy.findAllByRole("row").should("have.length",20)})})}),it("should change the page size",()=>{cy.get("#page-size-select").select("10"),cy.findAllByRole("paragraph").contains(/Showing 1 to 10 of 100 results/).should("exist"),cy.findByLabelText(/Successful Report/).within(()=>{cy.findAllByRole("rowgroup").eq(1).within(()=>{cy.findAllByRole("row").should("have.length",10)})})}),it("should change the page size via the URL",()=>{cy.visit(`/embedded/platform/dpr/view-report/async/report/request-examples/request-example-success/${s}/report?pageSize=100`),cy.findAllByRole("paragraph").contains(/100 total results/).should("exist"),cy.findByLabelText(/Successful Report/).within(()=>{cy.findAllByRole("rowgroup").eq(1).within(()=>{cy.findAllByRole("row").should("have.length",100)})})}),it("should change the page",()=>{cy.findByLabelText("Page 5").click(),cy.location().should(o=>{expect(o.search).to.contain("selectedPage=5")})}),it("should change the page via the URL",()=>{cy.visit(`/embedded/platform/dpr/view-report/async/report/request-examples/request-example-success/${s}/report?selectedPage=3`),cy.findByRole("link",{current:"page"}).contains("3")})})}),describe("Interactive report",()=>{const o=()=>{cy.findByRole("button",{name:"Apply filters"}).click()},i=()=>{cy.findAllByRole("group").contains(/Show filters/).click()};before(()=>{(0,l.executeReportStubs)(),cy.task("stubDefinitionFeatureTestingInteractive"),cy.task("stubAsyncRequestSuccessReportTablesCount"),cy.task("stubRequestSuccessResult20"),cy.task("stubRequestSuccessResult100")}),describe("Apply filters",()=>{before(()=>{(0,l.requestReport)({name:"Interactive Report",description:"this is an interactive report",path:n}),cy.url().then(e=>{a=e})}),beforeEach(()=>{cy.visit(a)});const c=()=>{for(let e=0;e<4;e+=1)cy.findByLabelText("Selected filters").within(()=>{cy.findAllByRole("link").first().click()})};describe("Date range",()=>{it("should apply the date range",()=>{cy.findByRole("textbox",{name:"From"}).should("have.value","01/02/2003"),cy.findByRole("textbox",{name:"To"}).should("have.value","04/05/2006"),c(),i(),cy.findByRole("textbox",{name:"From"}).type("02/05/2025"),cy.findByRole("textbox",{name:"To"}).type("05/07/2025").blur(),o(),cy.location().should(e=>{expect(e.search).to.contain("filters.field3.start=2025-05-02"),expect(e.search).to.contain("filters.field3.end=2025-07-05")}),(0,l.checkSelectedFilterValues)({length:2,buttonValues:[{key:"Field 3",value:"02/05/2025 - 05/07/2025"}]})}),it("should apply the relative daterange",()=>{c(),i(),cy.findByRole("tab",{name:"Preset date ranges"}).click(),cy.findByRole("radio",{name:"Tomorrow"}).check(),o();let e,d;cy.findByRole("textbox",{name:"From"}).invoke("val").should("not.be.empty").then(t=>{e=t}),cy.findByRole("textbox",{name:"To"}).invoke("val").should("not.be.empty").then(t=>{d=t});const u=new f.default;cy.location().should(t=>{expect(t.search).to.contain(`filters.field3.start=${u.toDateString(e,"iso")}`),expect(t.search).to.contain(`filters.field3.end=${u.toDateString(d,"iso")}`),expect(t.search).to.contain("filters.field3.relative-duration=tomorrow")}),(0,l.checkSelectedFilterValues)({length:2,buttonValues:[{key:"Field 3",value:"Tomorrow"}]})})}),describe("Multiselect",()=>{it("should apply the multiselect values",()=>{cy.findByRole("checkbox",{name:"Value 8.2"}).should("be.checked"),cy.findByRole("checkbox",{name:"Value 8.3"}).should("be.checked"),c(),cy.findByRole("checkbox",{name:"Value 8.1"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.2"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.3"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.4"}).should("not.be.checked"),i(),cy.findByRole("checkbox",{name:"Value 8.1"}).check(),cy.findByRole("checkbox",{name:"Value 8.3"}).check(),o(),cy.findByRole("checkbox",{name:"Value 8.1"}).should("be.checked"),cy.findByRole("checkbox",{name:"Value 8.2"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.3"}).should("be.checked"),cy.findByRole("checkbox",{name:"Value 8.4"}).should("not.be.checked"),(0,l.checkSelectedFilterValues)({length:2,buttonValues:[{key:"Field 8",value:"Value 8.1, Value 8.3"}]})}),it("should set the selected filter values correctly",()=>{cy.findByRole("checkbox",{name:"Value 8.2"}).should("be.checked"),cy.findByRole("checkbox",{name:"Value 8.3"}).should("be.checked"),c(),cy.findByRole("checkbox",{name:"Value 8.1"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.2"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.3"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.4"}).should("not.be.checked"),i(),cy.findByRole("checkbox",{name:"Value 8.1"}).check(),cy.findByRole("checkbox",{name:"Value 8.2"}).check(),cy.findByRole("checkbox",{name:"Value 8.3"}).check(),cy.findByRole("checkbox",{name:"Value 8.4"}).check(),o(),cy.findByRole("checkbox",{name:"Value 8.1"}).should("be.checked"),cy.findByRole("checkbox",{name:"Value 8.2"}).should("be.checked"),cy.findByRole("checkbox",{name:"Value 8.3"}).should("be.checked"),cy.findByRole("checkbox",{name:"Value 8.4"}).should("be.checked"),(0,l.checkSelectedFilterValues)({length:2,buttonValues:[{key:"Field 8",value:"Value 8.1, Value 8.2, Value 8.3 + 1 more"}]})}),it("should set the values correctly when only one checkbox selected",()=>{c(),cy.findByRole("checkbox",{name:"Value 8.1"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.2"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.3"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.4"}).should("not.be.checked"),i(),cy.findByRole("checkbox",{name:"Value 8.1"}).check(),o(),cy.findByRole("checkbox",{name:"Value 8.1"}).should("be.checked"),cy.findByRole("checkbox",{name:"Value 8.2"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.3"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.4"}).should("not.be.checked"),(0,l.checkSelectedFilterValues)({length:2,buttonValues:[{key:"Field 8",value:"Value 8.1"}]})})}),it("Applying filters should persist current applied columns",()=>{cy.findAllByRole("group").contains(/Show columns/).should("be.visible").click(),cy.findByRole("checkbox",{name:"Field 1"}).uncheck(),cy.findByRole("checkbox",{name:"Field 3"}).uncheck(),cy.findByRole("checkbox",{name:"Field 5"}).check(),cy.findByRole("checkbox",{name:"Field 7"}).uncheck(),cy.findByRole("checkbox",{name:"Field 8"}).check(),cy.findByRole("button",{name:"Apply columns"}).click(),cy.findAllByRole("group").contains("Show columns (4 of 8 shown)"),i(),cy.findByRole("checkbox",{name:"Value 8.1"}).check(),cy.findByRole("checkbox",{name:"Value 8.3"}).check(),o(),cy.findAllByRole("group").contains("Show columns (4 of 8 shown)")})}),describe("User defined interactive defaults",()=>{const c=()=>cy.findByRole("button",{name:"Save current filter values as defaults"}),e=()=>cy.findByRole("button",{name:"Update defaults"}),d=()=>cy.findByRole("button",{name:"Delete defaults"}),u=({name:t,product:h,length:m,selectedFilters:k})=>{cy.findByLabelText(/Viewed \(/).within(()=>{cy.findByRole("row",{name:(r,y)=>!!y.textContent?.includes(t)&&!!y.textContent?.includes(h)}).within(()=>{cy.findAllByRole("listitem").should("have.length",m).each((r,y)=>{if(k[y]){const{key:p,value:R}=k[y];cy.wrap(r).contains(p),cy.wrap(r).contains(R)}})})})};it("should save the interactive filters correctly",()=>{(0,l.requestReport)({name:"Interactive Report",description:"this is an interactive report",path:n}),(0,l.checkSelectedFilterValues)({length:5,buttonValues:[{key:"Field 1",value:"Value 1.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.2, Value 8.3"}]}),i(),cy.findByRole("checkbox",{name:"Value 8.1"}).check(),cy.findByRole("checkbox",{name:"Value 8.4"}).check(),cy.findByRole("combobox",{name:"Field 2"}).select("value2.2"),o();const t=[{key:"Field 1",value:"Value 1.2"},{key:"Field 2",value:"Value 2.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.1, Value 8.2, Value 8.3 + 1 more"}];(0,l.checkSelectedFilterValues)({length:6,buttonValues:t}),c().click(),e().should("exist"),d().should("exist"),(0,l.checkSelectedFilterValues)({length:6,buttonValues:t})}),it("should init the report with saved interactive defaults",()=>{(0,l.requestReport)({name:"Interactive Report",description:"this is an interactive report",path:n}),cy.url().then(h=>{a=h}),e().should("exist"),d().should("exist");const t=[{key:"Field 1",value:"Value 1.2"},{key:"Field 2",value:"Value 2.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.1, Value 8.2, Value 8.3 + 1 more"}];(0,l.checkSelectedFilterValues)({length:6,buttonValues:t}),cy.visit(n),cy.findByRole("tab",{name:/Viewed/}).click(),u({name:"Interactive Report",product:"Interactive Report",length:5,selectedFilters:t})}),it("should reset the filter values to the saved defaults",()=>{cy.visit(a),e().should("exist"),d().should("exist");const t=[{key:"Field 1",value:"Value 1.2"},{key:"Field 2",value:"Value 2.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.1, Value 8.2, Value 8.3 + 1 more"}];(0,l.checkSelectedFilterValues)({length:6,buttonValues:t}),i(),cy.findByRole("checkbox",{name:"Value 8.1"}).uncheck(),cy.findByRole("checkbox",{name:"Value 8.3"}).uncheck(),cy.findByRole("combobox",{name:"Field 2"}).select("value2.3"),o(),(0,l.checkSelectedFilterValues)({length:6,buttonValues:[{key:"Field 1",value:"Value 1.2"},{key:"Field 2",value:"Value 2.3"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.4"}]}),cy.visit(n),cy.findByRole("tab",{name:/Viewed/}).click(),u({name:"Interactive Report",product:"Interactive Report",length:5,selectedFilters:[{key:"Field 1",value:"Value 1.2"},{key:"Field 2",value:"Value 2.3"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.4"}]}),cy.visit(a),cy.findByRole("link",{name:"Reset filters"}).click(),(0,l.checkSelectedFilterValues)({length:6,buttonValues:t}),cy.visit(n),cy.findByRole("tab",{name:/Viewed/}).click(),u({name:"Interactive Report",product:"Interactive Report",length:5,selectedFilters:t})}),it("should update the filter values and init the report with the updated interactive defaults",()=>{cy.visit(a),e().should("exist"),d().should("exist"),(0,l.checkSelectedFilterValues)({length:6,buttonValues:[{key:"Field 1",value:"Value 1.2"},{key:"Field 2",value:"Value 2.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.1, Value 8.2, Value 8.3 + 1 more"}]}),i(),cy.findByRole("checkbox",{name:"Value 8.1"}).uncheck(),cy.findByRole("checkbox",{name:"Value 8.3"}).uncheck(),cy.findByRole("combobox",{name:"Field 2"}).select("value2.3"),o();const t=[{key:"Field 1",value:"Value 1.2"},{key:"Field 2",value:"Value 2.3"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.2, Value 8.4"}];(0,l.checkSelectedFilterValues)({length:6,buttonValues:t}),e().click(),(0,l.checkSelectedFilterValues)({length:6,buttonValues:t}),(0,l.requestReport)({name:"Interactive Report",description:"this is an interactive report",path:n}),cy.url().then(h=>{a=h}),(0,l.checkSelectedFilterValues)({length:6,buttonValues:t}),e().should("exist"),d().should("exist"),cy.visit(n),cy.findByRole("tab",{name:/Viewed/}).click(),u({name:"Interactive Report",product:"Interactive Report",length:5,selectedFilters:t})}),it("should delete the saved defaults",()=>{cy.visit(a),(0,l.checkSelectedFilterValues)({length:6,buttonValues:[{key:"Field 1",value:"Value 1.2"},{key:"Field 2",value:"Value 2.3"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.2, Value 8.4"}]}),d().click(),(0,l.checkSelectedFilterValues)({length:5,buttonValues:[{key:"Field 1",value:"Value 1.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.2, Value 8.3"}]}),cy.visit(n),cy.findByRole("tab",{name:/Viewed/}).click(),u({name:"Interactive Report",product:"Interactive Report",length:4,selectedFilters:[{key:"Field 1",value:"Value 1.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.2, Value 8.3"}]})}),describe("Input types",()=>{describe("Relative date range",()=>{it("should save the relative daterange",()=>{(0,l.requestReport)({name:"Interactive Report",description:"this is an interactive report",path:n}),(0,l.checkSelectedFilterValues)({length:5,buttonValues:[{key:"Field 1",value:"Value 1.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.2, Value 8.3"}]}),i(),cy.findByRole("tab",{name:"Preset date ranges"}).click(),cy.findByRole("radio",{name:"Tomorrow"}).check(),o();const t=[{key:"Field 1",value:"Value 1.2"},{key:"Field 3",value:"Tomorrow"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.2, Value 8.3"}];(0,l.checkSelectedFilterValues)({length:5,buttonValues:t}),c().click(),e().should("exist"),d().should("exist"),(0,l.checkSelectedFilterValues)({length:5,buttonValues:t}),(0,l.requestReport)({name:"Interactive Report",description:"this is an interactive report",path:n}),(0,l.checkSelectedFilterValues)({length:5,buttonValues:t}),d().click()})}),describe("Multiselect",()=>{it("should save a single multiselect value",()=>{(0,l.requestReport)({name:"Interactive Report",description:"this is an interactive report",path:n}),(0,l.checkSelectedFilterValues)({length:5,buttonValues:[{key:"Field 1",value:"Value 1.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.2, Value 8.3"}]}),i(),cy.findByRole("checkbox",{name:"Value 8.3"}).uncheck(),o();const t=[{key:"Field 1",value:"Value 1.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.2"}];(0,l.checkSelectedFilterValues)({length:5,buttonValues:t}),c().click(),e().should("exist"),d().should("exist"),(0,l.checkSelectedFilterValues)({length:5,buttonValues:t}),(0,l.requestReport)({name:"Interactive Report",description:"this is an interactive report",path:n}),(0,l.checkSelectedFilterValues)({length:5,buttonValues:t}),d().click()})})})}),describe("Sorting",()=>{before(()=>{(0,l.requestReport)({name:"Interactive Report",description:"this is an interactive report",path:n}),cy.url().then(c=>{a=c})}),beforeEach(()=>{cy.visit(a)}),it("should show the sort direction in the column header and the url",()=>{cy.findByRole("link",{name:"Reset filters"}).click(),cy.findByRole("link",{name:"Field 1"}).should("have.class","data-table-header-button-sort-ascending"),cy.findByRole("link",{name:"Field 2"}).should("have.class","data-table-header-button-sort-none"),cy.findByRole("link",{name:"Field 1"}).click(),cy.findByRole("link",{name:"Field 1"}).should("have.class","data-table-header-button-sort-descending"),cy.findByRole("link",{name:"Field 2"}).should("have.class","data-table-header-button-sort-none"),cy.location().should(c=>{expect(c.search).to.contain("&sortColumn=field1&sortedAsc=false"),expect(c.search).to.contain("filters.field8=value8.2&filters.field8=value8.3")}),cy.findByRole("link",{name:"Field 1"}).click(),cy.findByRole("link",{name:"Field 1"}).should("have.class","data-table-header-button-sort-ascending"),cy.findByRole("link",{name:"Field 2"}).should("have.class","data-table-header-button-sort-none"),cy.location().should(c=>{expect(c.search).to.contain("&sortColumn=field1&sortedAsc=true"),expect(c.search).to.contain("filters.field8=value8.2&filters.field8=value8.3")}),cy.findByRole("link",{name:"Field 2"}).click(),cy.findByRole("link",{name:"Field 2"}).should("have.class","data-table-header-button-sort-ascending"),cy.findByRole("link",{name:"Field 1"}).should("have.class","data-table-header-button-sort-none"),cy.location().should(c=>{expect(c.search).to.contain("&sortColumn=field2&sortedAsc=true"),expect(c.search).to.contain("filters.field8=value8.2&filters.field8=value8.3")}),cy.findByRole("link",{name:"Field 2"}).click(),cy.findByRole("link",{name:"Field 2"}).should("have.class","data-table-header-button-sort-descending"),cy.findByRole("link",{name:"Field 1"}).should("have.class","data-table-header-button-sort-none"),cy.location().should(c=>{expect(c.search).to.contain("&sortColumn=field2&sortedAsc=false"),expect(c.search).to.contain("filters.field8=value8.2&filters.field8=value8.3")})})})})});
1
+ "use strict";var x=Object.create;var b=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var g=(n,a,s,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let i of v(a))!V.call(n,i)&&i!==s&&b(n,i,{get:()=>a[i],enumerable:!(o=B(a,i))||o.enumerable});return n};var w=(n,a,s)=>(s=n!=null?x(F(n)):{},g(a||!n||!n.__esModule?b(s,"default",{value:n,enumerable:!0}):s,n));var l=require("../../../../../../../cypress-tests/cypressUtils"),f=w(require("../../../../../utils/DateMapper/DateMapper"));context("Viewing a report",()=>{const n="/embedded/platform/";let a,s;describe("List report page",()=>{before(()=>{(0,l.executeReportStubs)(),cy.task("stubDefinitionRequestExamplesSuccess"),cy.task("stubRequestSuccessResult10"),cy.task("stubRequestSuccessResult20"),cy.task("stubRequestSuccessResult100"),(0,l.requestReport)({name:"Successful Report",description:"this will succeed",path:n}),cy.url().then(o=>{a=o;const i=o.split("/");s=i[i.length-2]})}),beforeEach(()=>{cy.visit(a)}),describe("Report details",()=>{it("should show the report details",()=>{cy.findAllByRole("group").contains("Report details").should("be.visible").click(),cy.findAllByRole("group").contains("Report details").parent().parent().within(()=>{cy.findAllByRole("row").each((o,i)=>{cy.wrap(o).within(()=>{switch(i){case 0:cy.findAllByRole("cell",{name:"Name:"}).should("exist"),cy.findAllByRole("cell",{name:"Successful Report"}).should("exist");break;case 1:cy.findAllByRole("cell",{name:"Product:"}).should("exist"),cy.findAllByRole("cell",{name:"Successful Report"}).should("exist");break;case 2:cy.findAllByRole("cell",{name:"Description:"}).should("exist"),cy.findAllByRole("cell",{name:"this will succeed"}).should("exist");break;case 3:cy.findAllByRole("cell",{name:"Classification:"}).should("exist"),cy.findAllByRole("cell",{name:"OFFICIAL"}).should("exist");break;case 4:cy.findAllByRole("cell",{name:"Requested at:"}).should("exist"),cy.findAllByRole("cell",{name:/\d{1,2}\/\d{1,2}\/\d{2,4}/}).should("exist");break;case 5:cy.findAllByRole("cell",{name:"Applied Filters:"}).should("exist"),cy.findAllByRole("listitem").each((c,e)=>{switch(e){case 0:cy.wrap(c).contains("Field 1: value1.2");break;case 1:cy.wrap(c).contains("Field 3 start: 01/02/2003");break;case 2:cy.wrap(c).contains("Field 3 end: 04/05/2006");break;case 3:cy.wrap(c).contains("Field 7: 01/02/2005");break;case 4:cy.wrap(c).contains("Field 8: value8.2,value8.3");break;case 5:cy.wrap(c).contains("Sort column: Field 1");break;case 6:cy.wrap(c).contains("Sort direction: Descending");break;default:break}});break;default:break}})})})})}),describe("Actions",()=>{it("should show the actions and go to the filters page when refresh action is clicked",()=>{cy.findByLabelText("Refresh report").should("be.visible"),cy.findByLabelText(/download/).should("be.visible"),cy.findByLabelText(/Copy report link/).should("be.visible"),cy.findByRole("button",{name:/Add bookmark/}).should("be.visible"),cy.findByLabelText("Refresh report").should("be.visible").click(),cy.url().should("match",/.*\/embedded\/platform\/dpr\/request-report\/report\/request-examples\/request-example-success\/filters/i),cy.location().should(o=>{expect(o.search).to.contain("filters.field1=value1.2"),expect(o.search).to.contain("filters.field3.start=2003-02-01"),expect(o.search).to.contain("filters.field3.end=2006-05-04"),expect(o.search).to.contain("filters.field7=2005-02-01"),expect(o.search).to.contain("filters.field8=value8.2&filters.field8=value8.3")})})}),describe("Column interactions",()=>{const o=()=>{cy.findByRole("checkbox",{name:"Field 1"}).should("be.checked"),cy.findByRole("checkbox",{name:"Field 2"}).should("be.checked").should("be.disabled"),cy.findByRole("checkbox",{name:"Field 3"}).should("be.checked"),cy.findByRole("checkbox",{name:"Field 4"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 5"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 6"}).should("be.checked").should("be.disabled"),cy.findByRole("checkbox",{name:"Field 7"}).should("be.checked"),cy.findByRole("checkbox",{name:"Field 8"}).should("not.be.checked"),cy.location().should(e=>{expect(e.search).to.contain("columns=field1"),expect(e.search).to.contain("columns=field2"),expect(e.search).to.contain("columns=field3"),expect(e.search).not.to.contain("columns=field4"),expect(e.search).not.to.contain("columns=field5"),expect(e.search).to.contain("columns=field6"),expect(e.search).to.contain("columns=field7"),expect(e.search).not.to.contain("columns=field8")}),cy.findByLabelText(/Successful Report/).within(()=>{cy.findAllByRole("rowgroup").eq(0).within(()=>{cy.findAllByRole("row").eq(1).within(()=>{cy.findAllByRole("columnheader").should("have.length",5)})})})},i=()=>{cy.findByRole("checkbox",{name:"Field 1"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 2"}).should("be.checked").should("be.disabled"),cy.findByRole("checkbox",{name:"Field 3"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 4"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 5"}).should("be.checked"),cy.findByRole("checkbox",{name:"Field 6"}).should("be.checked").should("be.disabled"),cy.findByRole("checkbox",{name:"Field 7"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 8"}).should("be.checked"),cy.location().should(e=>{expect(e.search).not.to.contain("columns=field1"),expect(e.search).to.contain("columns=field2"),expect(e.search).not.to.contain("columns=field3"),expect(e.search).not.to.contain("columns=field4"),expect(e.search).to.contain("columns=field5"),expect(e.search).to.contain("columns=field6"),expect(e.search).not.to.contain("columns=field7"),expect(e.search).to.contain("columns=field8")}),cy.findByLabelText(/Successful Report/).within(()=>{cy.findAllByRole("rowgroup").eq(0).within(()=>{cy.findAllByRole("row").eq(1).within(()=>{cy.findAllByRole("columnheader").should("have.length",4)})})})},c=()=>{cy.findByRole("checkbox",{name:"Field 1"}).uncheck(),cy.findByRole("checkbox",{name:"Field 3"}).uncheck(),cy.findByRole("checkbox",{name:"Field 5"}).check(),cy.findByRole("checkbox",{name:"Field 7"}).uncheck(),cy.findByRole("checkbox",{name:"Field 8"}).check()};it("should initialise the column content correctly",()=>{cy.findAllByRole("group").contains(/Show columns/).should("be.visible").click(),o(),cy.findAllByRole("group").contains("Show columns (5 of 8 shown)"),cy.findByLabelText(/Successful Report/).within(()=>{cy.findAllByRole("rowgroup").eq(0).within(()=>{cy.findAllByRole("columnheader").each((e,d)=>{switch(d){case 0:cy.wrap(e).contains("Field 1");break;case 1:cy.wrap(e).contains("Field 2");break;case 2:cy.wrap(e).contains("Field 3");break;case 3:cy.wrap(e).contains("Field 6");break;case 4:cy.wrap(e).contains("Field 7");break;default:break}})})})}),it("should apply the columns",()=>{cy.findAllByRole("group").contains(/Show columns/).click(),c(),cy.findByRole("button",{name:"Apply columns"}).click(),i(),cy.findByLabelText(/Successful Report/).within(()=>{cy.findAllByRole("rowgroup").eq(0).within(()=>{cy.findAllByRole("columnheader").each((e,d)=>{switch(d){case 0:cy.wrap(e).contains("Field 2");break;case 1:cy.wrap(e).contains("Field 5");break;case 2:cy.wrap(e).contains("Field 6");break;case 3:cy.wrap(e).contains("Field 8");break;default:break}})})})}),it("should reset the columns to their DPD defaults",()=>{cy.findAllByRole("group").contains(/Show columns/).click(),c(),cy.findByRole("button",{name:"Apply columns"}).click(),i(),cy.findAllByRole("group").contains(/Show columns/).click(),cy.findByRole("link",{name:"Reset columns"}).click(),o()}),it("should apply the columns from the URL",()=>{cy.visit(`/embedded/platform/dpr/view-report/async/report/request-examples/request-example-success/${s}/report?columns=field1&columns=field5&columns=field8`),cy.findByRole("checkbox",{name:"Field 1"}).should("be.checked"),cy.findByRole("checkbox",{name:"Field 2"}).should("be.checked").should("be.disabled"),cy.findByRole("checkbox",{name:"Field 3"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 4"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 5"}).should("be.checked"),cy.findByRole("checkbox",{name:"Field 6"}).should("be.checked").should("be.disabled"),cy.findByRole("checkbox",{name:"Field 7"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 8"}).should("be.checked"),cy.findByLabelText(/Successful Report/).within(()=>{cy.findAllByRole("rowgroup").eq(0).within(()=>{cy.findAllByRole("columnheader").each((e,d)=>{switch(d){case 0:cy.wrap(e).contains("Field 1");break;case 1:cy.wrap(e).contains("Field 2");break;case 2:cy.wrap(e).contains("Field 5");break;case 3:cy.wrap(e).contains("Field 6");break;case 4:cy.wrap(e).contains("Field 8");break;default:break}})})})}),it("should only apply mandatory columms",()=>{cy.findAllByRole("group").contains(/Show columns/).click(),cy.findByRole("checkbox",{name:"Field 1"}).uncheck(),cy.findByRole("checkbox",{name:"Field 3"}).uncheck(),cy.findByRole("checkbox",{name:"Field 7"}).uncheck(),cy.findByRole("button",{name:"Apply columns"}).click(),cy.findByRole("checkbox",{name:"Field 1"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 2"}).should("be.checked").should("be.disabled"),cy.findByRole("checkbox",{name:"Field 3"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 4"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 5"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 6"}).should("be.checked").should("be.disabled"),cy.findByRole("checkbox",{name:"Field 7"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Field 8"}).should("not.be.checked"),cy.location().should(e=>{expect(e.search).not.to.contain("columns=field1"),expect(e.search).to.contain("columns=field2"),expect(e.search).not.to.contain("columns=field3"),expect(e.search).not.to.contain("columns=field4"),expect(e.search).not.to.contain("columns=field5"),expect(e.search).to.contain("columns=field6"),expect(e.search).not.to.contain("columns=field7"),expect(e.search).not.to.contain("columns=field8")}),cy.findByLabelText(/Successful Report/).within(()=>{cy.findAllByRole("rowgroup").eq(0).within(()=>{cy.findAllByRole("row").eq(1).within(()=>{cy.findAllByRole("columnheader").should("have.length",2)})})})})}),describe("Paging interaction",()=>{it("should show the table totals",()=>{cy.findAllByRole("paragraph").contains(/Showing \d{1,4} to \d{1,4} of \d{1,4} results/).should("exist"),cy.findByLabelText(/Successful Report/).within(()=>{cy.findAllByRole("rowgroup").eq(1).within(()=>{cy.findAllByRole("row").should("have.length",20)})})}),it("should change the page size",()=>{cy.get("#page-size-select").select("10"),cy.findAllByRole("paragraph").contains(/Showing 1 to 10 of 100 results/).should("exist"),cy.findByLabelText(/Successful Report/).within(()=>{cy.findAllByRole("rowgroup").eq(1).within(()=>{cy.findAllByRole("row").should("have.length",10)})})}),it("should change the page size via the URL",()=>{cy.visit(`/embedded/platform/dpr/view-report/async/report/request-examples/request-example-success/${s}/report?pageSize=100`),cy.findAllByRole("paragraph").contains(/100 total results/).should("exist"),cy.findByLabelText(/Successful Report/).within(()=>{cy.findAllByRole("rowgroup").eq(1).within(()=>{cy.findAllByRole("row").should("have.length",100)})})}),it("should change the page",()=>{cy.findByLabelText("Page 5").click(),cy.location().should(o=>{expect(o.search).to.contain("selectedPage=5")})}),it("should change the page via the URL",()=>{cy.visit(`/embedded/platform/dpr/view-report/async/report/request-examples/request-example-success/${s}/report?selectedPage=3`),cy.findByRole("link",{current:"page"}).contains("3")})})}),describe("Interactive report",()=>{const o=()=>{cy.findByRole("button",{name:"Apply filters"}).click()},i=()=>{cy.findAllByRole("group").contains(/Show filters/).click()};before(()=>{(0,l.executeReportStubs)(),cy.task("stubDefinitionFeatureTestingInteractive"),cy.task("stubAsyncRequestSuccessReportTablesCount"),cy.task("stubRequestSuccessResult20"),cy.task("stubRequestSuccessResult100")}),describe("Apply filters",()=>{before(()=>{(0,l.requestReport)({name:"Interactive Report",description:"this is an interactive report",path:n}),cy.url().then(e=>{a=e})}),beforeEach(()=>{cy.visit(a)});const c=()=>{for(let e=0;e<4;e+=1)cy.findByLabelText("Selected filters").within(()=>{cy.findAllByRole("link").first().click()})};describe("Date range",()=>{it("should apply the date range",()=>{cy.findByRole("textbox",{name:"From"}).should("have.value","01/02/2003"),cy.findByRole("textbox",{name:"To"}).should("have.value","04/05/2006"),c(),i(),cy.findByRole("textbox",{name:"From"}).type("02/05/2025"),cy.findByRole("textbox",{name:"To"}).type("05/07/2025").blur(),o(),cy.location().should(e=>{expect(e.search).to.contain("filters.field3.start=2025-05-02"),expect(e.search).to.contain("filters.field3.end=2025-07-05")}),(0,l.checkSelectedFilterValues)({length:2,buttonValues:[{key:"Field 3",value:"02/05/2025 - 05/07/2025"}]})}),it("should apply the relative daterange",()=>{c(),i(),cy.findByRole("tab",{name:"Preset date ranges"}).click(),cy.findByRole("radio",{name:"Tomorrow"}).check(),o();let e,d;cy.findByRole("textbox",{name:"From"}).invoke("val").should("not.be.empty").then(t=>{e=t}),cy.findByRole("textbox",{name:"To"}).invoke("val").should("not.be.empty").then(t=>{d=t});const u=new f.default;cy.location().should(t=>{expect(t.search).to.contain(`filters.field3.start=${u.toDateString(e,"iso")}`),expect(t.search).to.contain(`filters.field3.end=${u.toDateString(d,"iso")}`),expect(t.search).to.contain("filters.field3.relative-duration=tomorrow")}),(0,l.checkSelectedFilterValues)({length:2,buttonValues:[{key:"Field 3",value:"Tomorrow"}]})})}),describe("Multiselect",()=>{it("should apply the multiselect values",()=>{cy.findByRole("checkbox",{name:"Value 8.2"}).should("be.checked"),cy.findByRole("checkbox",{name:"Value 8.3"}).should("be.checked"),c(),cy.findByRole("checkbox",{name:"Value 8.1"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.2"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.3"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.4"}).should("not.be.checked"),i(),cy.findByRole("checkbox",{name:"Value 8.1"}).check(),cy.findByRole("checkbox",{name:"Value 8.3"}).check(),o(),cy.findByRole("checkbox",{name:"Value 8.1"}).should("be.checked"),cy.findByRole("checkbox",{name:"Value 8.2"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.3"}).should("be.checked"),cy.findByRole("checkbox",{name:"Value 8.4"}).should("not.be.checked"),(0,l.checkSelectedFilterValues)({length:2,buttonValues:[{key:"Field 8",value:"Value 8.1, Value 8.3"}]})}),it("should set the selected filter values correctly",()=>{cy.findByRole("checkbox",{name:"Value 8.2"}).should("be.checked"),cy.findByRole("checkbox",{name:"Value 8.3"}).should("be.checked"),c(),cy.findByRole("checkbox",{name:"Value 8.1"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.2"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.3"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.4"}).should("not.be.checked"),i(),cy.findByRole("checkbox",{name:"Value 8.1"}).check(),cy.findByRole("checkbox",{name:"Value 8.2"}).check(),cy.findByRole("checkbox",{name:"Value 8.3"}).check(),cy.findByRole("checkbox",{name:"Value 8.4"}).check(),o(),cy.findByRole("checkbox",{name:"Value 8.1"}).should("be.checked"),cy.findByRole("checkbox",{name:"Value 8.2"}).should("be.checked"),cy.findByRole("checkbox",{name:"Value 8.3"}).should("be.checked"),cy.findByRole("checkbox",{name:"Value 8.4"}).should("be.checked"),(0,l.checkSelectedFilterValues)({length:2,buttonValues:[{key:"Field 8",value:"Value 8.1, Value 8.2, Value 8.3 + 1 more"}]})}),it("should set the values correctly when only one checkbox selected",()=>{c(),cy.findByRole("checkbox",{name:"Value 8.1"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.2"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.3"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.4"}).should("not.be.checked"),i(),cy.findByRole("checkbox",{name:"Value 8.1"}).check(),o(),cy.findByRole("checkbox",{name:"Value 8.1"}).should("be.checked"),cy.findByRole("checkbox",{name:"Value 8.2"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.3"}).should("not.be.checked"),cy.findByRole("checkbox",{name:"Value 8.4"}).should("not.be.checked"),(0,l.checkSelectedFilterValues)({length:2,buttonValues:[{key:"Field 8",value:"Value 8.1"}]})})}),it("Applying filters should persist current applied columns",()=>{cy.findAllByRole("group").contains(/Show columns/).should("be.visible").click(),cy.findByRole("checkbox",{name:"Field 1"}).uncheck(),cy.findByRole("checkbox",{name:"Field 3"}).uncheck(),cy.findByRole("checkbox",{name:"Field 5"}).check(),cy.findByRole("checkbox",{name:"Field 7"}).uncheck(),cy.findByRole("checkbox",{name:"Field 8"}).check(),cy.findByRole("button",{name:"Apply columns"}).click(),cy.findAllByRole("group").contains("Show columns (4 of 8 shown)"),i(),cy.findByRole("checkbox",{name:"Value 8.1"}).check(),cy.findByRole("checkbox",{name:"Value 8.3"}).check(),o(),cy.findAllByRole("group").contains("Show columns (4 of 8 shown)")})}),describe("User defined interactive defaults",()=>{const c=()=>cy.findByRole("button",{name:"Save current filter values as defaults"}),e=()=>cy.findByRole("button",{name:"Update defaults"}),d=()=>cy.findByRole("button",{name:"Delete defaults"}),u=({name:t,product:h,length:m,selectedFilters:k})=>{cy.findByLabelText(/Viewed \(/).within(()=>{cy.findByRole("row",{name:(r,y)=>!!y.textContent?.includes(t)&&!!y.textContent?.includes(h)}).within(()=>{cy.findAllByRole("listitem").should("have.length",m).each((r,y)=>{if(k[y]){const{key:p,value:R}=k[y];cy.wrap(r).contains(p),cy.wrap(r).contains(R)}})})})};it("should save the interactive filters correctly",()=>{(0,l.requestReport)({name:"Interactive Report",description:"this is an interactive report",path:n}),(0,l.checkSelectedFilterValues)({length:5,buttonValues:[{key:"Field 1",value:"Value 1.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.2, Value 8.3"}]}),i(),cy.findByRole("checkbox",{name:"Value 8.1"}).check(),cy.findByRole("checkbox",{name:"Value 8.4"}).check(),cy.findByRole("combobox",{name:"Field 2"}).select("value2.2"),o();const t=[{key:"Field 1",value:"Value 1.2"},{key:"Field 2",value:"Value 2.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.1, Value 8.2, Value 8.3 + 1 more"}];(0,l.checkSelectedFilterValues)({length:6,buttonValues:t}),c().click(),e().should("exist"),d().should("exist"),(0,l.checkSelectedFilterValues)({length:6,buttonValues:t})}),it("should init the report with saved interactive defaults",()=>{(0,l.requestReport)({name:"Interactive Report",description:"this is an interactive report",path:n}),cy.url().then(h=>{a=h}),e().should("exist"),d().should("exist");const t=[{key:"Field 1",value:"Value 1.2"},{key:"Field 2",value:"Value 2.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.1, Value 8.2, Value 8.3 + 1 more"}];(0,l.checkSelectedFilterValues)({length:6,buttonValues:t}),cy.visit(n),cy.findByRole("tab",{name:/Viewed/}).click(),u({name:"Interactive Report",product:"Interactive Report",length:5,selectedFilters:t})}),it("should reset the filter values to the saved defaults",()=>{cy.visit(a),e().should("exist"),d().should("exist");const t=[{key:"Field 1",value:"Value 1.2"},{key:"Field 2",value:"Value 2.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.1, Value 8.2, Value 8.3 + 1 more"}];(0,l.checkSelectedFilterValues)({length:6,buttonValues:t}),i(),cy.findByRole("checkbox",{name:"Value 8.1"}).uncheck(),cy.findByRole("checkbox",{name:"Value 8.3"}).uncheck(),cy.findByRole("combobox",{name:"Field 2"}).select("value2.3"),o(),(0,l.checkSelectedFilterValues)({length:6,buttonValues:[{key:"Field 1",value:"Value 1.2"},{key:"Field 2",value:"Value 2.3"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.4"}]}),cy.visit(n),cy.findByRole("tab",{name:/Viewed/}).click(),u({name:"Interactive Report",product:"Interactive Report",length:5,selectedFilters:[{key:"Field 1",value:"Value 1.2"},{key:"Field 2",value:"Value 2.3"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.4"}]}),cy.visit(a),cy.findByRole("link",{name:"Reset filters"}).click(),(0,l.checkSelectedFilterValues)({length:6,buttonValues:t}),cy.visit(n),cy.findByRole("tab",{name:/Viewed/}).click(),u({name:"Interactive Report",product:"Interactive Report",length:5,selectedFilters:t})}),it("should update the filter values and init the report with the updated interactive defaults",()=>{cy.visit(a),e().should("exist"),d().should("exist"),(0,l.checkSelectedFilterValues)({length:6,buttonValues:[{key:"Field 1",value:"Value 1.2"},{key:"Field 2",value:"Value 2.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.1, Value 8.2, Value 8.3 + 1 more"}]}),i(),cy.findByRole("checkbox",{name:"Value 8.1"}).uncheck(),cy.findByRole("checkbox",{name:"Value 8.3"}).uncheck(),cy.findByRole("combobox",{name:"Field 2"}).select("value2.3"),o();const t=[{key:"Field 1",value:"Value 1.2"},{key:"Field 2",value:"Value 2.3"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.2, Value 8.4"}];(0,l.checkSelectedFilterValues)({length:6,buttonValues:t}),e().click(),(0,l.checkSelectedFilterValues)({length:6,buttonValues:t}),(0,l.requestReport)({name:"Interactive Report",description:"this is an interactive report",path:n}),cy.url().then(h=>{a=h}),(0,l.checkSelectedFilterValues)({length:6,buttonValues:t}),e().should("exist"),d().should("exist"),cy.visit(n),cy.findByRole("tab",{name:/Viewed/}).click(),u({name:"Interactive Report",product:"Interactive Report",length:5,selectedFilters:t})}),it("should delete the saved defaults",()=>{cy.visit(a),(0,l.checkSelectedFilterValues)({length:6,buttonValues:[{key:"Field 1",value:"Value 1.2"},{key:"Field 2",value:"Value 2.3"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.2, Value 8.4"}]}),d().click(),(0,l.checkSelectedFilterValues)({length:5,buttonValues:[{key:"Field 1",value:"Value 1.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.2, Value 8.3"}]}),cy.visit(n),cy.findByRole("tab",{name:/Viewed/}).click(),u({name:"Interactive Report",product:"Interactive Report",length:4,selectedFilters:[{key:"Field 1",value:"Value 1.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.2, Value 8.3"}]})}),describe("Input types",()=>{describe("Relative date range",()=>{it("should save the relative daterange",()=>{(0,l.requestReport)({name:"Interactive Report",description:"this is an interactive report",path:n}),(0,l.checkSelectedFilterValues)({length:5,buttonValues:[{key:"Field 1",value:"Value 1.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.2, Value 8.3"}]}),i(),cy.findByRole("tab",{name:"Preset date ranges"}).click(),cy.findByRole("radio",{name:"Tomorrow"}).check(),o();const t=[{key:"Field 1",value:"Value 1.2"},{key:"Field 3",value:"Tomorrow"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.2, Value 8.3"}];(0,l.checkSelectedFilterValues)({length:5,buttonValues:t}),c().click(),e().should("exist"),d().should("exist"),(0,l.checkSelectedFilterValues)({length:5,buttonValues:t}),(0,l.requestReport)({name:"Interactive Report",description:"this is an interactive report",path:n}),(0,l.checkSelectedFilterValues)({length:5,buttonValues:t}),d().click()})}),describe("Multiselect",()=>{it("should save a single multiselect value",()=>{(0,l.requestReport)({name:"Interactive Report",description:"this is an interactive report",path:n}),(0,l.checkSelectedFilterValues)({length:5,buttonValues:[{key:"Field 1",value:"Value 1.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.2, Value 8.3"}]}),i(),cy.findByRole("checkbox",{name:"Value 8.3"}).uncheck(),o();const t=[{key:"Field 1",value:"Value 1.2"},{key:"Field 3",value:"01/02/2003 - 04/05/2006"},{key:"Field 7",value:"01/02/2005"},{key:"Field 8",value:"Value 8.2"}];(0,l.checkSelectedFilterValues)({length:5,buttonValues:t}),c().click(),e().should("exist"),d().should("exist"),(0,l.checkSelectedFilterValues)({length:5,buttonValues:t}),(0,l.requestReport)({name:"Interactive Report",description:"this is an interactive report",path:n}),(0,l.checkSelectedFilterValues)({length:5,buttonValues:t}),d().click()})})})}),describe("Sorting",()=>{before(()=>{(0,l.requestReport)({name:"Interactive Report",description:"this is an interactive report",path:n}),cy.url().then(c=>{a=c})}),beforeEach(()=>{cy.visit(a)}),it("should show the sort direction in the column header and the url",()=>{cy.findByRole("link",{name:"Reset filters"}).click(),cy.findByRole("link",{name:"Field 1"}).should("have.class","data-table-header-button-sort-ascending"),cy.findByRole("link",{name:"Field 2"}).should("have.class","data-table-header-button-sort-none"),cy.findByRole("link",{name:"Field 1"}).click(),cy.findByRole("link",{name:"Field 1"}).should("have.class","data-table-header-button-sort-descending"),cy.findByRole("link",{name:"Field 2"}).should("have.class","data-table-header-button-sort-none"),cy.location().should(c=>{expect(c.search).to.contain("&sortColumn=field1&sortedAsc=false"),expect(c.search).to.contain("filters.field8=value8.2&filters.field8=value8.3")}),cy.findByRole("link",{name:"Field 1"}).click(),cy.findByRole("link",{name:"Field 1"}).should("have.class","data-table-header-button-sort-ascending"),cy.findByRole("link",{name:"Field 2"}).should("have.class","data-table-header-button-sort-none"),cy.location().should(c=>{expect(c.search).to.contain("&sortColumn=field1&sortedAsc=true"),expect(c.search).to.contain("filters.field8=value8.2&filters.field8=value8.3")}),cy.findByRole("link",{name:"Field 2"}).click(),cy.findByRole("link",{name:"Field 2"}).should("have.class","data-table-header-button-sort-ascending"),cy.findByRole("link",{name:"Field 1"}).should("have.class","data-table-header-button-sort-none"),cy.location().should(c=>{expect(c.search).to.contain("&sortColumn=field2&sortedAsc=true"),expect(c.search).to.contain("filters.field8=value8.2&filters.field8=value8.3")}),cy.findByRole("link",{name:"Field 2"}).click(),cy.findByRole("link",{name:"Field 2"}).should("have.class","data-table-header-button-sort-descending"),cy.findByRole("link",{name:"Field 1"}).should("have.class","data-table-header-button-sort-none"),cy.location().should(c=>{expect(c.search).to.contain("&sortColumn=field2&sortedAsc=false"),expect(c.search).to.contain("filters.field8=value8.2&filters.field8=value8.3")})})})})});
2
2
  //# sourceMappingURL=tests.cy.js.map