11import { BrowserHelper } from 'topcoder-testing-lib' ;
2+ import { ConfigHelper } from '../../../utils/config-helper' ;
23import { CommonHelper } from '../../common-page/common.helper' ;
3- import { IAnswers , IProjectData } from './create-project.model' ;
4+ import { IAnswers , IProjectData , ITaasData } from './create-project.model' ;
45import { CreateProjectPageObject } from './create-project.po' ;
56
67export class CreateProjectPageHelper {
@@ -29,8 +30,8 @@ export class CreateProjectPageHelper {
2930
3031 await this . clickNewProjectButton ( ) ;
3132 await this . navigateToViewSolutions ( ) ;
32- await this . clickOnDesignDevelopmentDeploymentButton ( ) ;
33- await this . fillBeforeWeStartForm ( projectData . answers ) ;
33+ await this . clickOnSelectButton ( ) ;
34+ await this . fillBeforeWeStartForm ( projectData . answers , 'Basic Details' ) ;
3435 await this . fillBasicDetailsForm (
3536 appNameWithDate ,
3637 projectData . appDescription
@@ -40,6 +41,29 @@ export class CreateProjectPageHelper {
4041 await this . goToYourProject ( appNameWithDate ) ;
4142 }
4243
44+ /**
45+ * verify whether the current user can create a TAAS project
46+ */
47+ public static async verifyTaasProject ( taasData : ITaasData ) {
48+ await this . clickNewProjectButton ( ) ;
49+ await this . navigateToTopTalent ( ) ;
50+ await this . clickOnSelectButton ( ) ;
51+ await this . fillBeforeWeStartForm ( taasData . answers , 'Talent as a Service: Getting Started' ) ;
52+ await this . fillTaasProjectTitleForm ( taasData . title ) ;
53+ await this . verifyAddJobItem ( ) ;
54+ await this . verifyDeleteJobItem ( ) ;
55+ await this . fillJobForm ( taasData ) ;
56+ await this . fillTalentRequirementForm ( taasData . answers , 'Your Talent Requirements' ) ;
57+ await this . fillRequirementForm ( taasData . answers , taasData . email ) ;
58+
59+ await this . createProjectPageObject . submitJobRequest . click ( ) ;
60+ await CommonHelper . verifySuccessAlert ( `PROJECT '${ taasData . title . toUpperCase ( ) } ' CREATED` ) ;
61+
62+ await this . createProjectPageObject . viewTalentRequestButton . click ( ) ;
63+ await BrowserHelper . sleep ( 10000 ) ;
64+ await CommonHelper . verifyPageUrl ( ConfigHelper . getPlatformUrl ( ) ) ;
65+ }
66+
4367 private static createProjectPageObject : CreateProjectPageObject ;
4468
4569 /**
@@ -100,10 +124,19 @@ export class CreateProjectPageHelper {
100124 expect ( title ) . toBe ( 'TOPCODER SOLUTIONS' ) ;
101125 }
102126
127+ /**
128+ * Click on "Tap Into Top Talen" under "TAAS" section
129+ */
130+ private static async navigateToTopTalent ( ) {
131+ await this . createProjectPageObject . tapIntoTopTalent . click ( ) ;
132+ const title = await this . createProjectPageObject . solutionCatalogTitle . getText ( ) ;
133+ expect ( title ) . toBe ( 'ENGAGE TALENT' ) ;
134+ }
135+
103136 /**
104137 * Click on "Select" button under Design, Development and Deployment.
105138 */
106- private static async clickOnDesignDevelopmentDeploymentButton ( ) {
139+ private static async clickOnSelectButton ( ) {
107140 const selectButton = await this . createProjectPageObject . selectButton ( ) ;
108141 await selectButton . click ( ) ;
109142 await this . verifyFormDisplayed ( 'Before we start' ) ;
@@ -112,14 +145,29 @@ export class CreateProjectPageHelper {
112145 /**
113146 * Fill Before We Start form
114147 * @param answers answers object defined by test data
148+ * @param formTitle form title to be expected
115149 */
116- private static async fillBeforeWeStartForm ( answers : IAnswers ) {
150+ private static async fillBeforeWeStartForm ( answers : IAnswers , formTitle : string ) {
117151 const { beforeWeStart } = answers ;
118152 await CommonHelper . selectInputByContainingText ( beforeWeStart ) ;
119153
120154 await this . createProjectPageObject . nextButton . click ( ) ;
121155
122- await this . verifyFormDisplayed ( 'Basic Details' ) ;
156+ await this . verifyFormDisplayed ( formTitle ) ;
157+ }
158+
159+ /**
160+ * Fill Before We Start form
161+ * @param answers answers object defined by test data
162+ * @param formTitle form title to be expected
163+ */
164+ private static async fillTalentRequirementForm ( answers : IAnswers , formTitle : string ) {
165+ const { startDate } = answers ;
166+ await CommonHelper . selectInputByContainingText ( startDate ) ;
167+
168+ await this . createProjectPageObject . nextButton . click ( ) ;
169+
170+ await this . verifyFormDisplayed ( formTitle ) ;
123171 }
124172
125173 /**
@@ -138,6 +186,69 @@ export class CreateProjectPageHelper {
138186 await this . verifyFormDisplayed ( 'App Definition' ) ;
139187 }
140188
189+ /**
190+ * Fill Taas Project title, then click next
191+ * @param title taas application title
192+ */
193+ private static async fillTaasProjectTitleForm ( title : string ) {
194+ const name = this . createProjectPageObject . appNameInput ;
195+ await CommonHelper . fillInputField ( name , title ) ;
196+ await this . createProjectPageObject . nextButton . click ( ) ;
197+
198+ await this . verifyFormDisplayed ( 'Your Talent Requirements' ) ;
199+ }
200+
201+ /**
202+ * Fill Requirement Form, then click next
203+ * @param title taas application title
204+ * @param email
205+ */
206+ private static async fillRequirementForm ( answers : IAnswers , email : string ) {
207+ const { requirement } = answers ;
208+ await CommonHelper . selectInputByContainingText ( requirement ) ;
209+
210+ await this . createProjectPageObject . emailInput . click ( ) ;
211+ await this . createProjectPageObject . emailInput . sendKeys ( email ) ;
212+
213+ await this . createProjectPageObject . nextButton . click ( ) ;
214+ }
215+
216+ /**
217+ * Fill Taas Job Form
218+ * @param taasData
219+ */
220+ private static async fillJobForm ( taasData : ITaasData ) {
221+ const { jobTitle, numOfPeople, duration, description } = taasData ;
222+
223+ const titleEl = this . createProjectPageObject . titleInput ;
224+ await CommonHelper . fillInputField ( titleEl , jobTitle ) ;
225+
226+ const numberInputs = await this . createProjectPageObject . numberInputEls ( ) ;
227+ await CommonHelper . fillInputField ( numberInputs [ 0 ] , numOfPeople + '' ) ;
228+ await CommonHelper . fillInputField ( numberInputs [ 1 ] , duration + '' ) ;
229+
230+ const dropdownInputs = await this . createProjectPageObject . dropdownEls ( ) ;
231+ await dropdownInputs [ 0 ] . click ( ) ;
232+ let dropdownOptions = await this . createProjectPageObject . dropdownOptions ( ) ;
233+ await dropdownOptions [ 1 ] . click ( ) ;
234+
235+ await dropdownInputs [ 1 ] . click ( ) ;
236+ dropdownOptions = await this . createProjectPageObject . dropdownOptions ( ) ;
237+ await BrowserHelper . sleep ( 200 ) ;
238+ await dropdownOptions [ 6 ] . click ( ) ;
239+
240+ await this . createProjectPageObject . editorTextarea . click ( ) ;
241+ await this . createProjectPageObject . editorTextareaInput . sendKeys ( description ) ;
242+
243+ await this . createProjectPageObject . skillsInput . click ( ) ;
244+ await BrowserHelper . sleep ( 2500 ) ;
245+ await this . createProjectPageObject . multiSelectOption . click ( ) ;
246+
247+ await this . createProjectPageObject . nextButton . click ( ) ;
248+
249+ await this . verifyFormDisplayed ( 'Your Talent Requirements' ) ;
250+ }
251+
141252 /**
142253 * Fill App Definition Form, then click next
143254 * @param projectData project data from test data
@@ -191,4 +302,22 @@ export class CreateProjectPageHelper {
191302
192303 expect ( await CommonHelper . projectTitle ( ) . getText ( ) ) . toBe ( appName ) ;
193304 }
305+
306+ /**
307+ * Add job item and verify Add Job Item
308+ */
309+ private static async verifyAddJobItem ( ) {
310+ await this . createProjectPageObject . plusIcon . click ( ) ;
311+ let jobFormNumber = await this . createProjectPageObject . taasJobForm ( ) ;
312+ expect ( jobFormNumber . length ) . toBe ( 2 ) ;
313+ }
314+
315+ /**
316+ * Delete job item and verify Deletion of Job Item
317+ */
318+ private static async verifyDeleteJobItem ( ) {
319+ await this . createProjectPageObject . deleteIcon . click ( ) ;
320+ const jobFormNumber = await this . createProjectPageObject . taasJobForm ( ) ;
321+ expect ( jobFormNumber . length ) . toBe ( 1 ) ;
322+ }
194323}
0 commit comments