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

Dev to Main Sync #883

Merged
merged 4 commits into from
Oct 15, 2024
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
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
23 changes: 23 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
3 changes: 1 addition & 2 deletions __tests__/extension-requests/extension-requests.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,9 @@ 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);
});
Expand Down
55 changes: 46 additions & 9 deletions applications/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
} from './utils.js';
let nextLink;
let isDataLoading = false;
let totalApplicationCount = 0;
let currentApplicationIndex = 0;
const loader = document.querySelector('.loader');
const filterModal = document.querySelector('.filter-modal');
const backDrop = document.querySelector('.backdrop');
Expand Down Expand Up @@ -38,6 +40,7 @@ const applicationDetailsActionsContainer = document.querySelector(
);
const urlParams = new URLSearchParams(window.location.search);
const isDev = urlParams.get('dev') === 'true';
let isApplicationPending = urlParams.get('status') === 'pending';
const filterButton = isDev
? document.getElementById('filter-button-new')
: document.getElementById('filter-button');
Expand Down Expand Up @@ -100,6 +103,7 @@ function changeFilter() {
} else {
totalCountElement.classList.add('hidden');
status = 'all';
totalApplicationCount = 0;
}
applicationContainer.innerHTML = '';
}
Expand Down Expand Up @@ -297,7 +301,7 @@ function removeQueryParamInUrl(queryParamKey) {
window.history.replaceState(window.history.state, '', updatedUrl);
}

function createApplicationCard({ application, dev }) {
function createApplicationCard({ application, dev, index }) {
const applicationCard = createElement({
type: 'div',
attributes: { class: 'application-card' },
Expand All @@ -314,6 +318,29 @@ function createApplicationCard({ application, dev }) {
innerText: application.biodata.firstName,
});

if (dev && isApplicationPending) {
const usernameTextAndIndex = createElement({
type: 'div',
attributes: { class: 'user-text-index' },
});

const userIndex = createElement({
type: 'input',
attributes: {
type: 'number',
value: `${index}`,
readonly: '',
class: 'user-index',
'data-testid': 'user-index',
},
});
usernameTextAndIndex.appendChild(usernameText);
usernameTextAndIndex.appendChild(userIndex);
userInfoContainer.appendChild(usernameTextAndIndex);
} else {
userInfoContainer.appendChild(usernameText);
}

const companyNameText = createElement({
type: 'p',
attributes: { class: 'company-name hide-overflow' },
Expand All @@ -326,7 +353,6 @@ function createApplicationCard({ application, dev }) {
innerText: `Skills: ${application.professional.skills}`,
});

userInfoContainer.appendChild(usernameText);
userInfoContainer.appendChild(companyNameText);
userInfoContainer.appendChild(skillsText);

Expand Down Expand Up @@ -382,7 +408,10 @@ async function renderApplicationCards(next, status, isInitialRender, dev) {
changeLoaderVisibility({ hide: true });
const applications = data.applications;
const totalSelectedCount = data.totalCount;

if (isInitialRender) {
totalApplicationCount = data.totalCount;
currentApplicationIndex = totalApplicationCount;
}
nextLink = data.next;
if (isDev && status != 'all') {
showAppliedFilter(status);
Expand All @@ -394,12 +423,19 @@ async function renderApplicationCards(next, status, isInitialRender, dev) {
}
if (!applications.length)
return noApplicationFoundText.classList.remove('hidden');
applications.forEach((application) => {

if (isInitialRender || !next) {
applicationContainer.innerHTML = '';
currentApplicationIndex = totalSelectedCount;
}
applications.forEach((application, index) => {
const applicationCard = createApplicationCard({
application,
dev,
index: currentApplicationIndex,
});
applicationContainer.appendChild(applicationCard);
currentApplicationIndex--;
});
}

Expand Down Expand Up @@ -448,7 +484,8 @@ async function renderApplicationById(id) {
if (applicationId) {
await renderApplicationById(applicationId);
}

totalApplicationCount = 0;
currentApplicationIndex = 0;
if (isDev) {
await renderApplicationCards('', status, true, isDev);
} else {
Expand All @@ -467,7 +504,7 @@ const intersectionObserver = new IntersectionObserver(async (entries) => {
if (entries[0].isIntersecting && !isDataLoading) {
const dev = urlParams.get('dev');
if (dev) {
await renderApplicationCards(nextLink, status, true, dev);
await renderApplicationCards(nextLink, status, false, dev);
} else {
await renderApplicationCards(nextLink);
}
Expand Down Expand Up @@ -514,7 +551,7 @@ if (isDev) {
const dev = urlParams.get('dev');

if (dev) {
renderApplicationCards(nextLink, status, false, dev);
renderApplicationCards(nextLink, status, true, dev);
} else {
renderApplicationCards(nextLink, status);
}
Expand All @@ -539,7 +576,7 @@ function applyFilter(filter, isDev) {
addQueryParamInUrl('status', filter);
changeFilter();
status = filter;
renderApplicationCards(nextLink, status, false, isDev);
renderApplicationCards('', status, false, isDev);
filterDropdown.style.display = 'none';
}
}
Expand All @@ -550,7 +587,7 @@ filterRemove.addEventListener('click', () => {
removeQueryParamInUrl('status');
changeFilter();
const dev = urlParams.get('dev');
renderApplicationCards(nextLink, status, false, dev);
renderApplicationCards(nextLink, status, true, dev);
});

backDrop.addEventListener('click', () => {
Expand Down
13 changes: 13 additions & 0 deletions applications/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@
--color-red-variant1: #f43030;
}

.user-text-index {
display: flex;
justify-content: space-between;
}

.user-index {
width: 60px;
border: none;
font-style: normal;
font-size: 20px;
font-weight: 700;
}

body {
font-family: 'Roboto', sans-serif;
margin: 0;
Expand Down
2 changes: 1 addition & 1 deletion online-members/online-members.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}

.task-container {
overflow: scroll;
overflow: auto;
display: none;
padding-top: 10px;
max-height: 85vh;
Expand Down
2 changes: 1 addition & 1 deletion online-members/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ async function generateUserTaskData(username) {
return;
}

showLoadingSpinner(`${TASKS_CONTAINER_ID}`);
showLoadingSpinner(`#${TASKS_CONTAINER_ID}`);

isTaskDataBeingFetched = true;

Expand Down
1 change: 1 addition & 0 deletions task-requests/details/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ const renderGithubIssue = async () => {
simplifiedAutoLink: true,
ghCodeBlocks: true,
openLinksInNewWindow: true,
disableForced4SpacesIndentedSublists: true,
});
let res = await fetch(taskRequest?.externalIssueUrl);
res = await res.json();
Expand Down
Loading