11/**
22 * @file Integration Tests for CloudPulse Custom and Preset Verification
33 */
4- import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags' ;
4+ import { DateTime } from 'luxon' ;
5+ import { widgetDetails } from 'support/constants/widgets' ;
6+ import { mockGetAccount } from 'support/intercepts/account' ;
57import {
68 mockCreateCloudPulseJWEToken ,
7- mockGetCloudPulseDashboard ,
89 mockCreateCloudPulseMetrics ,
10+ mockGetCloudPulseDashboard ,
911 mockGetCloudPulseDashboards ,
1012 mockGetCloudPulseMetricDefinitions ,
1113 mockGetCloudPulseServices ,
1214} from 'support/intercepts/cloudpulse' ;
15+ import { mockGetDatabases } from 'support/intercepts/databases' ;
16+ import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags' ;
17+ import {
18+ mockGetProfile ,
19+ mockGetUserPreferences ,
20+ } from 'support/intercepts/profile' ;
21+ import { mockGetRegions } from 'support/intercepts/regions' ;
1322import { ui } from 'support/ui' ;
14- import { widgetDetails } from 'support/constants/widgets' ;
23+ import { generateRandomMetricsData } from 'support/util/cloudpulse' ;
24+
1525import {
1626 accountFactory ,
1727 cloudPulseMetricsResponseFactory ,
@@ -22,20 +32,12 @@ import {
2232 regionFactory ,
2333 widgetFactory ,
2434} from 'src/factories' ;
25- import { mockGetAccount } from 'support/intercepts/account' ;
26- import {
27- mockGetProfile ,
28- mockGetUserPreferences ,
29- } from 'support/intercepts/profile' ;
30- import { mockGetRegions } from 'support/intercepts/regions' ;
31- import { Database , DateTimeWithPreset } from '@linode/api-v4' ;
32- import { generateRandomMetricsData } from 'support/util/cloudpulse' ;
33- import { mockGetDatabases } from 'support/intercepts/databases' ;
34- import type { Flags } from 'src/featureFlags' ;
35- import type { Interception } from 'support/cypress-exports' ;
3635import { convertToGmt } from 'src/features/CloudPulse/Utils/CloudPulseDateTimePickerUtils' ;
3736import { formatDate } from 'src/utilities/formatDate' ;
38- import { DateTime } from 'luxon' ;
37+
38+ import type { Database , DateTimeWithPreset } from '@linode/api-v4' ;
39+ import type { Flags } from 'src/featureFlags' ;
40+ import type { Interception } from 'support/cypress-exports' ;
3941
4042const formatter = "yyyy-MM-dd'T'HH:mm:ss'Z'" ;
4143const currentDate = new Date ( ) ;
@@ -59,7 +61,7 @@ const mockRegion = regionFactory.build({
5961} ) ;
6062
6163const flags : Partial < Flags > = {
62- aclp : { enabled : true , beta : true } ,
64+ aclp : { beta : true , enabled : true } ,
6365 aclpResourceTypeMap : [
6466 {
6567 dimensionKey : 'cluster_id' ,
@@ -70,23 +72,23 @@ const flags: Partial<Flags> = {
7072 ] ,
7173} ;
7274
73- const { metrics , id , serviceType , dashboardName , engine } = widgetDetails . dbaas ;
75+ const { dashboardName , engine , id , metrics , serviceType } = widgetDetails . dbaas ;
7476
7577const dashboard = dashboardFactory . build ( {
7678 label : dashboardName ,
7779 service_type : serviceType ,
78- widgets : metrics . map ( ( { title , yLabel , name , unit } ) => {
80+ widgets : metrics . map ( ( { name , title , unit , yLabel } ) => {
7981 return widgetFactory . build ( {
8082 label : title ,
81- y_label : yLabel ,
8283 metric : name ,
8384 unit,
85+ y_label : yLabel ,
8486 } ) ;
8587 } ) ,
8688} ) ;
8789
8890const metricDefinitions = {
89- data : metrics . map ( ( { title , name , unit } ) =>
91+ data : metrics . map ( ( { name , title , unit } ) =>
9092 dashboardMetricFactory . build ( {
9193 label : title ,
9294 metric : name ,
@@ -102,8 +104,8 @@ const metricsAPIResponsePayload = cloudPulseMetricsResponseFactory.build({
102104} ) ;
103105
104106const databaseMock : Database = databaseFactory . build ( {
105- type : engine ,
106107 region : mockRegion . label ,
108+ type : engine ,
107109} ) ;
108110const mockProfile = profileFactory . build ( {
109111 timezone : 'Etc/GMT' ,
@@ -235,8 +237,8 @@ describe('Integration tests for verifying Cloudpulse custom and preset configura
235237 aclpPreference : {
236238 dashboardId : id ,
237239 engine : engine . toLowerCase ( ) ,
238- resources : [ '1' ] ,
239240 region : mockRegion . id ,
241+ resources : [ '1' ] ,
240242 } ,
241243 } ) . as ( 'fetchPreferences' ) ;
242244 mockGetDatabases ( [ databaseMock ] ) ;
@@ -284,24 +286,26 @@ describe('Integration tests for verifying Cloudpulse custom and preset configura
284286 . click ( ) ;
285287
286288 // Selects the start hour, minute, and meridiem (AM/PM) in the time picker.
287-
288289 cy . findByLabelText ( 'Select hours' )
289- . scrollIntoView ( { easing : 'linear' } )
290- . within ( ( ) => {
291- cy . get ( `[aria-label="${ startHour } hours"]` ) . click ( ) ;
292- } ) ;
290+ . as ( 'selectHours' )
291+ . scrollIntoView ( { easing : 'linear' } ) ;
292+ cy . get ( '@selectHours' ) . within ( ( ) => {
293+ cy . get ( `[aria-label="${ startHour } hours"]` ) . click ( ) ;
294+ } ) ;
293295
294296 cy . findByLabelText ( 'Select minutes' )
295- . scrollIntoView ( { easing : 'linear' , duration : 500 } )
296- . within ( ( ) => {
297- cy . get ( `[aria-label="${ startMinute } minutes"]` ) . click ( ) ;
298- } ) ;
297+ . as ( 'selectMinutes' )
298+ . scrollIntoView ( { duration : 500 , easing : 'linear' } ) ;
299+ cy . get ( '@selectMinutes' ) . within ( ( ) => {
300+ cy . get ( `[aria-label="${ startMinute } minutes"]` ) . click ( ) ;
301+ } ) ;
299302
300303 cy . findByLabelText ( 'Select meridiem' )
301- . scrollIntoView ( { easing : 'linear' , duration : 500 } )
302- . within ( ( ) => {
303- cy . get ( `[aria-label="PM"]` ) . click ( ) ;
304- } ) ;
304+ . as ( 'selectMeridiem' )
305+ . scrollIntoView ( { duration : 500 , easing : 'linear' } ) ;
306+ cy . get ( '@selectMeridiem' ) . within ( ( ) => {
307+ cy . get ( `[aria-label="PM"]` ) . click ( ) ;
308+ } ) ;
305309
306310 // Click the "Apply" button to confirm the start date and time
307311 ui . button
@@ -312,7 +316,9 @@ describe('Integration tests for verifying Cloudpulse custom and preset configura
312316
313317 // Assert that the start date and time is correctly displayed
314318 cy . findByPlaceholderText ( 'Select Start Date' )
315- . scrollIntoView ( { easing : 'linear' } )
319+ . as ( 'selectStartDate' )
320+ . scrollIntoView ( { easing : 'linear' } ) ;
321+ cy . get ( '@selectStartDate' )
316322 . should ( 'be.visible' )
317323 . should ( 'have.value' , `${ cleanText ( startActualDate ) } PM` ) ;
318324
@@ -329,23 +335,29 @@ describe('Integration tests for verifying Cloudpulse custom and preset configura
329335 . click ( ) ;
330336
331337 // Selects the start hour, minute, and meridiem (AM/PM) in the time picker.
332- cy . findByLabelText ( 'Select hours' )
333- . scrollIntoView ( { easing : 'linear' , duration : 500 } )
334- . within ( ( ) => {
335- cy . get ( `[aria-label="${ endHour } hours"]` ) . click ( ) ;
336- } ) ;
338+ cy . findByLabelText ( 'Select hours' ) . scrollIntoView ( {
339+ duration : 500 ,
340+ easing : 'linear' ,
341+ } ) ;
342+ cy . get ( '@selectHours' ) . within ( ( ) => {
343+ cy . get ( `[aria-label="${ endHour } hours"]` ) . click ( ) ;
344+ } ) ;
337345
338- cy . findByLabelText ( 'Select minutes' )
339- . scrollIntoView ( { easing : 'linear' , duration : 500 } )
340- . within ( ( ) => {
341- cy . get ( `[aria-label="${ endMinute } minutes"]` ) . click ( ) ;
342- } ) ;
346+ cy . findByLabelText ( 'Select minutes' ) . scrollIntoView ( {
347+ duration : 500 ,
348+ easing : 'linear' ,
349+ } ) ;
350+ cy . get ( '@selectMinutes' ) . within ( ( ) => {
351+ cy . get ( `[aria-label="${ endMinute } minutes"]` ) . click ( ) ;
352+ } ) ;
343353
344- cy . findByLabelText ( 'Select meridiem' )
345- . scrollIntoView ( { easing : 'linear' , duration : 500 } )
346- . within ( ( ) => {
347- cy . get ( `[aria-label="PM"]` ) . click ( ) ;
348- } ) ;
354+ cy . findByLabelText ( 'Select meridiem' ) . scrollIntoView ( {
355+ duration : 500 ,
356+ easing : 'linear' ,
357+ } ) ;
358+ cy . get ( '@selectMeridiem' ) . within ( ( ) => {
359+ cy . get ( `[aria-label="PM"]` ) . click ( ) ;
360+ } ) ;
349361
350362 // Click the "Apply" button to confirm the end date and time
351363 ui . button
@@ -355,8 +367,10 @@ describe('Integration tests for verifying Cloudpulse custom and preset configura
355367 . click ( ) ;
356368
357369 // Assert that the end date and time is correctly displayed
370+ cy . findByPlaceholderText ( 'Select End Date' ) . scrollIntoView ( {
371+ easing : 'linear' ,
372+ } ) ;
358373 cy . findByPlaceholderText ( 'Select End Date' )
359- . scrollIntoView ( { easing : 'linear' } )
360374 . should ( 'be.visible' )
361375 . should ( 'have.value' , `${ cleanText ( endActualDate ) } PM` ) ;
362376
@@ -455,7 +469,7 @@ describe('Integration tests for verifying Cloudpulse custom and preset configura
455469 } ) ;
456470
457471 it ( 'Select the "Last Month" preset from the "Time Range" dropdown and verify its functionality.' , ( ) => {
458- const { start , end } = getLastMonthRange ( ) ;
472+ const { end , start } = getLastMonthRange ( ) ;
459473
460474 ui . autocomplete
461475 . findByLabel ( 'Time Range' )
@@ -486,7 +500,7 @@ describe('Integration tests for verifying Cloudpulse custom and preset configura
486500 } ) ;
487501
488502 it ( 'Select the "This Month" preset from the "Time Range" dropdown and verify its functionality.' , ( ) => {
489- const { start , end } = getThisMonthRange ( ) ;
503+ const { end , start } = getThisMonthRange ( ) ;
490504
491505 ui . autocomplete
492506 . findByLabel ( 'Time Range' )
0 commit comments