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

feat: Add onboarding extension requests tab #942

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

AnujChhikara
Copy link
Member

@AnujChhikara AnujChhikara commented Feb 8, 2025

Date: 24 Feb, 2025

Developer Name: @AnujChhikara


Issue Ticket Number

Description

  • Added a new tab for Onboarding Extension Requests in the /requests route.
  • Clicking the tab displays all onboarding extension requests.
  • Refactored the getRequests function for better readability and efficiency.

Documentation Updated?

  • Yes
  • No

Under Feature Flag

  • Yes
  • No

Database Changes

  • Yes
  • No

Breaking Changes

  • Yes
  • No

Development Tested?

  • Yes
  • No

Screenshots

Screenshot 1
brave_W1zSAH4AtF.mp4
  • Mobile UI

image

Test Coverage

Screenshot 1

image

Additional Notes

Summary by CodeRabbit

  • New Features

    • Introduced an onboarding extension requests view with a dedicated navigation tab for easier access to onboarding requests.
  • Style

    • Refined the visual presentation of request cards and request containers with updated color schemes and improved layout.
    • Adjusted the task navigation styling for enhanced layout flexibility.

@AnujChhikara AnujChhikara force-pushed the feature/onboarding-extension-tab branch from 9cc17c7 to 87e445e Compare February 21, 2025 05:56
@AnujChhikara AnujChhikara force-pushed the feature/onboarding-extension-tab branch from 87e445e to 9840e76 Compare February 21, 2025 06:06
expect(await actionContainer.isVisible()).toBe(false);
expect(await approveButton.isVisible()).toBe(false);
expect(await rejectButton.isVisible()).toBe(false);
expect(await remarkInput.isVisible()).toBe(false);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used isVisible() because all elements (e.g., action container, buttons, input) are in the DOM but hidden with a CSS class (like hidden). inDocument only checks DOM presence, and toBeTrue doesn’t accurately verify visibility. isVisible() ensures we test if elements are actually visible on the page or not.

--color-error: #da1e28;
--color-warn: rgba(199, 129, 18, 0.4);
--color-warn: #e3a008;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these hex codes are taken from the design doc.

.request_container > * {
width: 100% !important;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added width: 100% !important to .request_container > * for request cards in dev mode, where we use a flex row layout (flex-direction: column). This ensures cards stretch to full width for consistency. In production (grid layout), width: auto works better to avoid cramped spacing, but dev=true requires width: 100% for a clean appearance.

@AnujChhikara AnujChhikara marked this pull request as ready for review February 24, 2025 05:13
@AnujChhikara AnujChhikara changed the title feat: add onboarding tab and unify request fetch logic feat: implement onboarding extension requests tab Feb 24, 2025
@pankajjs pankajjs changed the title feat: implement onboarding extension requests tab feat: Add onboarding extension requests tab Feb 24, 2025
@@ -24,6 +26,7 @@ const ErrorMessages = {
UNAUTHORIZED: 'You are unauthorized to view this section',
OOO_NOT_FOUND: 'OOO Requests not found',
EXTENSION_NOT_FOUND: 'Extension Requests not found',
ONBOARDING_EXTENSION_NOT_FOUND: 'Onboarding extension Requests not found',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find this key getting used anywhere, was this intended to be used in requests/script.js line number 120?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be used when we apply the filter. As for its use on line 120, we don’t display that error directly. If you check the renderRequests function, it wraps the entire API call in a try-catch block and only shows an error in the finally block if the request response is undefined or zero. Here’s the link

Copy link

coderabbitai bot commented Feb 25, 2025

Walkthrough

The pull request introduces onboarding extension request handling into the codebase. It adds new mock data and constants, updates test cases to verify the onboarding tab’s behavior, and integrates this functionality into the main request pipeline. In addition, several CSS files have been edited to update styling and improve layout while certain utility functions have been refactored for enhanced testability. The changes consolidate request fetching into a single function that now processes multiple request types including the new onboarding type.

Changes

File(s) Change Summary
__tests__/.../requests.test.js Added new mock variable (onboardingExtensionRequest) and test cases for onboarding tab behavior; adjusted selectors and expected texts.
mock-data/.../index.js Added a new constant onboardingExtensionRequest containing sample onboarding request data with various request properties.
requests/constants.js Added ONBOARDING_EXTENSION_REQUEST_TYPE, ONBOARDING_EXTENSION_TAB_ID, and a new error message for onboarding requests.
requests/index.html Updated navigation tabs to include a new (disabled) Onboarding tab; added data-testid attributes to tabs and the request container to improve testability.
requests/script.js Integrated new onboarding tab logic by adding event listeners, updating the current request type, and consolidating request fetching into a single getRequests function.
global.css, requests/style.css In global.css: Removed width: 100%; from #tasksNav. In requests/style.css: Updated color variables, renamed .ooo_request__card to .request__card, and added new layout rules.
requests/util.js Removed getOooQueryParamsString; updated the query param function to getQueryParamsString with support for request type; enhanced createElementFromMap to handle testId.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant RequestHandler
    participant API

    User->>UI: Click "Onboarding" Tab
    UI->>RequestHandler: Set request type to ONBOARDING and update tab state
    RequestHandler->>API: Call getRequests(ONBOARDING)
    API-->>RequestHandler: Return onboarding extension data (mocked)
    RequestHandler->>UI: Render updated request cards
Loading

Poem

I'm a happy rabbit, with whiskers so bright,
Hop-scotching through code from morning to night.
Onboarding tabs now sparkle, tests leap with cheer,
New constants and styles bring the changes near.
With each little fix, my heart does a twirl—
Code's a meadow in bloom, my favorite in the world!
🐇🌸 Happy hopping in the code garden!

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
requests/style.css (3)

137-137: Introducing a max-width: 46rem constraint.
This may help keep request cards from stretching excessively, though consider responsive breakpoints for smaller screens if further refinement is needed.


239-239: Switching .request__date__pill color to --black-color.
The black text color on a pill highlights date details more clearly than white.


369-369: Slight margin adjustment for .request__remark__input.
margin-bottom: 0.2rem; offers subtle spacing and helps separate the input from subsequent elements.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ce6be97 and c045e71.

📒 Files selected for processing (8)
  • __tests__/requests/requests.test.js (4 hunks)
  • global.css (0 hunks)
  • mock-data/requests/index.js (1 hunks)
  • requests/constants.js (2 hunks)
  • requests/index.html (2 hunks)
  • requests/script.js (20 hunks)
  • requests/style.css (6 hunks)
  • requests/util.js (2 hunks)
💤 Files with no reviewable changes (1)
  • global.css
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
🔇 Additional comments (37)
mock-data/requests/index.js (1)

76-110: Looks good - new mock data matches existing patterns

The mock data for onboarding extension requests follows the same structure as the existing request types, including appropriate properties and sample states for testing.

requests/constants.js (3)

10-10: LGTM - new request type constant

The onboarding extension request type constant follows the same naming convention as the existing request types.


14-14: LGTM - new tab ID constant

The constant for the onboarding extension tab ID follows the same naming pattern as the existing tab IDs.


29-29: LGTM - new error message

The error message for onboarding extension requests follows the same format as existing error messages.

requests/util.js (2)

27-28: Good addition for testability

Adding support for data-testid attributes enhances the testability of the components and aligns with good testing practices.


37-47:

❓ Verification inconclusive

Good refactoring to consolidate query parameter logic

The new getQueryParamsString function efficiently replaces the need for separate functions for each request type, improving code maintainability.


🏁 Script executed:

#!/bin/bash
# Description: Check for any remaining references to the removed function

# Search for any remaining references to getOooQueryParamsString
rg "getOooQueryParamsString" -A 3 -B 3

Length of output: 38


Refactoring Approved – Please Manually Verify Removal of getOooQueryParamsString

The new getQueryParamsString function appropriately consolidates the query parameter logic. Although our automated search for getOooQueryParamsString returned no output, this result is somewhat inconclusive. Please manually verify that there are no remaining references to the removed getOooQueryParamsString function throughout the codebase.

  • File to Review: requests/util.js (Lines 37–47)
  • Action: Confirm manually that no parts of the code are still invoking getOooQueryParamsString.
__tests__/requests/requests.test.js (5)

7-7: LGTM - import of new mock data

The import of the onboarding extension request mock data follows the same pattern as existing imports.


70-82: Good test coverage for new request type

The test intercepts the API request for onboarding extension requests and responds with the appropriate mock data, following the same pattern as the existing request types.


131-134: Improved test reliability with waitForFunction

Using waitForFunction to check for the updated text content is more reliable than just waiting for a selector, as it ensures the content has actually changed.


161-164: Good test for feature flag behavior

This test verifies that the onboarding tab is hidden when the dev flag is not set, which is important for ensuring the feature flag works correctly.


166-268: Comprehensive test coverage for onboarding requests

The tests properly verify all aspects of the onboarding extension feature:

  1. Tab visibility in dev mode
  2. Request rendering
  3. Action buttons visibility based on request state
  4. Superuser details visibility based on request state

The tests are well-structured and thorough.

requests/index.html (2)

37-64: Good addition of data-testid attributes for testing.
These data attributes enhance test clarity by enabling selectors that are explicitly tied to functional elements like OOO, Onboarding, Task, and Extension tabs. The use of class="disabled__tab hidden" for "Onboarding" ensures it remains hidden unless toggled, which aligns with the dev-based feature flag.


72-76: data-testid for request container is consistent with testing best practices.
Adding a unique test identifier on the principal container simplifies test queries and fosters reliable UI tests.

requests/style.css (7)

4-6: Switching to solid hex colors benefits consistency.
Changing --color-success and --color-warn to solid hex codes (#0e9f6e, #e3a008) improves visual predictability and aligns them with typical design standards.


116-126: New .request_container rules enhance vertical flow for dev usage.
Defining a custom flex-direction and forcing child elements to full width ensures a vertical stacking layout needed in development mode. However, confirm that toggling between .request and .request_container does not inadvertently break other layouts.


133-133: Renaming .ooo_request__card to .request__card (observed) makes the style more generic.
A generic name suits multiple request types. Ensure all references to .ooo_request__card have been removed or updated throughout the codebase.


180-181: Increasing font size and weight for .requester__name p.
Enhancing legibility from 0.7rem+300 to 0.8rem+500 is a solid improvement in readability.


232-232: Raising .request__timeline p font weight for a bolder emphasis.
The shift to 500 helps the timeline text stand out, improving scanability.


295-295: Matching .admin__name__and__remark p font weight to 500.
Keeping font weights consistent across different text sections promotes a uniform look.


365-365: Boosting .request__remark__input padding to 0.8rem.
Additional padding can improve the user’s typing experience, especially on mobile screens.

requests/script.js (17)

12-14: Retrieving the onboarding extension tab element.
Consider adding safeguards if ONBOARDING_EXTENSION_TAB_ID is missing or undefined to prevent potential runtime errors.


27-31: Conditional dev-mode setup ensures onboarding tab is only visible in development.
Switching from .request to .request_container changes layout from grid to flex. Confirm it doesn’t break existing styling beyond dev usage.


53-64: Event listener for OOO tab is consistent with new approach.
The addition of preventDefault() and asynchronous rendering logic aligns with the existing flow.


66-77: Extension tab click handler matches the updated pattern.
Ensuring uniform handling across all tabs improves maintainability.


79-90: Onboarding tab event listener introduced.
Mirroring the logic of OOO and extension tabs ensures a cohesive user flow for the new request type.


98-105: Unified getRequests function logic for multiple request types.
Consolidating into one function is simpler to maintain and properly addresses the onboarding scenario with ONBOARDING_EXTENSION_NOT_FOUND.


123-123: Displaying the appropriate 404 error message.
Switching the shown message based on request type ensures better user feedback in the onboarding flow.


164-165: Destructuring new fields for onboarding.
Including newEndsOn and oldEndsOn ensures you have easy access to the extended date properties within request objects.


174-174: Flagging isRequestTypeOnboarding once for clarity.
This boolean check helps streamline the subsequent logic for distinguishing date fields and messages.


194-201: Conditional date fields based on request type.
Applying oldEndsOn/newEndsOn for onboarding vs. from/until for OOO is precise. Well done ensuring minimal confusion in the code.


214-215: Adding testId to the card container.
testId: \${type.toLowerCase()}-request-card`` helps testers confirm which card type is rendered.


229-229: Introducing testId: 'action-container'.
Clear test identifiers make verifying the presence/absence of action controls more straightforward in E2E and integration tests.


234-234: testId: 'request-remark-input' clarifies input field usage.
This ensures remark input is easy to target in automated tests.


246-246: testId: 'approve-button' for acceptance flow.
Explicit labeling for acceptance logic helps reliably locate the element in UI tests.


259-259: testId: 'reject-button' for rejection flow.
Similar to approve, it’s valuable to keep distinct element identifiers for consistent test automation.


279-279: testId: 'admin-info-and-status' fosters improved monitoring of superuser details.
This simplifies verifying whether admin info is shown or hidden.


449-450: Loading requesterUserDetails from request.userId for non-OOO requests.
This distinction ensures OOO requests use requestedBy while onboarding and extension requests rely on userId. Check if any other request types might need a similar fallback or additional mapping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants