Skip to content
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
Copy link
Member Author

@MayankBansal12 MayankBansal12 Jan 9, 2026

Choose a reason for hiding this comment

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

this change is done because with the year change, the test was expecting "4 years ago"...jest is used to freeze time for previous year

Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,15 @@ describe('ExtensionStatusModal Component', () => {

test('should test formatToRelativeTime function', () => {
const timestamp = 1640995200;
const fixedNow = new Date('2025-01-01T00:00:00Z');

jest.useFakeTimers();
jest.setSystemTime(fixedNow);

const result = formatToRelativeTime(timestamp);
expect(result).toBe('3 years ago');

jest.useRealTimers();
});

test('should open extension request form when request extension button is clicked', () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/Unit/Components/Navbar/Navbar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('Navbar', () => {
);
expect(eventLink).toHaveAttribute(
'href',
'https://www.realdevsquad.com/events.html'
'https://www.realdevsquad.com/events'
);
expect(memberLink).toHaveAttribute(
'href',
Expand Down
3 changes: 3 additions & 0 deletions __tests__/Unit/Components/Tasks/Card.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,8 @@ describe('Task card', () => {
});

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 change is done because with the year change expectation was being changed...jest is used to freeze time for previous year without updating test expectation

it('renders "Started" with a specific date if status is not AVAILABLE', () => {
jest.useFakeTimers();
jest.setSystemTime(new Date('2025-01-01T00:00:00Z'));
const { getByTestId } = renderWithRouter(
<Provider store={store()}>
<Card
Expand All @@ -549,6 +551,7 @@ describe('Task card', () => {
);
const spanElement = screen.getByTestId('started-on');
expect(spanElement).toHaveTextContent('Started 4 years ago'); // Mocked date from moment
jest.useRealTimers();
});
it('Should show the status of the task', () => {
renderWithRouter(
Expand Down
16 changes: 8 additions & 8 deletions src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Link from 'next/link';
import { LOGOUT_URL, MAIN_SITE_URL, MY_SITE_URL } from '../../constants/url';
import { LOGOUT_URL, MAIN_SITE_URL } from '../../constants/url';
import styles from '@/components/Dropdown/dropdown.module.scss';

export const logout = () => {
Expand All @@ -18,23 +18,23 @@ const Dropdown = () => {
<Link href={MAIN_SITE_URL} className={styles.dropdownLink}>
<li className={styles.dropdownItem}>Home</li>
</Link>
<Link href={`${MY_SITE_URL}`} className={styles.dropdownLink}>
<li className={styles.dropdownItem}>Status</li>
</Link>
<Link
href={`${MY_SITE_URL}/profile`}
href={`${MAIN_SITE_URL}/status`}
className={styles.dropdownLink}
>
<li className={styles.dropdownItem}>Profile</li>
<li className={styles.dropdownItem}>Status</li>
</Link>
<Link
href={`${MY_SITE_URL}/tasks`}
href={`${MAIN_SITE_URL}/profile`}
className={styles.dropdownLink}
>
<li className={styles.dropdownItem}>Profile</li>
</Link>
<Link href="/tasks" className={styles.dropdownLink}>
<li className={styles.dropdownItem}>Tasks</li>
</Link>
<Link
href={`${MY_SITE_URL}/identity`}
href={`${MAIN_SITE_URL}/identity`}
className={styles.dropdownLink}
>
<li className={styles.dropdownItem}>Identity</li>
Expand Down
27 changes: 16 additions & 11 deletions src/constants/url.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
export const BASE_URL = `${process.env.NEXT_PUBLIC_BASE_URL}`;
export const SUBSCRIBE_TO_CHALLENGE_URL = `${BASE_URL}/challenges/subscribe`;
export const MINE_TASKS_URL = `${process.env.NEXT_PUBLIC_BASE_URL}/tasks/self`;
export const USER_PROFILE_URL = 'https://my.realdevsquad.com/profile';
export const HOME_URL = 'https://realdevsquad.com';
export const WELCOME_URL = 'https://welcome.realdevsquad.com';
export const EVENTS_URL = 'https://www.realdevsquad.com/events.html';
export const CRYPTO_URL = 'https://crypto.realdevsquad.com';
export const STATUS_URL = 'https://status.realdevsquad.com';

const isStaging = process.env.NEXT_PUBLIC_BASE_URL?.includes(
'staging-api.realdevsquad.com'
);
const envPrefix = isStaging ? 'staging-' : '';

export const USER_PROFILE_URL = `https://${envPrefix}my.realdevsquad.com/profile`;
export const HOME_URL = `https://${envPrefix}realdevsquad.com`;
export const WELCOME_URL = `https://${envPrefix}welcome.realdevsquad.com`;
export const EVENTS_URL = `https://${envPrefix}www.realdevsquad.com/events`;
export const CRYPTO_URL = `https://${envPrefix}crypto.realdevsquad.com`;
export const STATUS_URL = `https://${envPrefix}status.realdevsquad.com`;
export const LOGIN_URL = `https://github.com/login/oauth/authorize?client_id=23c78f66ab7964e5ef97&state=${STATUS_URL}`;
export const MEMBERS_URL = 'https://members.realdevsquad.com';
export const MEMBERS_URL = `https://${envPrefix}members.realdevsquad.com`;
export const CHALLENGES_URL = `${BASE_URL}/challenges`;
export const USER_SELF = `${BASE_URL}/users?profile=true`;
export const USERS_IDLE = `${BASE_URL}/users/search?state=IDLE`;
export const DEFAULT_AVATAR = '/Avatar.png';
export const RDS_LOGO = '/RDSLogo.png';
export const GITHUB_LOGO = '/github-white.png';
export const SIGNUP_LINK = 'https://my.realdevsquad.com/signup';
export const SIGNUP_LINK = `https://${envPrefix}www.realdevsquad.com/new-signup`;
export const LOGOUT_URL = `${process.env.NEXT_PUBLIC_BASE_URL}/auth/signout`;
export const IDLE_USERS_URL = `${process.env.NEXT_PUBLIC_BASE_URL}/users/status?state=IDLE`;
export const ITEM_BY_FILTER_URL = `${process.env.NEXT_PUBLIC_BASE_URL}/items/filter`;
Expand All @@ -28,9 +34,8 @@ export const TASKS_URL = `${process.env.NEXT_PUBLIC_BASE_URL}/tasks`;
export const TASK_REQUEST_URL = `${process.env.NEXT_PUBLIC_BASE_URL}/taskRequests`;
export const ISSUES_URL = `${process.env.NEXT_PUBLIC_BASE_URL}/issues`;
export const USERS_URL = `${BASE_URL}/users`;
export const MAIN_SITE_URL = 'https://www.realdevsquad.com';
export const MY_SITE_URL = 'https://my.realdevsquad.com';
export const DASHBOARD_URL = 'https://dashboard.realdevsquad.com';
export const MAIN_SITE_URL = `https://${envPrefix}www.realdevsquad.com`;
export const DASHBOARD_URL = `https://${envPrefix}dashboard.realdevsquad.com`;
export const USER_MANAGEMENT_URL = `${DASHBOARD_URL}/users/details/`;
export const TASK_REQUESTS_DETAILS_URL = `${DASHBOARD_URL}/task-requests/details/`;
export const TASK_EXTENSION_REQUEST_URL = `${DASHBOARD_URL}/extension-requests/`;