feat(profile): Add Top Contributor
badge feature (#38348)
Co-authored-by: Twaha Rahman <39026437+Twaha-Rahman@users.noreply.github.com> Co-authored-by: Twaha Rahman <mahi6703890@gmail.com> Co-authored-by: moT01 <20648924+moT01@users.noreply.github.com>
This commit is contained in:
@ -70,7 +70,7 @@ describe('<NavLinks />', () => {
|
|||||||
expect(avatarHasClass(componentTree, 'gold-border')).toBeTruthy();
|
expect(avatarHasClass(componentTree, 'gold-border')).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has avatar with green border for top contributors', () => {
|
it('has avatar with blue border for top contributors', () => {
|
||||||
const topContributorUserProps = {
|
const topContributorUserProps = {
|
||||||
user: {
|
user: {
|
||||||
username: 'test-user',
|
username: 'test-user',
|
||||||
@ -84,7 +84,7 @@ describe('<NavLinks />', () => {
|
|||||||
.create(<AuthOrProfile {...topContributorUserProps} />)
|
.create(<AuthOrProfile {...topContributorUserProps} />)
|
||||||
.toJSON();
|
.toJSON();
|
||||||
|
|
||||||
expect(avatarHasClass(componentTree, 'green-border')).toBeTruthy();
|
expect(avatarHasClass(componentTree, 'blue-border')).toBeTruthy();
|
||||||
});
|
});
|
||||||
it('has avatar with purple border for donating top contributors', () => {
|
it('has avatar with purple border for donating top contributors', () => {
|
||||||
const topDonatingContributorUserProps = {
|
const topDonatingContributorUserProps = {
|
||||||
|
@ -189,8 +189,8 @@
|
|||||||
border: 2px solid var(--yellow-gold);
|
border: 2px solid var(--yellow-gold);
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-list .green-border {
|
.nav-list .blue-border {
|
||||||
border: 2px solid var(--green-mid);
|
border: 2px solid var(--blue-mid);
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-list .purple-border {
|
.nav-list .purple-border {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
export default function borderColorPicker(isDonating, isTopContributor) {
|
export default function borderColorPicker(isDonating, isTopContributor) {
|
||||||
if (isDonating && isTopContributor) return 'purple-border';
|
if (isDonating && isTopContributor) return 'purple-border';
|
||||||
else if (isTopContributor) return 'green-border';
|
else if (isTopContributor) return 'blue-border';
|
||||||
else if (isDonating) return 'gold-border';
|
else if (isDonating) return 'gold-border';
|
||||||
else return 'default-border';
|
else return 'default-border';
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
--blue-light: #99c9ff;
|
--blue-light: #99c9ff;
|
||||||
--blue-dark: #002ead;
|
--blue-dark: #002ead;
|
||||||
--green-light: #acd157;
|
--green-light: #acd157;
|
||||||
--green-mid: green;
|
--blue-mid: #198eee;
|
||||||
--purple-mid: darkviolet;
|
--purple-mid: darkviolet;
|
||||||
--green-dark: #00471b;
|
--green-dark: #00471b;
|
||||||
--red-light: #ffadad;
|
--red-light: #ffadad;
|
||||||
|
@ -11,6 +11,7 @@ import {
|
|||||||
import { AvatarRenderer } from '../../helpers';
|
import { AvatarRenderer } from '../../helpers';
|
||||||
|
|
||||||
import SocialIcons from './SocialIcons';
|
import SocialIcons from './SocialIcons';
|
||||||
|
import Link from '../../helpers/Link';
|
||||||
|
|
||||||
import './camper.css';
|
import './camper.css';
|
||||||
|
|
||||||
@ -120,7 +121,8 @@ function Camper({
|
|||||||
<div>
|
<div>
|
||||||
<br />
|
<br />
|
||||||
<p className='text-center yearsTopContributor'>
|
<p className='text-center yearsTopContributor'>
|
||||||
<FontAwesomeIcon icon={faAward} /> Top Contributor
|
<FontAwesomeIcon icon={faAward} />{' '}
|
||||||
|
<Link to={'/top-contributors'}>Top Contributor</Link>
|
||||||
</p>
|
</p>
|
||||||
<p className='text-center'>{joinArray(yearsTopContributor)}</p>
|
<p className='text-center'>{joinArray(yearsTopContributor)}</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
border: 10px solid var(--yellow-gold);
|
border: 10px solid var(--yellow-gold);
|
||||||
}
|
}
|
||||||
|
|
||||||
.avatar-container .green-border {
|
.avatar-container .blue-border {
|
||||||
border: 10px solid var(--green-mid);
|
border: 10px solid var(--blue-mid);
|
||||||
}
|
}
|
||||||
|
|
||||||
.avatar-container .purple-border {
|
.avatar-container .purple-border {
|
||||||
|
42
cypress/integration/top-contributor.js
Normal file
42
cypress/integration/top-contributor.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/* global cy */
|
||||||
|
|
||||||
|
describe('Top contributor in user profile', () => {
|
||||||
|
before(() => {
|
||||||
|
cy.clearCookies();
|
||||||
|
cy.exec('npm run seed:auth-user -- --top-contributor');
|
||||||
|
});
|
||||||
|
|
||||||
|
after(() => {
|
||||||
|
cy.exec('npm run seed');
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.login();
|
||||||
|
cy.contains('Profile').click({ force: true });
|
||||||
|
|
||||||
|
// The following line is only required if you want to test it in development
|
||||||
|
// cy.contains('Preview custom 404 page').click();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should show `Top Contributor` text with badge', () => {
|
||||||
|
cy.contains('Top Contributor')
|
||||||
|
.parent()
|
||||||
|
.within(() => {
|
||||||
|
cy.contains('Top Contributor').should('be.visible');
|
||||||
|
cy.get('svg').should('be.visible');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
it('Should take user to `Top Contributor` page when `Top Contributor` gets clicked', () => {
|
||||||
|
cy.contains('Top Contributor').should(
|
||||||
|
'have.attr',
|
||||||
|
'href',
|
||||||
|
'/top-contributors'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should show years when it was achieved', () => {
|
||||||
|
cy.contains('2017, 2018 and 2019').should('be.visible');
|
||||||
|
});
|
||||||
|
});
|
@ -4,6 +4,8 @@ const MongoClient = require('mongodb').MongoClient;
|
|||||||
const ObjectId = require('mongodb').ObjectID;
|
const ObjectId = require('mongodb').ObjectID;
|
||||||
const debug = require('debug');
|
const debug = require('debug');
|
||||||
|
|
||||||
|
const envVariables = process.argv;
|
||||||
|
|
||||||
const log = debug('fcc:tools:seedLocalAuthUser');
|
const log = debug('fcc:tools:seedLocalAuthUser');
|
||||||
const { MONGOHQ_URL } = process.env;
|
const { MONGOHQ_URL } = process.env;
|
||||||
|
|
||||||
@ -73,7 +75,9 @@ MongoClient.connect(MONGOHQ_URL, { useNewUrlParser: true }, function(
|
|||||||
isMachineLearningPyCertV7: false,
|
isMachineLearningPyCertV7: false,
|
||||||
completedChallenges: [],
|
completedChallenges: [],
|
||||||
portfolio: [],
|
portfolio: [],
|
||||||
yearsTopContributor: [],
|
yearsTopContributor: envVariables.includes('--top-contributor')
|
||||||
|
? ['2017', '2018', '2019']
|
||||||
|
: [],
|
||||||
rand: 0.6126749173148205,
|
rand: 0.6126749173148205,
|
||||||
theme: 'default',
|
theme: 'default',
|
||||||
profileUI: {
|
profileUI: {
|
||||||
@ -91,7 +95,7 @@ MongoClient.connect(MONGOHQ_URL, { useNewUrlParser: true }, function(
|
|||||||
badges: {
|
badges: {
|
||||||
coreTeam: []
|
coreTeam: []
|
||||||
},
|
},
|
||||||
isDonating: false,
|
isDonating: envVariables.includes('--donor'),
|
||||||
emailAuthLinkTTL: null,
|
emailAuthLinkTTL: null,
|
||||||
emailVerifyTTL: null
|
emailVerifyTTL: null
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user