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 new dashboard UI #299

Open
wants to merge 26 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7bb0bcd
Sync main with develop (#249)
akshay1502 Jan 27, 2022
0d35066
added contstants and image
ivinayakg Jul 29, 2022
4d7da41
fixed sidebar files
ivinayakg Aug 16, 2022
3e19883
fixed the sidebar
ivinayakg Aug 16, 2022
f82eed7
'Requested Changes Done'
ivinayakg Aug 22, 2022
5505754
fixed typo
ivinayakg Oct 2, 2022
ba14b6c
Merge branch 'develop' into feature/new-sidebar
MehulKChaudhari Oct 8, 2022
944e08f
responsivness added
ivinayakg Oct 19, 2022
22d8795
Sync main with develop (#249)
akshay1502 Jan 27, 2022
752bcf2
added contstants and image
ivinayakg Jul 29, 2022
1a89d49
fixed sidebar files
ivinayakg Aug 16, 2022
0a53637
fixed the sidebar
ivinayakg Aug 16, 2022
def0ffb
'Requested Changes Done'
ivinayakg Aug 22, 2022
72bd58e
fixed typo
ivinayakg Oct 2, 2022
9cbf66b
responsivness added
ivinayakg Oct 19, 2022
125e025
Merge branch 'feature/new-sidebar' of https://github.com/ivinayakg/we…
ivinayakg Dec 20, 2022
d8257de
feat-created new dashboard UI
manish591 Jan 1, 2023
fb7c4dc
style-created responsive layout
manish591 Jan 28, 2023
8aa4c73
added remaining months in month dropdown
manish591 Feb 3, 2023
bf512e0
removed hardcoded data
manish591 Feb 3, 2023
1af9930
refactor-requested changes
manish591 Feb 6, 2023
39a0c8c
style-added cursor property in breadcrumbs
manish591 Feb 6, 2023
41adc8e
test-tests added for dashboard UI
manish591 Feb 15, 2023
314ad1c
added requested changes
manish591 Mar 9, 2023
94c6705
updated tests
manish591 Mar 15, 2023
bf32a62
Merge branch 'develop' into feat/add-new-dashboard-UI
MehulKChaudhari Mar 18, 2023
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
211 changes: 211 additions & 0 deletions __tests__/integration/dashboard.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
describe('visiting /dashboard', () => {
before(() => {
cy.visit('/dashboard');
});

it('checks if url is pointing to dashboard route', () => {
cy.location('pathname').should('eq', '/dashboard');
});

it('checks if sidebar is rendered', () => {
const sidebarMenuOptions = [
{
name: 'Home',
iconPath: '/assets/Home.svg',
urlPath: '/',
},
{
name: 'Dashboard',
iconPath: '/assets/Dashboard.svg',
urlPath: 'dashboard',
},
{
name: 'Currency Exchange',
iconPath: '/assets/Swap.svg',
urlPath: 'currency-exchange',
},
{
name: 'Auction',
iconPath: '/assets/Auction.svg',
urlPath: 'auction',
},
{
name: 'Stocks',
iconPath: '/assets/Stocks.svg',
urlPath: 'trading',
},
{
name: 'Balance',
iconPath: '/assets/Balance.svg',
urlPath: 'wallet',
},
];

cy.get('[data-testid="sidebar-logo"]').should('exist');
cy.get('[data-testid="sidebar-title"]').should('have.text', 'RealDevSquad');

sidebarMenuOptions.forEach((option) => {
cy.get(`[data-testid="sidebar-menu-icon=${option.iconPath}"]`).should(
'exist'
);
cy.get(`[data-testid="sidebar-menu-title-${option.name}"]`).should(
'have.text',
option.name
);
});

cy.get('[data-testid="sidebar-trade-button"]').should(
'have.text',
'Trade Now'
);
cy.get('[data-testid="sidebar-trade-button-icon"]').should('exist');
cy.get('[data-testid="sidebar-guide-button"]').should('exist');
cy.get('[data-testid="sidebar-guide-button-icon"]').should('exist');
});

it('checks if breadcrumbs are rendered', () => {
const links = ['home', 'dashboard'];

cy.get('[data-testid="breadcrumbs-separator"]').should('exist');

links.forEach((link) => {
cy.get(`[data-testid="breadcrumbs-link-${link}"]`).should(
'have.text',
link
);
});
});

it('checks if wallets section is rendered', () => {
const currencyData = [
{
name: 'Gold',
value: 110,
color: ' #f39c12',
borderColor: '#A58F20',
},
{
name: 'Silver',
value: 120,
color: ' #bdc3c7',
borderColor: '#7F7F7F',
},
{
name: 'Brass',
value: 150,
color: '#e67e22',
borderColor: '#885A01',
},
];

cy.get('[data-testid="wallets-title"]').should('have.text', 'Wallets');
cy.get('[data-testid="wallets-more-assets-btn"]').should(
'have.text',
'More Assets →'
);
cy.get(`[data-testid="wallets-add-currency-btn"]`).should(
'have.text',
'+ Add Currency'
);

currencyData.forEach((currency) => {
cy.get(`[data-testid="currency-card-name-${currency.name}"]`).should(
'have.text',
currency.name
);
cy.get(`[data-testid="currency-card-value-${currency.value}"]`).should(
'have.text',
currency.value
);
});
});

it('checks if rds transaction graph is visible', () => {
const monthsList = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'Sepetember',
'October',
'November',
'December',
];

cy.get('[data-testid="trasaction-title"]').should(
'have.text',
'RDS Transaction'
);
cy.get('[data-testid="latest-transaction-btn"]').should(
'have.text',
'Latest Transaction'
);
cy.get('[data-testid="transaction-select-month"]').should('exist');
cy.get('[data-testid="transaction-chart"]').should('exist');

monthsList.forEach((month) => {
cy.get(`[data-testid="transaction-select-month-${month}"]`).should(
'have.text',
month
);
});
});

it('checks if profile sidebar is rendered', () => {
const personData = {
name: 'Ankush Dharkar',
email: 'some.gmail.com',
joined: '23 August, 2022',
type: 'Active',
coins: {
brass: 200,
gold: 100,
silver: 300,
},
};

cy.get('[data-testid="profile-sidebar-img"]').should('exist');
cy.get('[data-testid="profile-sidebar-name"]').should(
'have.text',
personData.name
);
cy.get('[data-testid="profile-sidebar-email"]').should(
'have.text',
personData.email
);
cy.get('[data-testid="profile-sidebar-account-title"]').should(
'have.text',
'Account'
);
cy.get('[data-testid="profile-sidebar-joined-title"]').should(
'have.text',
'Joined'
);
cy.get('[data-testid="profile-sidebar-joined-detail"]').should(
'have.text',
personData.joined
);
cy.get('[data-testid="profile-sidebar-assets-title"]').should(
'have.text',
'Assets'
);
cy.get('[data-testid="profile-sidebar-more-asset-btn"]').should(
'have.text',
'More Assets...'
);

for (let coin in personData.coins) {
cy.get(`[data-testid=profile-sidebar-asset-${coin}]`).should(
'have.text',
coin
);
cy.get(
`[data-testid=profile-sidebar-asset-${personData.coins[coin]}]`
).should('have.text', personData.coins[coin]);
}
});
});
106 changes: 106 additions & 0 deletions components/Sidebar/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { useState } from 'react';
import { useRouter } from 'next/router';
import Image from 'next/image';
import sidebarMenuOptions from 'constants/sidebarMenuOptions';
import { MENU_ICON_HEIGHT, MENU_ICON_WIDTH } from 'constants/sidebarImgDetails';
import sidebarIconPaths from 'constants/sidebarMenuIconPaths';
import styles from './sidebar.module.css';

const Sidebar = () => {
const [mobileToggle, setMobileToggle] = useState(false);
const router = useRouter();
const navigateTo = (url) => router.push(url);
const { ICON_PATH_LOGO, ICON_PATH_ARROW, ICON_PATH_INFO } = sidebarIconPaths;

const basePath = router.pathname;
const pagePath = router.pathname.split('/')[1];

const addActiveOptionClass = (optionURL) =>
pagePath === optionURL || (basePath === '/' && '/' === optionURL)
manish591 marked this conversation as resolved.
Show resolved Hide resolved
? ' ' + styles.option_active
: '';

return (
<div className={styles.wrapper} data-testid="sidebar-notification">
<div
className={
styles.mobileToggle +
` ${mobileToggle ? styles['mobileToggle--active'] : ''}`
}
onClick={() => setMobileToggle((prev) => !prev)}
>
<h3>Menu</h3>
<Image
src={ICON_PATH_ARROW}
width={MENU_ICON_WIDTH}
height={MENU_ICON_HEIGHT}
/>
</div>

<aside className={styles.sidebar}>
<span className={styles.heading}>
<Image
data-testid="sidebar-logo"
src={ICON_PATH_LOGO}
width={50}
height={50}
/>
<h3 data-testid="sidebar-title">RealDevSquad</h3>
</span>
<div className={styles.options}>
{sidebarMenuOptions.map((option, index) => {
return (
<span
key={index}
// this code below insure even if we are in nested path like currency-exchange/**/
//even then the link is active
className={styles.option + addActiveOptionClass(option.urlPath)}
onClick={() => navigateTo(option.urlPath)}
>
<Image
data-testid={`sidebar-menu-icon=${option.iconPath}`}
src={option.iconPath}
className={styles.option_image}
width={MENU_ICON_WIDTH}
height={MENU_ICON_HEIGHT}
/>
<p data-testid={`sidebar-menu-title-${option.name}`}>
{option.name}
</p>
<span className={styles.option_bar}></span>
</span>
);
})}
</div>

<div className={styles.buttonWrapper}>
{router.pathname !== '/currency-exchange' && (
manish591 marked this conversation as resolved.
Show resolved Hide resolved
<button
data-testid="sidebar-trade-button"
className={styles.button}
>
<Image
data-testid="sidebar-trade-button-icon"
src={ICON_PATH_INFO}
width={MENU_ICON_WIDTH}
height={MENU_ICON_HEIGHT}
/>
Trade Now
</button>
)}
<button data-testid="sidebar-guide-button" className={styles.button}>
<Image
data-testid="sidebar-guide-button-icon"
src={ICON_PATH_INFO}
width={MENU_ICON_WIDTH}
height={MENU_ICON_HEIGHT}
/>
Guide
</button>
</div>
</aside>
</div>
);
};

export default Sidebar;
Loading