Skip to content

Commit

Permalink
Fix Task Request Details Page (#602)
Browse files Browse the repository at this point in the history
* fix oversize image, adds toasts and assignedTo

* adds modal on click of avatar and name

* test for modal

* fix failing test

* change cursor style to indicate clickable

* fix failing test

* fix the failing test condition

* add safety check for taskrequest which dont have users info

* resolve Sunny comment on the PR

* resolve comments from Bhavika

* fixes the event listener on the global window obj

* fixes failing test

* rename variable and remove commented code
  • Loading branch information
heyrandhir authored Nov 6, 2023
1 parent 96852f4 commit 3a1faba
Show file tree
Hide file tree
Showing 7 changed files with 540 additions and 32 deletions.
3 changes: 2 additions & 1 deletion __tests__/extension-requests/extension-requests.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,8 @@ describe('Tests the Extension Requests Screen', () => {

const extensionCardsAfter = await page.$$('.extension-card');

expect(extensionCardsAfter.length).toBe(3);
const cardCount = extensionCardsAfter.length;
expect(cardCount === 3 || cardCount === 7).toBe(true);
});

it('Checks whether the card is not removed from display when api call is unsuccessful', async () => {
Expand Down
91 changes: 91 additions & 0 deletions __tests__/taskRequests/taskRequestDetails.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
const puppeteer = require('puppeteer');
const {
urlMappings,
defaultMockResponseHeaders,
} = require('../../mock-data/taskRequests');

describe('Tests the User Management User Listing Screen', () => {
let browser;
let page;
jest.setTimeout(60000);

beforeAll(async () => {
browser = await puppeteer.launch({
headless: true,
ignoreHTTPSErrors: true,
args: ['--incognito', '--disable-web-security'],
devtools: false,
});
page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', (interceptedRequest) => {
const url = interceptedRequest.url();
if (urlMappings.hasOwnProperty(url)) {
interceptedRequest.respond({
...defaultMockResponseHeaders,
body: JSON.stringify(urlMappings[url]),
});
} else {
interceptedRequest.continue();
}
});
await page.goto(
'http://localhost:8000/taskRequests/details/?id=dM5wwD9QsiTzi7eG7Oq5',
);
await page.waitForNetworkIdle();
await page.click('.requestors__container__list__userDetails');
await page.waitForSelector('#requestor_details_modal_content', {
visible: true,
});
});

afterAll(async () => {
await browser.close();
});

it('Checks the Modal working as expected', async () => {
const modalHeading = await page.$eval(
'[data-modal-header="requestor-details-header"]',
(element) => element.textContent,
);
expect(modalHeading).toBe('Requestor Details');

const proposedStartDateHeading = await page.$eval(
'[data-modal-start-date-text="proposed-start-date-text"]',
(element) => element.textContent,
);
expect(proposedStartDateHeading).toBe('Proposed Start Date:');

const proposedStartDateValue = await page.$eval(
'[data-modal-start-date-value="proposed-start-date-value"]',
(element) => element.textContent,
);
expect(proposedStartDateValue).toBe('30-10-2023');

const proposedEndDateHeading = await page.$eval(
'[data-modal-end-date-text="proposed-end-date-text"]',
(element) => element.textContent,
);
expect(proposedEndDateHeading).toBe('Proposed Deadline:');

const proposedEndDateValue = await page.$eval(
'[data-modal-end-date-value="proposed-end-date-value"]',
(element) => element.textContent,
);
expect(proposedEndDateValue).toBe('5-11-2023');

const descriptionTextHeading = await page.$eval(
'[data-modal-description-text="proposed-description-text"]',
(element) => element.textContent,
);
expect(descriptionTextHeading).toBe('Description:');

const descriptionTextValue = await page.$eval(
'[data-modal-description-value="proposed-description-value"]',
(element) => element.textContent,
);
expect(descriptionTextValue).toBe(
'code change 3 days , testing - 2 days. total - 5 days',
);
});
});
106 changes: 106 additions & 0 deletions mock-data/taskRequests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,112 @@ const fetchedTaskRequests = [
},
];

const individualTaskReqDetail = {
message: 'Task request returned successfully',
data: {
createdAt: 1698837978463,
lastModifiedAt: 1698837978463,
requestType: 'ASSIGNMENT',
createdBy: 'randhir',
requestors: ['SooJK37gzjIZfFNH0tlL'],
lastModifiedBy: 'randhir',
taskTitle: 'sample golang task s402',
externalIssueUrl:
'https://api.github.com/repos/Real-Dev-Squad/website-backend/issues/1310',
taskId: '44SwDPe1r6AgoOtWq8EN',
approvedTo: 'SooJK37gzjIZfFNH0tlL',
users: [
{
proposedStartDate: 1698684354,
proposedDeadline: 1699142400,
description: 'code change 3 days , testing - 2 days. total - 5 days',
userId: 'SooJK37gzjIZfFNH0tlL',
status: 'APPROVED',
},
],
status: 'APPROVED',
id: 'dM5wwD9QsiTzi7eG7Oq5',
url: 'http://localhost:3000/taskRequests/dM5wwD9QsiTzi7eG7Oq5',
},
};

const individualTaskDetail = {
message: 'task returned successfully',
taskData: {
percentCompleted: 100,
createdBy: 'randhir',
assignee: 'randhir',
type: 'feature',
priority: 'HIGH',
title: 'sample golang task',
endsOn: 1699142.4,
startedOn: 1698684.354,
status: 'ASSIGNED',
assigneeId: 'SooJK37gzjIZfFNH0tlL',
dependsOn: [],
},
};

const userInformation = {
message: 'User returned successfully!',
user: {
id: 'SooJK37gzjIZfFNH0tlL',
profileURL: 'https://rahul-goyal-profile-service.herokuapp.com/',
incompleteUserDetails: false,
profileStatus: 'VERIFIED',
last_name: 'singh',
picture: {
publicId: 'profile/DtR9sK7CysOVHP17zl8N/bbtkpea622crqotnhsa3',
url: 'https://res.cloudinary.com/realdevsquad/image/upload/v1673312957/profile/DtR9sK7CysOVHP17zl8N/bbtkpea622crqotnhsa3.jpg',
},
github_display_name: 'Randhir Kumar Singh',
github_id: 'heyrandhir',
company: 'cg',
designation: 'consultant',
status: 'active',
username: 'randhir',
first_name: 'randhir',
tokens: {
githubAccessToken: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
},
roles: {
super_user: true,
archived: false,
in_discord: true,
},
github_created_at: 1641642287000,
updated_at: 1698684157040,
created_at: 1698684157040,
},
};

const defaultMockResponseHeaders = {
status: 200,
contentType: 'application/json',
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
},
};

const urlMappings = {
'https://api.realdevsquad.com/taskRequests/dM5wwD9QsiTzi7eG7Oq5':
individualTaskReqDetail,
'https://staging-api.realdevsquad.com/taskRequests/dM5wwD9QsiTzi7eG7Oq5':
individualTaskReqDetail,
'https://api.realdevsquad.com/tasks/44SwDPe1r6AgoOtWq8EN/details':
individualTaskDetail,
'https://staging-api.realdevsquad.com/tasks/44SwDPe1r6AgoOtWq8EN/details':
individualTaskDetail,
'https://api.realdevsquad.com/users/userId/SooJK37gzjIZfFNH0tlL':
userInformation,
'https://staging-api.realdevsquad.com/users/userId/SooJK37gzjIZfFNH0tlL':
userInformation,
};

module.exports = {
fetchedTaskRequests,
defaultMockResponseHeaders,
urlMappings,
};
25 changes: 25 additions & 0 deletions taskRequests/details/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<script src="/helpers/loadENV.js"></script>
<script src="/taskRequests/util.js"></script>
<script src="/taskRequests/constants.js"></script>
<script src="/utils/time/index.js"></script>
<script src="/taskRequests/details/script.js" defer></script>
</head>
<body>
Expand Down Expand Up @@ -65,8 +66,32 @@ <h4 class="requestors__container__title">Requestors</h4>
<li class="skeleton"></li>
<li class="skeleton"></li>
</ul>
<!-- <div class="reject__container">
<button
id="reject-button"
class="requestors__container__reject__button"
>
Reject
</button>
</div> -->
</div>
</div>
</div>
<div id="toast_task_details" class="hidden">
<div class="message"></div>
</div>
<div id="overlay" class="overlay">
<div
id="requestor_details_modal_content"
class="requestor_details_modal_content"
>
<span
class="requestor_details_modal_close"
id="requestor_details_modal_close"
>&times;</span
>
<div class="requestor_details_modal_info"></div>
</div>
</div>
</body>
</html>
Loading

0 comments on commit 3a1faba

Please sign in to comment.