Skip to content

Commit ecd6511

Browse files
Ishan VeerIshan Veer
authored andcommitted
Merge branch 'develop' of https://github.com/Real-Dev-Squad/website-dashboard into feature/user-data-pagination
2 parents b68987a + d1641bd commit ecd6511

File tree

27 files changed

+836
-284
lines changed

27 files changed

+836
-284
lines changed

__tests__/applications/applications.test.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,4 +295,35 @@ describe('Applications page', () => {
295295
);
296296
await page.waitForNetworkIdle();
297297
});
298+
299+
it('should display the footer with the correct repo link', async () => {
300+
const footer = await page.$('[data-test-id="footer"]');
301+
expect(footer).toBeTruthy();
302+
303+
const infoRepo = await footer.$('[data-test-id="info-repo"]');
304+
expect(infoRepo).toBeTruthy();
305+
306+
const repoLink = await infoRepo.$('[data-test-id="repo-link"]');
307+
expect(repoLink).toBeTruthy();
308+
309+
const repoLinkHref = await page.evaluate((el) => el.href, repoLink);
310+
expect(repoLinkHref).toBe(
311+
'https://github.com/Real-Dev-Squad/website-dashboard',
312+
);
313+
314+
const repoLinkTarget = await page.evaluate((el) => el.target, repoLink);
315+
expect(repoLinkTarget).toBe('_blank');
316+
317+
const repoLinkRel = await page.evaluate((el) => el.rel, repoLink);
318+
expect(repoLinkRel).toBe('noopener noreferrer');
319+
320+
const repoLinkText = await page.evaluate((el) => el.innerText, repoLink);
321+
expect(repoLinkText).toBe('open sourced repo');
322+
323+
const repoLinkClass = await page.evaluate((el) => el.className, repoLink);
324+
expect(repoLinkClass).toBe('');
325+
326+
const repoLinkStyle = await page.evaluate((el) => el.style, repoLink);
327+
expect(repoLinkStyle).toBeTruthy();
328+
});
298329
});

__tests__/extension-requests/extension-requests.test.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,106 @@ describe('Tests the Extension Requests Screen', () => {
640640
expect(cardCount === 3 || cardCount === 7).toBe(true);
641641
});
642642

643+
it('checks whether the shimmer effect is visible under dev flag only for the assignee image element', async () => {
644+
await page.goto(`${baseUrl}/?dev=true`);
645+
const assignImageSelector = await page.$$(
646+
'[data-testid="assignee-image skeleton"]',
647+
);
648+
expect(assignImageSelector).toBeTruthy();
649+
650+
await page.waitForTimeout(5000);
651+
const hasSkeletonClassAfter = await page.$eval('.assignee-image', (el) =>
652+
el.classList.contains('skeleton'),
653+
);
654+
expect(hasSkeletonClassAfter).toBe(false);
655+
});
656+
657+
it('checks whether the shimmer effect is visible under dev flag only for the assignee name element', async () => {
658+
await page.goto(`${baseUrl}/?dev=true`);
659+
const assignNameSelector = await page.$$(
660+
'[data-testid="assignee-name skeleton-text"]',
661+
);
662+
expect(assignNameSelector).toBeTruthy();
663+
await page.waitForTimeout(5000);
664+
const hasSkeletonClassAfter = await page.$eval('.assignee-name', (el) =>
665+
el.classList.contains('skeleton-text'),
666+
);
667+
expect(hasSkeletonClassAfter).toBe(false);
668+
});
669+
670+
it('checks whether the shimmer effect is working for deadlineValue element under feature flag', async () => {
671+
await page.goto(`${baseUrl}/?dev=true`);
672+
const deadlineValueSelector = await page.$$(
673+
'[data-testid="skeleton-span"]',
674+
);
675+
expect(deadlineValueSelector).toBeTruthy();
676+
await page.waitForTimeout(5000);
677+
const hasSkeletonClassAfter = await page.$eval('.tooltip-container', (el) =>
678+
el.classList.contains('skeleton-span'),
679+
);
680+
expect(hasSkeletonClassAfter).toBe(false);
681+
});
682+
683+
it('checks whether the shimmer effect is working for requestedValue element under feature flag', async () => {
684+
await page.goto(`${baseUrl}/?dev=true`);
685+
const requestedValueSelector = await page.$$(
686+
'[data-testid="skeleton-text"]',
687+
);
688+
expect(requestedValueSelector).toBeTruthy();
689+
await page.waitForTimeout(5000);
690+
const hasSkeletonClassAfter = await page.$eval('.requested-day', (el) =>
691+
el.classList.contains('skeleton-text'),
692+
);
693+
expect(hasSkeletonClassAfter).toBe(false);
694+
});
695+
it('checks whether the shimmer effect is working for newDeadlineValue element under feature flag', async () => {
696+
await page.goto(`${baseUrl}/?dev=true`);
697+
const newDeadlineValueSelector = await page.$$(
698+
'[data-testid="skeleton-span"]',
699+
);
700+
expect(newDeadlineValueSelector).toBeTruthy();
701+
await page.waitForTimeout(5000);
702+
const hasSkeletonClassAfter = await page.$eval('.requested-day', (el) =>
703+
el.classList.contains('skeleton-span'),
704+
);
705+
expect(hasSkeletonClassAfter).toBe(false);
706+
});
707+
708+
it('checks whether the shimmer effect is working for extensionRequestNumberValue element under feature flag', async () => {
709+
await page.goto(`${baseUrl}/?dev=true`);
710+
const extensionRequestNumberValueSelector = await page.$$(
711+
'[data-testid="skeleton-span"]',
712+
);
713+
expect(extensionRequestNumberValueSelector).toBeTruthy();
714+
await page.waitForTimeout(5000);
715+
const hasSkeletonClassAfter = await page.$eval(
716+
'.extension-request-number',
717+
(el) => el.classList.contains('skeleton-span'),
718+
);
719+
expect(hasSkeletonClassAfter).toBe(false);
720+
});
721+
722+
it('checks whether the shimmer effect is visible under dev flag only for the statusSiteLink element', async () => {
723+
await page.goto(`${baseUrl}/?dev=true`);
724+
const statusSiteLinkSelector = await page.$$(
725+
'[data-testid="external-link skeleton-link"]',
726+
);
727+
expect(statusSiteLinkSelector).toBeTruthy();
728+
await page.waitForTimeout(5000);
729+
const hasSkeletonClassAfter = await page.$eval('.external-link', (el) =>
730+
el.classList.contains('skeleton-link'),
731+
);
732+
expect(hasSkeletonClassAfter).toBe(false);
733+
});
734+
735+
it('checks whether the shimmer effect is visible under dev flag only for the taskStatusValue element', async () => {
736+
await page.goto(`${baseUrl}/?dev=true`);
737+
const taskStatusValueElement = await page.$$(
738+
'[data-testid="skeleton-span"]',
739+
);
740+
expect(taskStatusValueElement).toBeTruthy();
741+
});
742+
643743
it('Checks whether the card is not removed from display when api call is unsuccessful', async () => {
644744
const extensionCards = await page.$$('.extension-card');
645745

__tests__/groups/group.test.js

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('Discord Groups Page', () => {
6060
},
6161
body: JSON.stringify(discordGroups),
6262
});
63-
} else if (url === `${BASE_URL}/discord-actions/groups?dev=true`) {
63+
} else if (url === `${BASE_URL}/discord-actions/groups`) {
6464
interceptedRequest.respond({
6565
status: 200,
6666
contentType: 'application/json',
@@ -244,9 +244,9 @@ describe('Discord Groups Page', () => {
244244
expect(groupCreationModalClosed).toBeFalsy();
245245
});
246246

247-
test('Should display only specified groups when dev=true and name=<group-name> with different case', async () => {
247+
test('Should display only specified groups when name=<group-name> with different case', async () => {
248248
const groupNames = 'fIrSt,DSA+COdInG';
249-
await page.goto(`${PAGE_URL}/groups?dev=true&name=${groupNames}`);
249+
await page.goto(`${PAGE_URL}/groups?name=${groupNames}`);
250250
await page.waitForNetworkIdle();
251251

252252
const displayedGroups = await page.evaluate(() => {
@@ -259,11 +259,42 @@ describe('Discord Groups Page', () => {
259259
});
260260

261261
test('Should display no group found div when no group is present', async () => {
262-
await page.goto(`${PAGE_URL}/groups?dev=true&name=no-group-present`);
262+
await page.goto(`${PAGE_URL}/groups?name=no-group-present`);
263263
await page.waitForNetworkIdle();
264264

265265
const noGroupDiv = await page.$('.no-group-container');
266266

267267
expect(noGroupDiv).toBeTruthy();
268268
});
269+
270+
it('should display the footer with the correct repo link', async () => {
271+
const footer = await page.$('[data-test-id="footer"]');
272+
expect(footer).toBeTruthy();
273+
274+
const infoRepo = await footer.$('[data-test-id="info-repo"]');
275+
expect(infoRepo).toBeTruthy();
276+
277+
const repoLink = await infoRepo.$('[data-test-id="repo-link"]');
278+
expect(repoLink).toBeTruthy();
279+
280+
const repoLinkHref = await page.evaluate((el) => el.href, repoLink);
281+
expect(repoLinkHref).toBe(
282+
'https://github.com/Real-Dev-Squad/website-dashboard',
283+
);
284+
285+
const repoLinkTarget = await page.evaluate((el) => el.target, repoLink);
286+
expect(repoLinkTarget).toBe('_blank');
287+
288+
const repoLinkRel = await page.evaluate((el) => el.rel, repoLink);
289+
expect(repoLinkRel).toBe('noopener noreferrer');
290+
291+
const repoLinkText = await page.evaluate((el) => el.innerText, repoLink);
292+
expect(repoLinkText).toBe('open sourced repo');
293+
294+
const repoLinkClass = await page.evaluate((el) => el.className, repoLink);
295+
expect(repoLinkClass).toBe('');
296+
297+
const repoLinkStyle = await page.evaluate((el) => el.style, repoLink);
298+
expect(repoLinkStyle).toBeTruthy();
299+
});
269300
});

__tests__/task-requests/task-requestDetails.test.js

Lines changed: 71 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,63 @@ const {
33
urlMappings,
44
defaultMockResponseHeaders,
55
} = require('../../mock-data/taskRequests');
6+
const { user } = require('../../mock-data/users/index.js');
7+
8+
describe('Request container for non-super users', () => {
9+
let browser;
10+
let page;
11+
jest.setTimeout(60000);
12+
13+
beforeAll(async () => {
14+
browser = await puppeteer.launch({
15+
headless: 'new',
16+
ignoreHTTPSErrors: true,
17+
args: ['--incognito', '--disable-web-security'],
18+
devtools: false,
19+
});
20+
page = await browser.newPage();
21+
await page.setRequestInterception(true);
22+
page.on('request', (interceptedRequest) => {
23+
const url = interceptedRequest.url();
24+
if (url == 'https://staging-api.realdevsquad.com/users/self') {
25+
interceptedRequest.respond({
26+
...defaultMockResponseHeaders,
27+
body: JSON.stringify(user),
28+
});
29+
} else if (urlMappings.hasOwnProperty(url)) {
30+
interceptedRequest.respond({
31+
...defaultMockResponseHeaders,
32+
body: JSON.stringify(urlMappings[url]),
33+
});
34+
} else {
35+
interceptedRequest.continue();
36+
}
37+
});
38+
await page.goto(
39+
'http://localhost:8000/task-requests/details/?id=dM5wwD9QsiTzi7eG7Oq5&dev=true',
40+
);
41+
});
42+
43+
afterAll(async () => {
44+
await browser.close();
45+
});
46+
47+
it('Approve and Reject buttons should not render for non-super users', async function () {
48+
await page.waitForNetworkIdle();
49+
const approveButton = await page.$('[data-testid="task-approve-button"]');
50+
const rejectButton = await page.$('[data-testid="task-reject-button"]');
51+
expect(approveButton).toBeNull();
52+
expect(rejectButton).toBeNull();
53+
});
54+
55+
it('Should render task status for non-super users', async function () {
56+
await page.waitForNetworkIdle();
57+
const taskRequestStatus = await page.$(
58+
'[data-testid="requestors-task-status"]',
59+
);
60+
expect(taskRequestStatus).toBeTruthy();
61+
});
62+
});
663

764
describe('Task request details page', () => {
865
let browser;
@@ -89,9 +146,13 @@ describe('Task request details page', () => {
89146
);
90147
});
91148

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');
149+
it('Should render Approve and Reject buttons for super users', async function () {
150+
await page.goto(
151+
'http://localhost:8000/task-requests/details/?id=dM5wwD9QsiTzi7eG7Oq5&dev=true',
152+
);
153+
await page.waitForNetworkIdle();
154+
const approveButton = await page.$('[data-testid="task-approve-button"]');
155+
const rejectButton = await page.$('[data-testid="task-reject-button"]');
95156
expect(approveButton).toBeTruthy();
96157
expect(rejectButton).toBeTruthy();
97158
});
@@ -180,9 +241,13 @@ describe('Task request details page with markdown support in description', () =>
180241
expect(descriptionHtmlValue).toContain('<h3 id="heading">Heading</h3>');
181242
});
182243

183-
it('Should contain Approve and Reject buttons', async function () {
184-
const approveButton = await page.$('.requestors__conatainer__list__button');
185-
const rejectButton = await page.$('.request-details__reject__button');
244+
it('Should render Approve and Reject buttons for super users', async function () {
245+
await page.goto(
246+
'http://localhost:8000/task-requests/details/?id=dM5wwD9QsiTzi7eG7Oq6&dev=true',
247+
);
248+
await page.waitForNetworkIdle();
249+
const approveButton = await page.$('[data-testid="task-approve-button"]');
250+
const rejectButton = await page.$('[data-testid="task-reject-button"]');
186251
expect(approveButton).toBeTruthy();
187252
expect(rejectButton).toBeTruthy();
188253
});

0 commit comments

Comments
 (0)