-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make navigation for challenge slick carousel and corresponding test #1995
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
|
||
import BasePage from "./BasePage"; | ||
import { expect } from "@playwright/test"; | ||
|
||
class ChallengeInfoPage extends BasePage { | ||
constructor(page) { | ||
super(page); | ||
this.viewChallengeButton = page.getByRole("button", { name: "Переглянути челендж" }); | ||
this.viewChallengeTitle = page.locator("span.title"); | ||
this.slickCard = page.locator("div.slick-slide"); | ||
this.slickCardsNames = page.locator("div.slick-slide div.name"); | ||
this.slickDots = page.locator("ul.slick-dots li"); | ||
this.slickRightArrow = page.locator("div.challenge-day-block span[aria-label='arrow-right']:nth-child(2) svg"); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Invalid locator nth-child(2) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. $$("span.arrows-next svg") |
||
this.challengePageTitle = page.locator("h1.ant-typography"); | ||
this.challengeSortNumber = page.locator("input#sortNumber"); | ||
this.challengeStatus = page.locator("button#isActive"); | ||
|
@@ -15,6 +23,37 @@ class ChallengeInfoPage extends BasePage { | |
this.challengeTasksNames = page.locator("td:nth-child(2)"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Invalid locator nth-child(2) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. $$("td.ant-table-cell > a.table-name[href*='task']") There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. $x("//a[contains(text(),'Task_second')]") |
||
} | ||
|
||
async openViewChallenge() { | ||
await this.viewChallengeButton.click(); | ||
await this.verifyElementVisibility(this.viewChallengeTitle); | ||
} | ||
|
||
async verifyTaskOnChallengeView(taskName) { | ||
// Step 1: Verify the existence of the task in the slick carousel | ||
await this.verifyElementExistance(this.slickCardsNames, taskName); | ||
|
||
// Step 2: Find the target card based on the provided taskName | ||
const targetCard = await this.slickCard.filter({ hasText: taskName }); | ||
|
||
// Step 3: Loop through challenge tasks until the target card is active | ||
await this.navigateToTargetTask(targetCard); | ||
} | ||
|
||
async navigateToTargetTask(targetCard) { | ||
const dotsCount = await this.slickDots.count(); | ||
|
||
let i = 0; | ||
while (i < dotsCount && !(await this.isCardActive(targetCard))) { | ||
await this.slickRightArrow.click(); | ||
i++; | ||
} | ||
expect(await this.isCardActive(targetCard)).toBeTruthy(); | ||
} | ||
|
||
async isCardActive(card) { | ||
const slickClass = await card.getAttribute("class"); | ||
return slickClass.includes("slick-active"); | ||
} | ||
} | ||
|
||
module.exports = ChallengeInfoPage; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,10 +15,6 @@ let apiservice, challengespage, challengeinfopage,taskspage, addchallengepage, a | |
apiservice = new ApiService(page); | ||
challengespage = new ChallengesPage(page); | ||
await apiservice.apiLoginAs('admin'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use Const for "admin" |
||
// await apiservice.deleteChallengeBySequenceNumber(newChallengeCorrectDetails.SEQUENCE_NUMBER) | ||
// await apiservice.deleteChallengeBySequenceNumber(editedChallengeCorrectDetails.SEQUENCE_NUMBER) | ||
// await apiservice.deleteTaskByName(editedTaskCorrectDetails.NAME); | ||
// await apiservice.deleteTaskByName(newTaskCorrectDetails.NAME); | ||
}) | ||
|
||
test("Verify that a new challenge can be successfully created", async ({ page }) => { | ||
|
@@ -171,9 +167,28 @@ let apiservice, challengespage, challengeinfopage,taskspage, addchallengepage, a | |
}); | ||
|
||
|
||
// test("Verify that the user can navigate through challenge's existing tasks", async({page})=>{ | ||
// await apiservice.createNewChallenge(); | ||
// }) | ||
test("Verify that the user can navigate through challenge's existing tasks", async({page})=>{ | ||
taskspage = new TasksPage(page); | ||
challengeinfopage = new ChallengeInfoPage(page); | ||
await apiservice.deleteTaskByName(createTaskRequest.body.name); | ||
await apiservice.deleteTaskByName(createTaskRequest2.body.name); | ||
await apiservice.deleteTaskByName(createTaskRequest3.body.name); | ||
await apiservice.deleteTaskByName(createTaskRequest4.body.name); | ||
|
||
await apiservice.createNewChallenge(createChallengeRequest); | ||
await apiservice.createNewTask(createTaskRequest); | ||
await apiservice.changeTaskDateToToday(createTaskRequest.body.name); | ||
await apiservice.createNewTask(createTaskRequest2); | ||
await apiservice.changeTaskDateToToday(createTaskRequest2.body.name); | ||
await apiservice.createNewTask(createTaskRequest3); | ||
await apiservice.changeTaskDateToToday(createTaskRequest3.body.name); | ||
await apiservice.createNewTask(createTaskRequest4); | ||
await apiservice.changeTaskDateToToday(createTaskRequest4.body.name); | ||
await challengespage.gotoChallengesPage(); | ||
await challengespage.openChallengeInfoPage(createChallengeRequest.body.sortNumber); | ||
await challengeinfopage.openViewChallenge(); | ||
await challengeinfopage.verifyTaskOnChallengeView(createTaskRequest4.body.name); | ||
}) | ||
|
||
|
||
test.afterEach(async({page})=>{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use const for "Переглянути челендж"