Skip to content
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

Split challenge manipulation test & refactor #2055

Merged
merged 1 commit into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/test/playwright/PO/ChallengesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ChallengesPage extends BasePage {
this.openTasksButton = page.locator('a.back-btn button');
this.addTaskButton = page.locator('a[href="/dev/admin/addTask"]');
this.allChallengesSequenceNumbers = page.locator(
`td.ant-table-cell:nth-child(${CHALLENGES_PAGE.sequenceNumberTableColumn})`
`td.ant-table-cell:nth-child(${CHALLENGES_PAGE.sequenceNumberTableColumn}) a`
);
this.firstChallenge = page.locator('tr:first-child td.ant-table-cell:first-child');
this.editChallengeButtons = page.locator('span.table-action').filter({ hasText: CHALLENGES_PAGE.edit });
Expand Down
2 changes: 1 addition & 1 deletion src/test/playwright/PO/TasksPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class TasksPage extends BasePage {
} else if (await this.isNextPageAvailable()) {
// If the club is not found on this page, checks if there's a next page and recursively search
await this.goToNextPage();
await this.selectTaskManageOption(challengeSortNumber, option);
await this.selectTaskManageOption(taskName, option);
} else {
// If the club is not found and there are no more pages, throws an error
throw new Error("No such task exists");
Expand Down
14 changes: 13 additions & 1 deletion src/test/playwright/constants/api.constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,23 @@ export const CREATE_CHALLENGE_REQUEST = {
},
};

export const CREATE_CHALLENGE_REQUEST_2 = {
url: "http://localhost:8080/dev/api/challenge",
method: "POST",
body: {
name: "Tasks Testing Challenge",
description: "Description for a challenge which purpose is to test tasks functionality. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident.",
title: "Test for a task",
picture: "/upload/challenges/challenge1.jpg",
sortNumber: 54321
},
};

export const CREATE_TASK_REQUEST = {
url: "http://localhost:8080/dev/api/challenge",
method: "POST",
body: {
name: "Super Task Name",
name: "First Task Request",
headerText: "Splendid test Task title. Minimum 40 chars",
description: "A new TASK test description. Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet.",
startDate: "2024-12-12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const EDITED_CHALLENGE_CORRECT_DETAILS = {
}

export const NEW_TASK_CORRECT_DETAILS = {
startDate: '2023-12-12',
startDate: '2024-06-12',
name: 'Super Task Name',
title: 'Splendid test Task title. Minimum 40 chars',
description: 'A new TASK test description. Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet.'
Expand Down
4 changes: 2 additions & 2 deletions src/test/playwright/services/ApiService.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import { expect} from "@playwright/test";
import { ADMIN_EMAIL, ADMIN_PASSWORD, USER_EMAIL, USER_PASSWORD } from "../constants/general.constants";
import {SIGN_IN_URL, CREATE_CLUB_REQUEST , USERS_CLUBS, CREATE_CHALLENGE_REQUEST, CREATE_TASK_REQUEST, GET_CHALLENGES_REQUEST, GET_TASK_REQUEST} from "../constants/api.constants";
import {SIGN_IN_URL, CREATE_CLUB_REQUEST , USERS_CLUBS, CREATE_CHALLENGE_REQUEST_2, CREATE_TASK_REQUEST, GET_CHALLENGES_REQUEST, GET_TASK_REQUEST} from "../constants/api.constants";


class ApiService {
Expand Down Expand Up @@ -164,7 +164,7 @@ class ApiService {
return;
}
const challenges = await this.getAllChallenges();
const challenge = challenges.find((c) => c.sortNumber === parseInt(CREATE_CHALLENGE_REQUEST.body.sortNumber));
const challenge = challenges.find((c) => c.sortNumber === parseInt(CREATE_CHALLENGE_REQUEST_2.body.sortNumber));
CREATE_TASK_REQUEST.body.challengeId = challenge.id;
if (challenge) {
const response = await fetch(`http://localhost:8080/dev/api/challenge/${challenge.id}/task`, {
Expand Down
Loading
Loading