Skip to content

Commit

Permalink
fixed merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Depayan Mondal committed Oct 30, 2024
2 parents 2070a11 + 44df325 commit d1dc513
Show file tree
Hide file tree
Showing 32 changed files with 935 additions and 301 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ on:
branches: [main, develop]
push:
branches: [main, develop]

jobs:
Lint-Check:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: yarn test
- uses: actions/checkout@v2

- name: Install system dependencies
run: |
echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
- name: Install project dependencies
run: yarn install

- name: Run tests
run: yarn test
54 changes: 54 additions & 0 deletions __tests__/applications/applications.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,23 @@ describe('Applications page', () => {
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
},
});
} else if (
request.url() ===
`${API_BASE_URL}/applications?size=6&status=pending&dev=true`
) {
request.respond({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
applications: acceptedApplications,
totalCount: acceptedApplications.length,
}),
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
},
});
} else {
request.continue();
}
Expand All @@ -129,6 +146,12 @@ describe('Applications page', () => {
expect(applicationCards.length).toBe(6);
});

it('should render the index of pending applications under dev flag === true', async function () {
await page.goto(`${SITE_URL}/applications?dev=true&status=pending`);
const indexOfApplication = await page.$$('[data-testid="user-index"]');
expect(indexOfApplication).toBeTruthy();
});

it('should render the initial UI elements under dev flag === true', async function () {
await page.goto(`${SITE_URL}/applications?dev=true`);
const title = await page.$('.header h1');
Expand Down Expand Up @@ -272,4 +295,35 @@ describe('Applications page', () => {
);
await page.waitForNetworkIdle();
});

it('should display the footer with the correct repo link', async () => {
const footer = await page.$('[data-test-id="footer"]');
expect(footer).toBeTruthy();

const infoRepo = await footer.$('[data-test-id="info-repo"]');
expect(infoRepo).toBeTruthy();

const repoLink = await infoRepo.$('[data-test-id="repo-link"]');
expect(repoLink).toBeTruthy();

const repoLinkHref = await page.evaluate((el) => el.href, repoLink);
expect(repoLinkHref).toBe(
'https://github.com/Real-Dev-Squad/website-dashboard',
);

const repoLinkTarget = await page.evaluate((el) => el.target, repoLink);
expect(repoLinkTarget).toBe('_blank');

const repoLinkRel = await page.evaluate((el) => el.rel, repoLink);
expect(repoLinkRel).toBe('noopener noreferrer');

const repoLinkText = await page.evaluate((el) => el.innerText, repoLink);
expect(repoLinkText).toBe('open sourced repo');

const repoLinkClass = await page.evaluate((el) => el.className, repoLink);
expect(repoLinkClass).toBe('');

const repoLinkStyle = await page.evaluate((el) => el.style, repoLink);
expect(repoLinkStyle).toBeTruthy();
});
});
103 changes: 101 additions & 2 deletions __tests__/extension-requests/extension-requests.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,14 +633,113 @@ describe('Tests the Extension Requests Screen', () => {
break;
}
}
await page.waitForTimeout(1650);
await page.waitForTimeout(2000);

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

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

it('checks whether the shimmer effect is visible under dev flag only for the assignee image element', async () => {
await page.goto(`${baseUrl}/?dev=true`);
const assignImageSelector = await page.$$(
'[data-testid="assignee-image skeleton"]',
);
expect(assignImageSelector).toBeTruthy();

await page.waitForTimeout(5000);
const hasSkeletonClassAfter = await page.$eval('.assignee-image', (el) =>
el.classList.contains('skeleton'),
);
expect(hasSkeletonClassAfter).toBe(false);
});

it('checks whether the shimmer effect is visible under dev flag only for the assignee name element', async () => {
await page.goto(`${baseUrl}/?dev=true`);
const assignNameSelector = await page.$$(
'[data-testid="assignee-name skeleton-text"]',
);
expect(assignNameSelector).toBeTruthy();
await page.waitForTimeout(5000);
const hasSkeletonClassAfter = await page.$eval('.assignee-name', (el) =>
el.classList.contains('skeleton-text'),
);
expect(hasSkeletonClassAfter).toBe(false);
});

it('checks whether the shimmer effect is working for deadlineValue element under feature flag', async () => {
await page.goto(`${baseUrl}/?dev=true`);
const deadlineValueSelector = await page.$$(
'[data-testid="skeleton-span"]',
);
expect(deadlineValueSelector).toBeTruthy();
await page.waitForTimeout(5000);
const hasSkeletonClassAfter = await page.$eval('.tooltip-container', (el) =>
el.classList.contains('skeleton-span'),
);
expect(hasSkeletonClassAfter).toBe(false);
});

it('checks whether the shimmer effect is working for requestedValue element under feature flag', async () => {
await page.goto(`${baseUrl}/?dev=true`);
const requestedValueSelector = await page.$$(
'[data-testid="skeleton-text"]',
);
expect(requestedValueSelector).toBeTruthy();
await page.waitForTimeout(5000);
const hasSkeletonClassAfter = await page.$eval('.requested-day', (el) =>
el.classList.contains('skeleton-text'),
);
expect(hasSkeletonClassAfter).toBe(false);
});
it('checks whether the shimmer effect is working for newDeadlineValue element under feature flag', async () => {
await page.goto(`${baseUrl}/?dev=true`);
const newDeadlineValueSelector = await page.$$(
'[data-testid="skeleton-span"]',
);
expect(newDeadlineValueSelector).toBeTruthy();
await page.waitForTimeout(5000);
const hasSkeletonClassAfter = await page.$eval('.requested-day', (el) =>
el.classList.contains('skeleton-span'),
);
expect(hasSkeletonClassAfter).toBe(false);
});

it('checks whether the shimmer effect is working for extensionRequestNumberValue element under feature flag', async () => {
await page.goto(`${baseUrl}/?dev=true`);
const extensionRequestNumberValueSelector = await page.$$(
'[data-testid="skeleton-span"]',
);
expect(extensionRequestNumberValueSelector).toBeTruthy();
await page.waitForTimeout(5000);
const hasSkeletonClassAfter = await page.$eval(
'.extension-request-number',
(el) => el.classList.contains('skeleton-span'),
);
expect(hasSkeletonClassAfter).toBe(false);
});

it('checks whether the shimmer effect is visible under dev flag only for the statusSiteLink element', async () => {
await page.goto(`${baseUrl}/?dev=true`);
const statusSiteLinkSelector = await page.$$(
'[data-testid="external-link skeleton-link"]',
);
expect(statusSiteLinkSelector).toBeTruthy();
await page.waitForTimeout(5000);
const hasSkeletonClassAfter = await page.$eval('.external-link', (el) =>
el.classList.contains('skeleton-link'),
);
expect(hasSkeletonClassAfter).toBe(false);
});

it('checks whether the shimmer effect is visible under dev flag only for the taskStatusValue element', async () => {
await page.goto(`${baseUrl}/?dev=true`);
const taskStatusValueElement = await page.$$(
'[data-testid="skeleton-span"]',
);
expect(taskStatusValueElement).toBeTruthy();
});

it('Checks whether the card is not removed from display when api call is unsuccessful', async () => {
const extensionCards = await page.$$('.extension-card');

Expand Down
39 changes: 35 additions & 4 deletions __tests__/groups/group.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Discord Groups Page', () => {
},
body: JSON.stringify(discordGroups),
});
} else if (url === `${BASE_URL}/discord-actions/groups?dev=true`) {
} else if (url === `${BASE_URL}/discord-actions/groups`) {
interceptedRequest.respond({
status: 200,
contentType: 'application/json',
Expand Down Expand Up @@ -244,9 +244,9 @@ describe('Discord Groups Page', () => {
expect(groupCreationModalClosed).toBeFalsy();
});

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

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

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

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

expect(noGroupDiv).toBeTruthy();
});

it('should display the footer with the correct repo link', async () => {
const footer = await page.$('[data-test-id="footer"]');
expect(footer).toBeTruthy();

const infoRepo = await footer.$('[data-test-id="info-repo"]');
expect(infoRepo).toBeTruthy();

const repoLink = await infoRepo.$('[data-test-id="repo-link"]');
expect(repoLink).toBeTruthy();

const repoLinkHref = await page.evaluate((el) => el.href, repoLink);
expect(repoLinkHref).toBe(
'https://github.com/Real-Dev-Squad/website-dashboard',
);

const repoLinkTarget = await page.evaluate((el) => el.target, repoLink);
expect(repoLinkTarget).toBe('_blank');

const repoLinkRel = await page.evaluate((el) => el.rel, repoLink);
expect(repoLinkRel).toBe('noopener noreferrer');

const repoLinkText = await page.evaluate((el) => el.innerText, repoLink);
expect(repoLinkText).toBe('open sourced repo');

const repoLinkClass = await page.evaluate((el) => el.className, repoLink);
expect(repoLinkClass).toBe('');

const repoLinkStyle = await page.evaluate((el) => el.style, repoLink);
expect(repoLinkStyle).toBeTruthy();
});
});
79 changes: 73 additions & 6 deletions __tests__/task-requests/task-requestDetails.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,67 @@ const {
urlMappings,
defaultMockResponseHeaders,
} = require('../../mock-data/taskRequests');
const { user } = require('../../mock-data/users/index.js');

describe('Request container for non-super users', () => {
let browser;
let page;
jest.setTimeout(60000);

beforeAll(async () => {
browser = await puppeteer.launch({
headless: 'new',
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 (url == 'https://staging-api.realdevsquad.com/users/self') {
interceptedRequest.respond({
...defaultMockResponseHeaders,
body: JSON.stringify(user),
});
} else if (urlMappings.hasOwnProperty(url)) {
interceptedRequest.respond({
...defaultMockResponseHeaders,
body: JSON.stringify(urlMappings[url]),
});
} else {
interceptedRequest.continue();
}
});
await page.goto(
'http://localhost:8000/task-requests/details/?id=dM5wwD9QsiTzi7eG7Oq5',
);
});

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

it('Approve and Reject buttons should not render for non-super users', async function () {
await page.goto(
'http://localhost:8000/task-requests/details/?id=dM5wwD9QsiTzi7eG7Oq5&&dev=true',
);
const approveButton = await page.$('[data-testid="task-approve-button"]');
const rejectButton = await page.$('[data-testid="task-reject-button"]');
expect(approveButton).toBeNull();
expect(rejectButton).toBeNull();
});

it('Should render task status for non-super users', async function () {
await page.goto(
'http://localhost:8000/task-requests/details/?id=dM5wwD9QsiTzi7eG7Oq5&&dev=true',
);
const taskRequestStatus = await page.$(
'[data-testid="requestors-task-status"]',
);
expect(taskRequestStatus).toBeTruthy();
});
});

describe('Task request details page', () => {
let browser;
Expand Down Expand Up @@ -89,9 +150,12 @@ describe('Task request details page', () => {
);
});

it('Should contain Approve and Reject buttons', async function () {
const approveButton = await page.$('.requestors__conatainer__list__button');
const rejectButton = await page.$('.request-details__reject__button');
it('Should render Approve and Reject buttons for super users', async function () {
await page.goto(
'http://localhost:8000/task-requests/details/?id=dM5wwD9QsiTzi7eG7Oq5&&dev=true',
);
const approveButton = await page.$('[data-testid="task-approve-button"]');
const rejectButton = await page.$('[data-testid="task-reject-button"]');
expect(approveButton).toBeTruthy();
expect(rejectButton).toBeTruthy();
});
Expand Down Expand Up @@ -180,9 +244,12 @@ describe('Task request details page with markdown support in description', () =>
expect(descriptionHtmlValue).toContain('<h3 id="heading">Heading</h3>');
});

it('Should contain Approve and Reject buttons', async function () {
const approveButton = await page.$('.requestors__conatainer__list__button');
const rejectButton = await page.$('.request-details__reject__button');
it('Should render Approve and Reject buttons for super users', async function () {
await page.goto(
'http://localhost:8000/task-requests/details/?id=dM5wwD9QsiTzi7eG7Oq5&&dev=true',
);
const approveButton = await page.$('[data-testid="task-approve-button"]');
const rejectButton = await page.$('[data-testid="task-reject-button"]');
expect(approveButton).toBeTruthy();
expect(rejectButton).toBeTruthy();
});
Expand Down
Loading

0 comments on commit d1dc513

Please sign in to comment.