From 0029551ee1e021bf78c9486edf1935ec275ef889 Mon Sep 17 00:00:00 2001 From: anuj chhikara Date: Tue, 24 Feb 2026 01:15:05 +0530 Subject: [PATCH 1/6] feat: add Request Changes functionality for application feedback - Introduced a new button for requesting changes in application details. - Updated the application feedback submission logic to handle 'changes_requested' status. - Enhanced tests to cover new functionality, including success and error toast messages. - Adjusted styles for the new button to ensure consistent UI. --- __tests__/applications/applications.test.js | 94 ++++++++++++++++++++- applications/index.html | 6 ++ applications/script.js | 54 +++++++----- applications/style.css | 40 ++++++++- applications/utils.js | 29 ++++--- 5 files changed, 184 insertions(+), 39 deletions(-) diff --git a/__tests__/applications/applications.test.js b/__tests__/applications/applications.test.js index b214a112..6396757f 100644 --- a/__tests__/applications/applications.test.js +++ b/__tests__/applications/applications.test.js @@ -74,12 +74,34 @@ describe('Applications page', () => { }); } else if ( url === `${STAGING_API_URL}/applications/lavEduxsb2C5Bl4s289P` + ) { + const method = interceptedRequest.method(); + const body = + method === 'GET' + ? JSON.stringify({ application: pendingApplications[0] }) + : JSON.stringify({ + message: 'Application feedback submitted successfully', + }); + interceptedRequest.respond({ + status: 200, + contentType: 'application/json', + body, + headers: { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS', + 'Access-Control-Allow-Headers': 'Content-Type, Authorization', + }, + }); + } else if ( + interceptedRequest.method() === 'PATCH' && + url.includes('/applications/') && + url.endsWith('/feedback') ) { interceptedRequest.respond({ status: 200, contentType: 'application/json', body: JSON.stringify({ - message: 'application updated successfully!', + message: 'Application feedback submitted successfully', }), headers: { 'Access-Control-Allow-Origin': '*', @@ -210,7 +232,10 @@ describe('Applications page', () => { element.scrollIntoView({ behavior: 'auto' }); } }); - await page.waitForNetworkIdle(); + await page.waitForFunction( + () => document.querySelectorAll('.application-card').length >= 12, + { timeout: 10000 }, + ); applicationCards = await page.$$('.application-card'); expect(applicationCards.length).toBe(12); }); @@ -355,7 +380,7 @@ describe('Applications page', () => { ).toBe(false); const toastMessage = await page.$('[data-testid="toast-message"]'); expect(await toastMessage.evaluate((el) => el.textContent)).toBe( - 'application updated successfully!', + 'Application feedback submitted successfully', ); }); @@ -371,4 +396,67 @@ describe('Applications page', () => { const applicationCardElements = await page.$$('.application-card'); expect(applicationCardElements.length).toBe(acceptedApplications.length); }); + + it('should show Request changes button when application details modal is open for a pending application', async () => { + await page.goto( + `${LOCAL_TEST_PAGE_URL}/applications?dev=true&status=pending`, + ); + await page.waitForSelector('.application-card'); + await page.click('.application-card'); + await page.waitForSelector('.application-details:not(.hidden)'); + const requestChangesButton = await page.$( + '.application-details-request-changes', + ); + expect(requestChangesButton).toBeTruthy(); + const isHidden = await requestChangesButton.evaluate((el) => + el.classList.contains('hidden'), + ); + expect(isHidden).toBe(false); + }); + + it('should show error toast when clicking Request changes without feedback text', async () => { + await page.goto( + `${LOCAL_TEST_PAGE_URL}/applications?dev=true&status=pending`, + ); + await page.waitForSelector('.application-card'); + await page.click('.application-card'); + await page.waitForSelector('.application-details:not(.hidden)'); + await page.click('.application-details-request-changes'); + await page.waitForSelector('[data-testid="toast-component"].show'); + const toastComponent = await page.$('[data-testid="toast-component"]'); + expect( + await toastComponent.evaluate((el) => + el.classList.contains('error__toast'), + ), + ).toBe(true); + const toastMessage = await page.$('[data-testid="toast-message"]'); + expect(await toastMessage.evaluate((el) => el.textContent)).toBe( + 'Feedback is required when requesting changes.', + ); + }); + + it('should show success toast when submitting Request changes with feedback text', async () => { + await page.goto( + `${LOCAL_TEST_PAGE_URL}/applications?dev=true&status=pending`, + ); + await page.waitForSelector('.application-card'); + await page.click('.application-card'); + await page.waitForSelector('.application-details:not(.hidden)'); + await page.type( + '.application-textarea', + 'Please add more details on skills', + ); + await page.click('.application-details-request-changes'); + await page.waitForSelector('[data-testid="toast-component"].show'); + const toastComponent = await page.$('[data-testid="toast-component"]'); + expect( + await toastComponent.evaluate((el) => + el.classList.contains('success__toast'), + ), + ).toBe(true); + const toastMessage = await page.$('[data-testid="toast-message"]'); + expect(await toastMessage.evaluate((el) => el.textContent)).toBe( + 'Application feedback submitted successfully', + ); + }); }); diff --git a/applications/index.html b/applications/index.html index af5e1c02..0bfe3804 100644 --- a/applications/index.html +++ b/applications/index.html @@ -132,6 +132,12 @@

Status

> Accept + diff --git a/applications/script.js b/applications/script.js index f84f1da4..b1209772 100644 --- a/applications/script.js +++ b/applications/script.js @@ -177,11 +177,11 @@ function openApplicationDetails(application) { }, { title: 'Score', - description: application.score, + description: application.score ?? 'N/A', }, { title: 'Nudge Count', - description: application.nudgeCount, + description: application.nudgeCount ?? 'N/A', }, { title: 'Introduction', @@ -278,7 +278,7 @@ function openApplicationDetails(application) { type: 'textarea', attributes: { class: 'application-textarea', - placeHolder: 'Add Feedback here (required for Request changes)', + placeholder: 'Add Feedback here (required for Request changes)', }, innerText: '', }); From 4b421cc301e27750d95bd39d7d4aeddbace3e7b7 Mon Sep 17 00:00:00 2001 From: Mayank Bansal Date: Thu, 26 Feb 2026 00:20:59 +0530 Subject: [PATCH 6/6] fix: use test id, replace hardcoded colors --- __tests__/applications/applications.test.js | 4 +-- applications/index.html | 1 + applications/script.js | 4 +-- applications/style.css | 34 +++++++++++++-------- applications/utils.js | 2 +- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/__tests__/applications/applications.test.js b/__tests__/applications/applications.test.js index ffb7c9e2..fb09b818 100644 --- a/__tests__/applications/applications.test.js +++ b/__tests__/applications/applications.test.js @@ -87,8 +87,7 @@ describe('Applications page', () => { }); } else if ( interceptedRequest.method() === 'PATCH' && - url.includes('/applications/') && - url.endsWith('/feedback') + url === `${STAGING_API_URL}/applications/lavEduxsb2C5Bl4s289P/feedback` ) { interceptedRequest.respond({ status: 200, @@ -227,7 +226,6 @@ describe('Applications page', () => { }); await page.waitForFunction( () => document.querySelectorAll('.application-card').length >= 12, - { timeout: 10000 }, ); applicationCards = await page.$$('.application-card'); expect(applicationCards.length).toBe(12); diff --git a/applications/index.html b/applications/index.html index 38fe698d..ce1f79da 100644 --- a/applications/index.html +++ b/applications/index.html @@ -133,6 +133,7 @@

Status

Accept