Skip to content

Commit 18e204a

Browse files
Merge pull request #5465 from nursoltan-s/nursoltan-s-smoke-test
fix test TC_020, TC_010
2 parents fe1024c + cfc9632 commit 18e204a

File tree

3 files changed

+96
-186
lines changed

3 files changed

+96
-186
lines changed

automated-smoke-test/page-objects/pages/topcoder/challenge-listing/challenge-listing.helper.ts

Lines changed: 48 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { CommonHelper } from '../common-page/common.helper';
44
import { HeaderPage } from '../header/header.po';
55
import { BrowserHelper, ElementHelper } from 'topcoder-testing-lib';
66
import { logger } from '../../../../logger/logger';
7+
import { ChallengeDetailPageObject } from '../challenge-detail/challenge-detail.po';
78

89
export class ChallengeListingPageHelper {
910
/**
@@ -64,20 +65,6 @@ export class ChallengeListingPageHelper {
6465
expect(firstChallengeName).toEqual(searchString);
6566
}
6667

67-
/**
68-
* verify filter by toggle
69-
*/
70-
static async verifyFilterToggle() {
71-
await this.openFiltersPanel();
72-
let filtersVisibility = await CommonHelper.isDisplayed(ChallengeListingPageObject.keywordsLabel);
73-
expect(filtersVisibility).toBe(true);
74-
await ChallengeListingPageObject.filterButton.click();
75-
filtersVisibility = await CommonHelper.isDisplayed(
76-
ChallengeListingPageObject.keywordsLabel
77-
);
78-
expect(filtersVisibility).toBe(false);
79-
}
80-
8168
/**
8269
* select keyword
8370
*/
@@ -174,7 +161,7 @@ export class ChallengeListingPageHelper {
174161
await this.waitForLoadingNewChallengeList();
175162
const challenges = await ChallengeListingPageObject.challengeLinks;
176163
for (let i = 0; i < challenges.length; i++) {
177-
const parentDiv = ElementHelper.getElementByXPath('..', challenges[i]);
164+
const parentDiv = ElementHelper.getElementByXPath('../..', challenges[i]);
178165
let skills = await ElementHelper.getAllElementsByCss(
179166
'button[type=button]',
180167
parentDiv
@@ -208,17 +195,17 @@ export class ChallengeListingPageHelper {
208195
}
209196
}
210197

211-
static async verifyFilterByKeywords() {
212-
await this.openFiltersPanel();
198+
static async verifyFilterByKeywordSearch() {
213199
await CommonHelper.waitUntilVisibilityOf(
214-
() => ChallengeListingPageObject.keywordsLabel,
215-
'Wait for keywords label',
200+
() => ChallengeListingPageObject.subCommunityLabel,
201+
'Wait for sub community label',
216202
false
217203
);
218-
let filtersVisibility = await CommonHelper.isDisplayed(ChallengeListingPageObject.keywordsLabel);
204+
let filtersVisibility = await CommonHelper.isDisplayed(ChallengeListingPageObject.subCommunityLabel);
219205
expect(filtersVisibility).toBe(true);
220206

221-
await this.selectKeyword('Java');
207+
await ChallengeListingPageObject.challengeSearchBox.sendKeys('Java');
208+
await BrowserHelper.sleep(5000);
222209
await this.verifyChallengesMatchingKeyword(['Java']);
223210
}
224211

@@ -242,22 +229,25 @@ export class ChallengeListingPageHelper {
242229
}
243230

244231
static async verifyFilterByType() {
245-
await this.openFiltersPanel();
246232
await CommonHelper.waitUntilVisibilityOf(
247-
() => ChallengeListingPageObject.typeLabel,
248-
'Wait for type label',
233+
() => ChallengeListingPageObject.subCommunityLabel,
234+
'Wait for type sub community label',
249235
false
250236
);
251-
let filtersVisibility = await CommonHelper.isDisplayed(ChallengeListingPageObject.typeLabel);
237+
let filtersVisibility = await CommonHelper.isDisplayed(ChallengeListingPageObject.subCommunityLabel);
252238
expect(filtersVisibility).toBe(true);
253-
await this.selectType('First2Finish');
254239

240+
await ChallengeListingPageObject.challengeCheckbox.click();
241+
await ChallengeListingPageObject.taskCheckbox.click();
242+
243+
await BrowserHelper.sleep(5000);
255244
await this.viewMoreChallenges();
256245

257246
// need to sleep to wait for ajax calls to be completed to filter using the above type
258247
await this.waitForLoadingNewChallengeList();
259-
const count = await this.getOpenForRegistrationChallengesCount();
260-
await this.verifyChallengesMatchingType(count, [{ name: 'F2F' }]);
248+
const openForRegistrationCount = await ChallengeListingPageObject.openForRegistrationCount();
249+
const count = await openForRegistrationCount.getText();
250+
await this.verifyChallengesMatchingType(parseInt(count), [{ name: 'F2F' }]);
261251
}
262252

263253
static async selectSubCommunity(index: number) {
@@ -283,7 +273,6 @@ export class ChallengeListingPageHelper {
283273
}
284274

285275
static async verifyFilterBySubCommunity() {
286-
await this.openFiltersPanel();
287276
await CommonHelper.waitUntilVisibilityOf(
288277
() => ChallengeListingPageObject.subCommunityLabel,
289278
'Wait for sub community label',
@@ -321,111 +310,34 @@ export class ChallengeListingPageHelper {
321310
}
322311

323312
static async selectDateRange() {
324-
await CommonHelper.waitUntil(
325-
() => async () => {
326-
const daterange = await ChallengeListingPageObject.dateRangeStartDate();
327-
if (!(await CommonHelper.isDisplayed(daterange))) {
328-
return false;
329-
}
330-
return await CommonHelper.isDisplayed(daterange);
331-
},
332-
'wait for day range field',
333-
true
313+
await CommonHelper.waitUntilVisibilityOf(
314+
() => ChallengeListingPageObject.subCommunityLabel,
315+
'Wait for sub community label',
316+
false
334317
);
318+
let filtersVisibility = await CommonHelper.isDisplayed(ChallengeListingPageObject.subCommunityLabel);
319+
expect(filtersVisibility).toBe(true);
335320

336-
const days = [
337-
'Sunday',
338-
'Monday',
339-
'Tuesday',
340-
'Wednesday',
341-
'Thursday',
342-
'Friday',
343-
'Saturday',
344-
];
345-
const months = [
346-
'January',
347-
'February',
348-
'March',
349-
'April',
350-
'May',
351-
'June',
352-
'July',
353-
'August',
354-
'September',
355-
'October',
356-
'November',
357-
'December',
358-
];
359-
360-
const now = new Date();
361-
const currentDay = days[now.getDay()];
362-
const currentMonth = months[now.getMonth()];
363-
const currentYear = now.getFullYear();
364-
365-
const nowPlusOne = new Date();
366-
nowPlusOne.setDate(nowPlusOne.getDate() + 1);
367-
368-
const nextDay = days[nowPlusOne.getDay()];
369-
const nextDayMonth = months[nowPlusOne.getMonth()];
370-
const nextDayYear = nowPlusOne.getFullYear();
371-
372-
const currentDayAriaText =
373-
'Choose ' +
374-
currentDay +
375-
', ' +
376-
currentMonth +
377-
' ' +
378-
now.getDate() +
379-
', ' +
380-
currentYear +
381-
' as your check-in date. It’s available.';
382-
const nextDayAriaText =
383-
'Choose ' +
384-
nextDay +
385-
', ' +
386-
nextDayMonth +
387-
' ' +
388-
nowPlusOne.getDate() +
389-
', ' +
390-
nextDayYear +
391-
' as your check-out date. It’s available.';
392-
393-
const dateRangeStartDate = await ChallengeListingPageObject.dateRangeStartDate();
394-
await dateRangeStartDate.click();
395-
await BrowserHelper.sleep(1000);
396-
await CommonHelper.getLinkByAriaLabel(currentDayAriaText).click();
397-
await CommonHelper.getLinkByAriaLabel(nextDayAriaText).click();
398-
await BrowserHelper.sleep(1000);
321+
await ChallengeListingPageObject.pastChallengesTab.click();
399322
}
400323

401-
static async verifyNumberOfAppliedFilters(
402-
expectedNumberOfAppliedFilters: number
403-
) {
404-
const appliedFiltersText = await ChallengeListingPageObject.appliedFilters.getText();
405-
if (expectedNumberOfAppliedFilters === 0) {
406-
expect(appliedFiltersText).toEqual('Filters');
407-
} else {
408-
expect(appliedFiltersText).toEqual(
409-
'Filters' + expectedNumberOfAppliedFilters
410-
);
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+
}
411335
}
412-
}
413336

414-
static async verifyFilterByKeywordsAndType() {
415-
await this.selectKeyword('Java');
416-
await this.selectType('Challenge');
417-
await this.verifyChallengesMatchingKeyword(['Java']);
418-
const count = await this.getOpenForRegistrationChallengesCount();
419-
await this.verifyChallengesMatchingType(count, [{ name: 'CH' }]);
420337
}
421338

422-
/**
423-
* verify filter by multiple keywords
424-
*/
425-
static async verifyFilterByMultipleKeywords() {
426-
await this.selectKeyword('Java');
427-
await this.selectKeyword('HTML5');
428-
await this.verifyChallengesMatchingKeyword(['Java', 'HTML5']);
339+
static async verifyFilterByKeywordsAndType() {
340+
await this.verifyFilterByKeywordSearch();
429341
}
430342

431343
/**
@@ -446,14 +358,12 @@ export class ChallengeListingPageHelper {
446358
* verify filter by multiple types
447359
*/
448360
static async verifyFilterByMultipleTypes() {
449-
await this.selectType('Challenge');
450-
await this.selectType('First2Finish');
451-
452-
// await this.viewMoreChallenges();
361+
await ChallengeListingPageObject.taskCheckbox.click();
453362

454-
const count = await this.getOpenForRegistrationChallengesCount();
363+
const openForRegistrationCount = await ChallengeListingPageObject.openForRegistrationCount();
364+
const count = await openForRegistrationCount.getText();
455365

456-
await this.verifyChallengesMatchingType(count, [
366+
await this.verifyChallengesMatchingType(parseInt(count), [
457367
{ name: 'F2F' },
458368
{ name: 'CH' },
459369
]);
@@ -639,8 +549,12 @@ export class ChallengeListingPageHelper {
639549
const challenges = await ChallengeListingPageObject.filterChallengesBy(
640550
tabName
641551
);
642-
let challengesText = await challenges.getText();
643-
challengesText = challengesText.replace(/(\r\n|\n|\r)/gm, ' ');
552+
let challengesText = '';
553+
if (challenges) {
554+
challengesText = await challenges.getText();
555+
challengesText = challengesText.replace(/(\r\n|\n|\r)/gm, ' ');
556+
}
557+
644558
const count = parseInt(challengesText.split(tabName)[1]);
645559
return count || 0;
646560
}

automated-smoke-test/page-objects/pages/topcoder/challenge-listing/challenge-listing.po.ts

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class ChallengeListingPageObject {
6969
* Get filter sub community label field
7070
*/
7171
static get subCommunityDropdown() {
72-
return ElementHelper.getElementById('react-select-3--value-item');
72+
return ElementHelper.getElementById('react-select-2--value-item');
7373
}
7474

7575
/**
@@ -93,6 +93,42 @@ export class ChallengeListingPageObject {
9393
return ElementHelper.getElementById('type-select');
9494
}
9595

96+
/**
97+
* Get past challenges tab
98+
*/
99+
static get pastChallengesTab() {
100+
return ElementHelper.getTagElementContainingText('li', 'Past Challenges');
101+
}
102+
103+
/**
104+
* Get past month select option
105+
*/
106+
static get pastMonth() {
107+
return ElementHelper.getElementByCss('label[for="Past Month"]');
108+
}
109+
110+
/**
111+
* Get challenge checkbox
112+
*/
113+
static get challengeCheckbox() {
114+
return ElementHelper.getElementByCss('label[for=Challenge]');
115+
}
116+
117+
/**
118+
* Get F2F checkbox
119+
*/
120+
static get first2FinishCheckbox() {
121+
return ElementHelper.getElementByCss('label[for=First2Finish]');
122+
}
123+
124+
/**
125+
* Get Task checkbox
126+
*/
127+
static get taskCheckbox() {
128+
return ElementHelper.getElementByCss('label[for=Task]');
129+
}
130+
131+
96132
/**
97133
* Get view more challenges button
98134
*/
@@ -112,6 +148,14 @@ export class ChallengeListingPageObject {
112148
return els[1];
113149
}
114150

151+
/**
152+
* Get open for registration count
153+
*/
154+
static async openForRegistrationCount() {
155+
const els = await ElementHelper.getAllElementsByClassName('_23WWoe');
156+
return els[0];
157+
}
158+
115159
/**
116160
* Get all elements that contain text
117161
* @param elementType element type
@@ -240,7 +284,7 @@ export class ChallengeListingPageObject {
240284
static async findSkillsForChallenge(challenge: TcElementImpl) {
241285
const buttons = await ElementHelper.getAllElementsByTag(
242286
'button',
243-
ElementHelper.getElementByXPath('..', challenge)
287+
ElementHelper.getElementByXPath('../..', challenge)
244288
);
245289
const skills = [];
246290
for (let j = 0; j < buttons.length; j++) {

0 commit comments

Comments
 (0)