Skip to content

Commit 412b9c2

Browse files
Merge pull request #627 from Real-Dev-Squad/develop
sync dev to main
2 parents 9040a60 + a6434e6 commit 412b9c2

File tree

14 files changed

+683
-263
lines changed

14 files changed

+683
-263
lines changed

__tests__/taskRequests/taskRequest.test.js

Lines changed: 88 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,25 @@ describe('Task Requests', () => {
1212

1313
jest.setTimeout(60000);
1414

15-
beforeAll(async () => {
15+
beforeEach(async () => {
1616
browser = await puppeteer.launch({
1717
headless: 'new',
1818
ignoreHTTPSErrors: true,
1919
args: ['--incognito', '--disable-web-security'],
2020
devtools: false,
2121
});
22-
22+
});
23+
beforeEach(async () => {
2324
page = await browser.newPage();
2425

2526
await page.setRequestInterception(true);
2627

2728
page.on('request', (request) => {
2829
if (
2930
request.url() === `${API_BASE_URL}/taskRequests` ||
30-
request.url() === `${API_BASE_URL}/taskRequests?dev=true`
31+
request.url() === `${API_BASE_URL}/taskRequests?dev=true` ||
32+
request.url() ===
33+
`${API_BASE_URL}/taskRequests?size=20&q=status%3Apending+sort%3Acreated-asc&dev=true`
3134
) {
3235
request.respond({
3336
status: 200,
@@ -39,19 +42,37 @@ describe('Task Requests', () => {
3942
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
4043
},
4144
});
45+
} else if (
46+
request.url() ===
47+
`${API_BASE_URL}/taskRequests?size=20&q=status%3Aapproved++sort%3Acreated-asc&dev=true`
48+
) {
49+
const list = [];
50+
for (let i = 0; i < 20; i++) {
51+
list.push(fetchedTaskRequests[0]);
52+
}
53+
request.respond({
54+
status: 200,
55+
contentType: 'application/json',
56+
body: JSON.stringify({
57+
data: list,
58+
next: '/taskRequests?size=20&q=status%3Aapproved++sort%3Acreated-asc&dev=true',
59+
}),
60+
});
4261
} else {
4362
request.continue();
4463
}
4564
});
46-
4765
await page.goto(`${SITE_URL}/taskRequests`);
4866
await page.waitForNetworkIdle();
4967
});
5068

69+
afterEach(async () => {
70+
await page.close();
71+
});
72+
5173
afterAll(async () => {
5274
await browser.close();
5375
});
54-
5576
describe('When the user is super user', () => {
5677
it('should display the task requests card', async () => {
5778
const url = await page.evaluate(() => API_BASE_URL);
@@ -68,11 +89,6 @@ describe('Task Requests', () => {
6889
expect(purpose).toMatch(/test purpose/i);
6990
});
7091
describe('Filter Modal', () => {
71-
beforeAll(async () => {
72-
await page.goto(`${SITE_URL}/taskRequests/?dev=true`);
73-
await page.waitForNetworkIdle();
74-
});
75-
7692
it('should be hidden initially', async () => {
7793
const modal = await page.$('.filter-modal');
7894
expect(
@@ -84,28 +100,63 @@ describe('Task Requests', () => {
84100
const modal = await page.$('.filter-modal');
85101
const filterHead = await page.$('.filter-head');
86102
const filterContainer = await page.$('.filters-container');
87-
88103
expect(filterHead).toBeTruthy();
89104
expect(filterContainer).toBeTruthy();
90-
91105
await page.click('#filter-button');
92106
expect(modal).not.toBeNull();
93107
expect(
94108
await modal.evaluate((el) => el.classList.contains('hidden')),
95109
).toBe(false);
96-
97110
await page.mouse.click(20, 20);
98111
expect(
99112
await modal.evaluate((el) => el.classList.contains('hidden')),
100113
).toBe(true);
101114
});
115+
116+
it('checks if PENDING is checked by default', async () => {
117+
const filterButton = await page.$('#filter-button');
118+
await filterButton.click();
119+
await page.waitForSelector('.filter-modal');
120+
const activeFilter = await page.$('input[value="PENDING"]');
121+
const currentState = await activeFilter.getProperty('checked');
122+
const isChecked = await currentState.jsonValue();
123+
expect(isChecked).toBe(true);
124+
});
125+
126+
it('Selecting filters and clicking on apply should filter task request list', async () => {
127+
let cardsList = await page.$$('.taskRequest__card');
128+
expect(cardsList).not.toBeNull();
129+
const initialLength = cardsList.length;
130+
await page.click('#filter-button');
131+
await page.click('input[value="PENDING"]');
132+
await page.click('input[value="APPROVED"]');
133+
await page.click('#apply-filter-button');
134+
await page.waitForNetworkIdle();
135+
cardsList = await page.$$('.taskRequest__card');
136+
expect(cardsList).not.toBeNull();
137+
expect(cardsList.length).toBeGreaterThanOrEqual(0);
138+
expect(cardsList.length).not.toBe(initialLength);
139+
});
140+
141+
it('clears the filter when the Clear button is clicked', async () => {
142+
const filterButton = await page.$('#filter-button');
143+
await filterButton.click();
144+
await page.waitForSelector('.filter-modal');
145+
const activeFilter = await page.$('input[value="APPROVED"]');
146+
await activeFilter.click();
147+
const clearButton = await page.$('.filter-modal #clear-button');
148+
await clearButton.click();
149+
await page.waitForSelector('.filter-modal', { hidden: true });
150+
const currentState = await activeFilter.getProperty('checked');
151+
const isChecked = await currentState.jsonValue();
152+
expect(isChecked).toBe(false);
153+
});
102154
});
103155

104156
describe('Sort Modal', () => {
105157
it('should be hidden initially', async () => {
106158
const sortModal = await page.$('.sort-modal');
107-
const assigneButton = await page.$('#ASSIGNEE_COUNT');
108-
159+
const assigneButton = await page.$('#REQUESTORS_COUNT_ASC');
109160
expect(
110161
await sortModal.evaluate((el) => el.classList.contains('hidden')),
111162
).toBe(true);
@@ -114,15 +165,15 @@ describe('Task Requests', () => {
114165

115166
it('should toggle visibility sort modal by clicking the sort button and selecting an option', async () => {
116167
const sortModal = await page.$('.sort-modal');
117-
const assigneButton = await page.$('#ASSIGNEE_COUNT');
168+
const assigneButton = await page.$('#REQUESTORS_COUNT_ASC');
118169
const sortHead = await page.$('.sort-head');
119170
const sortContainer = await page.$('.sorts-container');
120171

121172
expect(sortHead).toBeTruthy();
122173
expect(sortContainer).toBeTruthy();
123174

124175
await page.click('.sort-button');
125-
await page.click('#ASSIGNEE_COUNT');
176+
await page.click('#REQUESTORS_COUNT_ASC');
126177
expect(
127178
await assigneButton.evaluate((el) =>
128179
el.classList.contains('selected'),
@@ -131,9 +182,8 @@ describe('Task Requests', () => {
131182
expect(
132183
await sortModal.evaluate((el) => el.classList.contains('hidden')),
133184
).toBe(true);
134-
135185
await page.click('.sort-button');
136-
await page.click('#ASSIGNEE_COUNT');
186+
await page.click('#REQUESTORS_COUNT_ASC');
137187
expect(
138188
await assigneButton.evaluate((el) =>
139189
el.classList.contains('selected'),
@@ -144,6 +194,25 @@ describe('Task Requests', () => {
144194
).toBe(true);
145195
});
146196
});
197+
198+
it('Checks that new items are loaded when scrolled to the bottom', async () => {
199+
await page.click('#filter-button');
200+
await page.click('input[value="PENDING"]');
201+
await page.click('input[value="APPROVED"]');
202+
await page.click('#apply-filter-button');
203+
await page.waitForNetworkIdle();
204+
let taskRequestList = await page.$$('.taskRequest__card');
205+
expect(taskRequestList.length).toBe(20);
206+
await page.evaluate(() => {
207+
const element = document.querySelector('.virtual');
208+
if (element) {
209+
element.scrollIntoView({ behavior: 'auto' });
210+
}
211+
});
212+
await page.waitForNetworkIdle();
213+
taskRequestList = await page.$$('.taskRequest__card');
214+
expect(taskRequestList.length).toBe(40);
215+
});
147216
});
148217
});
149218

__tests__/taskRequests/taskRequestDetails.test.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const {
44
defaultMockResponseHeaders,
55
} = require('../../mock-data/taskRequests');
66

7-
describe('Tests the User Management User Listing Screen', () => {
7+
describe('Task request details page', () => {
88
let browser;
99
let page;
1010
jest.setTimeout(60000);
@@ -32,18 +32,18 @@ describe('Tests the User Management User Listing Screen', () => {
3232
await page.goto(
3333
'http://localhost:8000/taskRequests/details/?id=dM5wwD9QsiTzi7eG7Oq5',
3434
);
35-
await page.waitForNetworkIdle();
36-
await page.click('.requestors__container__list__userDetails');
37-
await page.waitForSelector('#requestor_details_modal_content', {
38-
visible: true,
39-
});
4035
});
4136

4237
afterAll(async () => {
4338
await browser.close();
4439
});
4540

4641
it('Checks the Modal working as expected', async () => {
42+
await page.waitForNetworkIdle();
43+
await page.click('.info__more');
44+
await page.waitForSelector('#requestor_details_modal_content', {
45+
visible: true,
46+
});
4747
const modalHeading = await page.$eval(
4848
'[data-modal-header="requestor-details-header"]',
4949
(element) => element.textContent,
@@ -88,4 +88,11 @@ describe('Tests the User Management User Listing Screen', () => {
8888
'code change 3 days , testing - 2 days. total - 5 days',
8989
);
9090
});
91+
92+
it('Should contain Approve and Reject buttons', async function () {
93+
const approveButton = await page.$('.requestors__conatainer__list__button');
94+
const rejectButton = await page.$('.request-details__reject__button');
95+
expect(approveButton).toBeTruthy();
96+
expect(rejectButton).toBeTruthy();
97+
});
9198
});

index.html

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,17 @@
2727
<div class="line"></div>
2828
</div>
2929
<div class="links">
30-
<a href="">Welcome</a>
31-
<a href="">Events</a>
32-
<a href="">Members</a>
33-
<a href="">Status</a>
30+
<a href="https://welcome.realdevsquad.com/">Welcome</a>
31+
<a href="https://www.realdevsquad.com/events">Events</a>
32+
<a href="https://members.realdevsquad.com/">Members</a>
33+
<a href="https://status.realdevsquad.com/tasks">Status</a>
3434
</div>
3535
</div>
3636
<div class="sign-in-btn">
37-
<a
38-
href="https://github.com/login/oauth/authorize?client_id=23c78f66ab7964e5ef97"
39-
>Sign In <span>With GitHub</span>
37+
<button onclick="goToAuthPage()">
38+
Sign In <span>With GitHub</span>
4039
<img src="images/github.png" class="user-avatar" />
41-
</a>
40+
</button>
4241
</div>
4342
<div class="user-info">
4443
<span id="user-name"></span>

mock-data/taskRequests/index.js

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,24 @@ const fetchedTaskRequests = [
1414
priority: 'HIGH',
1515
status: 'ASSIGNED',
1616
},
17+
users: [
18+
{
19+
proposedStartDate: 1700304616479,
20+
proposedDeadline: 1700909416479,
21+
userId: 'eChYAP0kUwLo4wQ1gqMV',
22+
status: 'PENDING',
23+
username: 'ajeyak',
24+
first_name: 'Test first_name',
25+
},
26+
],
1727
requestors: [
1828
{
19-
userExists: true,
20-
user: {
21-
id: 'V4rqL1aDecNGoa1IxiCu',
22-
incompleteUserDetails: false,
23-
discordId: '12345',
24-
roles: {
25-
archived: false,
26-
},
27-
linkedin_id: 'uiram',
28-
last_name: 'Raghunathan',
29-
yoe: '5',
30-
github_display_name: 'Sriram',
31-
company_name: 'Juniper networks ',
32-
github_id: '19sriram',
33-
designation: 'Front end engineer',
34-
twitter_id: '19sriram',
35-
first_name: 'Sriram',
36-
username: '19sriram',
37-
},
29+
proposedStartDate: 1700304616479,
30+
proposedDeadline: 1700909416479,
31+
userId: 'eChYAP0kUwLo4wQ1gqMV',
32+
status: 'PENDING',
33+
username: 'ajeyak',
34+
first_name: 'Test first_name',
3835
},
3936
],
4037
},
@@ -47,23 +44,21 @@ const individualTaskReqDetail = {
4744
lastModifiedAt: 1698837978463,
4845
requestType: 'ASSIGNMENT',
4946
createdBy: 'randhir',
50-
requestors: ['SooJK37gzjIZfFNH0tlL'],
5147
lastModifiedBy: 'randhir',
5248
taskTitle: 'sample golang task s402',
5349
externalIssueUrl:
5450
'https://api.github.com/repos/Real-Dev-Squad/website-backend/issues/1310',
5551
taskId: '44SwDPe1r6AgoOtWq8EN',
56-
approvedTo: 'SooJK37gzjIZfFNH0tlL',
5752
users: [
5853
{
5954
proposedStartDate: 1698684354000,
6055
proposedDeadline: 1699142400000,
6156
description: 'code change 3 days , testing - 2 days. total - 5 days',
6257
userId: 'SooJK37gzjIZfFNH0tlL',
63-
status: 'APPROVED',
58+
status: 'PENDING',
6459
},
6560
],
66-
status: 'APPROVED',
61+
status: 'PENDING',
6762
id: 'dM5wwD9QsiTzi7eG7Oq5',
6863
url: 'http://localhost:3000/taskRequests/dM5wwD9QsiTzi7eG7Oq5',
6964
},
@@ -142,6 +137,14 @@ const urlMappings = {
142137
userInformation,
143138
'https://staging-api.realdevsquad.com/users/userId/SooJK37gzjIZfFNH0tlL':
144139
userInformation,
140+
'https://staging-api.realdevsquad.com/taskRequests?action=approve':
141+
fetchedTaskRequests,
142+
'https://api.realdevsquad.com/taskRequests?action=approve':
143+
fetchedTaskRequests,
144+
'https://staging-api.realdevsquad.com/taskRequests?action=reject':
145+
fetchedTaskRequests,
146+
'https://api.realdevsquad.com/taskRequests?action=reject':
147+
fetchedTaskRequests,
145148
};
146149

147150
module.exports = {

style.css

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,23 @@ img {
8181
order: 3;
8282
}
8383

84-
.sign-in-btn a {
84+
.sign-in-btn button {
8585
position: absolute;
8686
right: 10px;
8787
margin: 10px;
8888
height: 30px;
89+
width: fit-content;
8990
padding: 5px;
9091
background-color: var(--blue-color);
9192
color: var(--white-color);
9293
cursor: pointer;
9394
border: 2px solid var(--white-color);
9495
border-radius: 6px;
9596
text-decoration: none;
97+
font-size: 16px;
9698
}
9799

98-
.sign-in-btn a img {
100+
.sign-in-btn button img {
99101
height: 15px;
100102
width: 15px;
101103
position: relative;
@@ -465,7 +467,7 @@ footer {
465467
justify-content: space-between;
466468
}
467469

468-
.sign-in-btn a {
470+
.sign-in-btn button {
469471
position: static;
470472
}
471473

0 commit comments

Comments
 (0)