@@ -4,6 +4,7 @@ import { CommonHelper } from '../common-page/common.helper';
44import { HeaderPage } from '../header/header.po' ;
55import { BrowserHelper , ElementHelper } from 'topcoder-testing-lib' ;
66import { logger } from '../../../../logger/logger' ;
7+ import { ChallengeDetailPageObject } from '../challenge-detail/challenge-detail.po' ;
78
89export class ChallengeListingPageHelper {
910 /**
@@ -309,94 +310,30 @@ export class ChallengeListingPageHelper {
309310 }
310311
311312 static async selectDateRange ( ) {
312- await CommonHelper . waitUntil (
313- ( ) => async ( ) => {
314- const daterange = await ChallengeListingPageObject . dateRangeStartDate ( ) ;
315- if ( ! ( await CommonHelper . isDisplayed ( daterange ) ) ) {
316- return false ;
317- }
318- return await CommonHelper . isDisplayed ( daterange ) ;
319- } ,
320- 'wait for day range field' ,
321- true
313+ await CommonHelper . waitUntilVisibilityOf (
314+ ( ) => ChallengeListingPageObject . subCommunityLabel ,
315+ 'Wait for sub community label' ,
316+ false
322317 ) ;
318+ let filtersVisibility = await CommonHelper . isDisplayed ( ChallengeListingPageObject . subCommunityLabel ) ;
319+ expect ( filtersVisibility ) . toBe ( true ) ;
323320
324- const days = [
325- 'Sunday' ,
326- 'Monday' ,
327- 'Tuesday' ,
328- 'Wednesday' ,
329- 'Thursday' ,
330- 'Friday' ,
331- 'Saturday' ,
332- ] ;
333- const months = [
334- 'January' ,
335- 'February' ,
336- 'March' ,
337- 'April' ,
338- 'May' ,
339- 'June' ,
340- 'July' ,
341- 'August' ,
342- 'September' ,
343- 'October' ,
344- 'November' ,
345- 'December' ,
346- ] ;
347-
348- const now = new Date ( ) ;
349- const currentDay = days [ now . getDay ( ) ] ;
350- const currentMonth = months [ now . getMonth ( ) ] ;
351- const currentYear = now . getFullYear ( ) ;
352-
353- const nowPlusOne = new Date ( ) ;
354- nowPlusOne . setDate ( nowPlusOne . getDate ( ) + 1 ) ;
355-
356- const nextDay = days [ nowPlusOne . getDay ( ) ] ;
357- const nextDayMonth = months [ nowPlusOne . getMonth ( ) ] ;
358- const nextDayYear = nowPlusOne . getFullYear ( ) ;
359-
360- const currentDayAriaText =
361- 'Choose ' +
362- currentDay +
363- ', ' +
364- currentMonth +
365- ' ' +
366- now . getDate ( ) +
367- ', ' +
368- currentYear +
369- ' as your check-in date. It’s available.' ;
370- const nextDayAriaText =
371- 'Choose ' +
372- nextDay +
373- ', ' +
374- nextDayMonth +
375- ' ' +
376- nowPlusOne . getDate ( ) +
377- ', ' +
378- nextDayYear +
379- ' as your check-out date. It’s available.' ;
380-
381- const dateRangeStartDate = await ChallengeListingPageObject . dateRangeStartDate ( ) ;
382- await dateRangeStartDate . click ( ) ;
383- await BrowserHelper . sleep ( 1000 ) ;
384- await CommonHelper . getLinkByAriaLabel ( currentDayAriaText ) . click ( ) ;
385- await CommonHelper . getLinkByAriaLabel ( nextDayAriaText ) . click ( ) ;
386- await BrowserHelper . sleep ( 1000 ) ;
321+ await ChallengeListingPageObject . pastChallengesTab . click ( ) ;
387322 }
388323
389- static async verifyNumberOfAppliedFilters (
390- expectedNumberOfAppliedFilters : number
391- ) {
392- const appliedFiltersText = await ChallengeListingPageObject . appliedFilters . getText ( ) ;
393- if ( expectedNumberOfAppliedFilters === 0 ) {
394- expect ( appliedFiltersText ) . toEqual ( 'Filters' ) ;
395- } else {
396- expect ( appliedFiltersText ) . toEqual (
397- 'Filters' + expectedNumberOfAppliedFilters
398- ) ;
324+ static async verifyPastChallenges ( ) {
325+ await ChallengeListingPageObject . pastMonth . click ( ) ;
326+ await this . waitForLoadingNewChallengeList ( ) ;
327+ const challenges = await ChallengeListingPageObject . challengeLinks ;
328+ for ( let i = 0 ; i < challenges . length ; i ++ ) {
329+ let dates = await ElementHelper . getAllElementsByClassName ( 'JV6Mui' ) ;
330+
331+ for ( let i = 0 ; i < dates . length ; i ++ ) {
332+ const skill = await dates [ i ] . getText ( ) ;
333+ expect ( skill ) . toContain ( 'Ended' ) ;
334+ }
399335 }
336+
400337 }
401338
402339 static async verifyFilterByKeywordsAndType ( ) {
0 commit comments