1+ import { Application } from "../../../support/application.config" ;
2+ import { tiles , toolbar } from "../../../support/components/common" ;
3+ import {
4+ advancedSettingsDialog ,
5+ createEditMappingDialog ,
6+ sourceToEntityMap
7+ } from "../../../support/components/mapping/index" ;
8+ import loadPage from "../../../support/pages/load" ;
9+ import browsePage from "../../../support/pages/browse" ;
10+ import curatePage from "../../../support/pages/curate" ;
11+ import runPage from "../../../support/pages/run" ;
12+ import detailPage from "../../../support/pages/detail" ;
13+ import LoginPage from "../../../support/pages/login" ;
14+ import "cypress-wait-until" ;
15+
16+ const flowName = "orderCustomHeaderFlow" ;
17+ const flowName2 = "orderE2eFlow" ;
18+ const loadStep = "loadOrderCustomHeader" ;
19+ const mapStep = "mapOrderCustomHeader" ;
20+
21+ describe ( "Create and verify load steps, map step and flows with a custom header" , ( ) => {
22+ before ( ( ) => {
23+ cy . visit ( "/" ) ;
24+ cy . contains ( Application . title ) ;
25+ cy . loginAsTestUserWithRoles ( "hub-central-flow-writer" , "hub-central-mapping-writer" , "hub-central-load-writer" ) . withRequest ( ) ;
26+ LoginPage . postLogin ( ) ;
27+ } ) ;
28+ beforeEach ( ( ) => {
29+ cy . loginAsTestUserWithRoles ( "hub-central-flow-writer" , "hub-central-mapping-writer" , "hub-central-load-writer" ) . withRequest ( ) ;
30+ } ) ;
31+ afterEach ( ( ) => {
32+ cy . resetTestUser ( ) ;
33+ } ) ;
34+ after ( ( ) => {
35+ cy . loginAsDeveloper ( ) . withRequest ( ) ;
36+ cy . deleteSteps ( "ingestion" , "loadOrderCustomHeader" ) ;
37+ cy . deleteSteps ( "mapping" , "mapOrderCustomHeader" ) ;
38+ cy . deleteFlows ( "orderCustomHeaderFlow" , "orderE2eFlow" ) ;
39+ cy . resetTestUser ( ) ;
40+ } ) ;
41+ it ( "Create load step" , ( ) => {
42+ toolbar . getLoadToolbarIcon ( ) . click ( ) ;
43+ cy . waitUntil ( ( ) => loadPage . stepName ( "ingestion-step" ) . should ( "be.visible" ) ) ;
44+ loadPage . addNewButton ( "card" ) . click ( ) ;
45+ loadPage . stepNameInput ( ) . type ( loadStep ) ;
46+ loadPage . stepDescriptionInput ( ) . type ( "load order with a custom header" ) ;
47+ loadPage . stepSourceNameInput ( ) . type ( "backup-ABC123" ) ;
48+ loadPage . confirmationOptions ( "Save" ) . click ( ) ;
49+ cy . findByText ( loadStep ) . should ( "be.visible" ) ;
50+ } ) ;
51+ it ( "Edit load step and Run" , ( ) => {
52+ // Open step settings and switch to Advanced tab
53+ loadPage . editStepInCardView ( loadStep ) . click ( { force : true } ) ;
54+ loadPage . switchEditAdvanced ( ) . click ( ) ;
55+ // add custom header to load step
56+ advancedSettingsDialog . setHeaderContent ( "loadTile/customHeader" ) ;
57+ advancedSettingsDialog . saveSettings ( loadStep ) . click ( ) ;
58+ advancedSettingsDialog . saveSettings ( loadStep ) . should ( "not.be.exist" ) ;
59+ // add step to a new flow
60+ loadPage . addStepToNewFlow ( loadStep ) ;
61+ cy . findByText ( "New Flow" ) . should ( "be.visible" ) ;
62+ runPage . setFlowName ( flowName ) ;
63+ runPage . setFlowDescription ( `${ flowName } description` ) ;
64+ loadPage . confirmationOptions ( "Save" ) . click ( ) ;
65+ cy . verifyStepAddedToFlow ( "Load" , loadStep ) ;
66+ //Run the ingest with JSON
67+ runPage . runStep ( loadStep ) . click ( ) ;
68+ cy . uploadFile ( "input/10260.json" ) ;
69+ cy . verifyStepRunResult ( "success" , "Ingestion" , loadStep ) ;
70+ tiles . closeRunMessage ( ) ;
71+ } ) ;
72+ it ( "Create mapping step" , ( ) => {
73+ toolbar . getCurateToolbarIcon ( ) . click ( ) ;
74+ cy . waitUntil ( ( ) => curatePage . getEntityTypePanel ( "Customer" ) . should ( "be.visible" ) ) ;
75+ curatePage . toggleEntityTypeId ( "Order" ) ;
76+ cy . waitUntil ( ( ) => curatePage . addNewStep ( ) . click ( ) ) ;
77+ createEditMappingDialog . setMappingName ( mapStep ) ;
78+ createEditMappingDialog . setMappingDescription ( "An order mapping with custom header" ) ;
79+ createEditMappingDialog . setSourceRadio ( "Query" ) ;
80+ createEditMappingDialog . setQueryInput ( `cts.collectionQuery(['${ loadStep } '])` ) ;
81+ createEditMappingDialog . saveButton ( ) . click ( { force : true } ) ;
82+ //verify that step details automatically opens after step creation
83+ curatePage . verifyStepDetailsOpen ( mapStep ) ;
84+ //close modal
85+ cy . get ( "body" ) . type ( "{esc}" ) ;
86+ curatePage . verifyStepNameIsVisible ( mapStep ) ;
87+ } ) ;
88+ it ( "Edit Map step" , ( ) => {
89+ // Open step settings and switch to Advanced tab
90+ cy . waitUntil ( ( ) => curatePage . editStep ( mapStep ) . click ( { force : true } ) ) ;
91+ curatePage . switchEditAdvanced ( ) . click ( ) ;
92+ // add custom header
93+ advancedSettingsDialog . setHeaderContent ( "curateTile/customHeader" ) ;
94+ cy . waitUntil ( ( ) => advancedSettingsDialog . saveSettings ( mapStep ) . click ( { force : true } ) ) ;
95+ advancedSettingsDialog . saveSettings ( mapStep ) . should ( "not.exist" ) ;
96+ // map source to entity
97+ curatePage . openSourceToEntityMap ( "Order" , mapStep ) ;
98+ cy . waitUntil ( ( ) => sourceToEntityMap . expandCollapseEntity ( ) . should ( "be.visible" ) ) . click ( ) ;
99+ sourceToEntityMap . setXpathExpressionInput ( "orderId" , "OrderID" ) ;
100+ sourceToEntityMap . setXpathExpressionInput ( "address" , "/" ) ;
101+ sourceToEntityMap . setXpathExpressionInput ( "city" , "ShipCity" ) ;
102+ sourceToEntityMap . setXpathExpressionInput ( "state" , "ShipAddress" ) ;
103+ sourceToEntityMap . setXpathExpressionInput ( "orderDetails" , "/" ) ;
104+ sourceToEntityMap . setXpathExpressionInput ( "productID" , "OrderDetails/ProductID" ) ;
105+ sourceToEntityMap . setXpathExpressionInput ( "unitPrice" , "head(OrderDetails/UnitPrice)" ) ;
106+ sourceToEntityMap . setXpathExpressionInput ( "quantity" , "OrderDetails/Quantity" ) ;
107+ sourceToEntityMap . setXpathExpressionInput ( "discount" , "head(OrderDetails/Discount)" ) ;
108+ sourceToEntityMap . setXpathExpressionInput ( "shipRegion" , "ShipRegion" ) ;
109+ sourceToEntityMap . setXpathExpressionInput ( "shippedDate" , "ShippedDate" ) ;
110+ // close modal
111+ cy . get ( "body" ) . type ( "{esc}" ) ;
112+ } ) ;
113+ it ( "Add Map step to new flow and Run" , ( ) => {
114+ //Cancel add to new flow
115+ curatePage . addToNewFlow ( "Order" , mapStep ) ;
116+ cy . findByText ( "New Flow" ) . should ( "be.visible" ) ;
117+ loadPage . confirmationOptions ( "Cancel" ) . click ( ) ;
118+ //should route user back to curate page
119+ cy . waitUntil ( ( ) => curatePage . getEntityTypePanel ( "Order" ) . should ( "be.visible" ) ) ;
120+ curatePage . openExistingFlowDropdown ( "Order" , mapStep ) ;
121+ curatePage . getExistingFlowFromDropdown ( flowName ) . click ( ) ;
122+ curatePage . addStepToFlowConfirmationMessage ( ) ;
123+ curatePage . confirmAddStepToFlow ( mapStep , flowName ) ;
124+ runPage . runStep ( mapStep ) . click ( ) ;
125+ cy . verifyStepRunResult ( "success" , "Mapping" , mapStep ) ;
126+ tiles . closeRunMessage ( ) ;
127+ runPage . deleteStep ( mapStep ) . click ( ) ;
128+ loadPage . confirmationOptions ( "Yes" ) . click ( ) ;
129+ } ) ;
130+ it ( "Add Map step to existing flow Run" , ( ) => {
131+ //Verify Run Map step in an existing Flow
132+ toolbar . getCurateToolbarIcon ( ) . click ( ) ;
133+ cy . waitUntil ( ( ) => curatePage . getEntityTypePanel ( "Customer" ) . should ( "be.visible" ) ) ;
134+ curatePage . toggleEntityTypeId ( "Order" ) ;
135+ curatePage . runStepInCardView ( mapStep ) . click ( ) ;
136+ curatePage . runStepSelectFlowConfirmation ( ) . should ( "be.visible" ) ;
137+ curatePage . selectFlowToRunIn ( flowName ) ;
138+ //Step should automatically run
139+ cy . verifyStepRunResult ( "success" , "Mapping" , mapStep ) ;
140+ tiles . closeRunMessage ( ) ;
141+ } ) ;
142+ it ( "Delete the flow and Verify Run Map step in a new Flow" , ( ) => {
143+ runPage . deleteFlow ( flowName ) . click ( ) ;
144+ runPage . deleteFlowConfirmationMessage ( flowName ) . should ( "be.visible" ) ;
145+ loadPage . confirmationOptions ( "Yes" ) . click ( ) ;
146+ runPage . getFlowName ( flowName ) . should ( "not.be.visible" ) ;
147+ //Verify Run Map step in a new Flow
148+ toolbar . getCurateToolbarIcon ( ) . click ( ) ;
149+ cy . waitUntil ( ( ) => curatePage . getEntityTypePanel ( "Customer" ) . should ( "be.visible" ) ) ;
150+ curatePage . toggleEntityTypeId ( "Order" ) ;
151+ curatePage . runStepInCardView ( mapStep ) . click ( ) ;
152+ //Just deleted flow should not be visible on flows list
153+ cy . findByText ( flowName ) . should ( "not.be.visible" ) ;
154+ curatePage . runInNewFlow ( mapStep ) . click ( { force : true } ) ;
155+ cy . findByText ( "New Flow" ) . should ( "be.visible" ) ;
156+ runPage . setFlowName ( flowName ) ;
157+ runPage . setFlowDescription ( `${ flowName } description` ) ;
158+ loadPage . confirmationOptions ( "Save" ) . click ( ) ;
159+ //Step should automatically run
160+ cy . verifyStepRunResult ( "success" , "Mapping" , mapStep ) ;
161+ tiles . closeRunMessage ( ) ;
162+ } ) ;
163+ it ( "Verify Run Map step in flow where step exists, should run automatically" , ( ) => {
164+ toolbar . getCurateToolbarIcon ( ) . click ( ) ;
165+ cy . waitUntil ( ( ) => curatePage . getEntityTypePanel ( "Customer" ) . should ( "be.visible" ) ) ;
166+ curatePage . toggleEntityTypeId ( "Order" ) ;
167+ curatePage . runStepInCardView ( mapStep ) . click ( ) ;
168+ curatePage . runStepExistsOneFlowConfirmation ( ) . should ( "be.visible" ) ;
169+ curatePage . confirmContinueRun ( ) ;
170+ cy . waitForAsyncRequest ( ) ;
171+ cy . verifyStepAddedToFlow ( "Map" , mapStep ) ;
172+ cy . waitUntil ( ( ) => runPage . getFlowName ( flowName ) . should ( "be.visible" ) ) ;
173+ cy . verifyStepRunResult ( "success" , "Mapping" , mapStep ) ;
174+ tiles . closeRunMessage ( ) ;
175+ } ) ;
176+ it ( "Add step to a new flow, Run Map step where step exists in multiple flows and explore data" , ( ) => {
177+ toolbar . getCurateToolbarIcon ( ) . click ( ) ;
178+ cy . waitUntil ( ( ) => curatePage . getEntityTypePanel ( "Customer" ) . should ( "be.visible" ) ) ;
179+ curatePage . toggleEntityTypeId ( "Order" ) ;
180+ curatePage . addToNewFlow ( "Order" , mapStep ) ;
181+ cy . findByText ( "New Flow" ) . should ( "be.visible" ) ;
182+ runPage . setFlowName ( flowName2 ) ;
183+ runPage . setFlowDescription ( `${ flowName2 } description` ) ;
184+ loadPage . confirmationOptions ( "Save" ) . click ( ) ;
185+ cy . verifyStepAddedToFlow ( "Map" , mapStep ) ;
186+ //Verify Run Map step where step exists in multiple flows, choose one to automatically run in
187+ toolbar . getCurateToolbarIcon ( ) . click ( ) ;
188+ cy . waitUntil ( ( ) => curatePage . getEntityTypePanel ( "Customer" ) . should ( "be.visible" ) ) ;
189+ curatePage . toggleEntityTypeId ( "Order" ) ;
190+ curatePage . runStepInCardView ( mapStep ) . click ( ) ;
191+ curatePage . runStepExistsMultFlowsConfirmation ( ) . should ( "be.visible" ) ;
192+ curatePage . selectFlowToRunIn ( flowName ) ;
193+ cy . waitForAsyncRequest ( ) ;
194+ cy . verifyStepAddedToFlow ( "Map" , mapStep ) ;
195+ cy . waitUntil ( ( ) => runPage . getFlowName ( flowName ) . should ( "be.visible" ) ) ;
196+ cy . verifyStepRunResult ( "success" , "Mapping" , mapStep ) ;
197+ runPage . explorerLink ( ) . click ( ) ;
198+ browsePage . getTableViewInstanceIcon ( ) . click ( ) ;
199+ detailPage . getDocumentSource ( ) . should ( "contain" , "backup-ABC123" ) ;
200+ detailPage . getDocumentTimestamp ( ) . should ( "not.exist" ) ;
201+ detailPage . getSourceView ( ) . click ( ) ;
202+ cy . contains ( "accessLevel" ) ;
203+ cy . contains ( "999ABC" ) ;
204+ } ) ;
205+ } ) ;
0 commit comments