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

Implement profile page #117

Merged
merged 25 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
35 changes: 35 additions & 0 deletions cypress/e2e/pages/edit-profile.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/// <reference types="cypress" />

describe('Edit Profile Page', () => {
beforeEach(() => {
cy.login('standard');
cy.location('pathname').should('equal', '/');
cy.visit('/profile/edit');
cy.location('pathname').should('equal', '/profile/edit');
});

it('Should update profile preview', () => {
// write something new to make sure it can save
cy.typeInForm('First', new Date().toISOString());
cy.get('button').contains('Save').click();

cy.fixture('profile').then(profile => {
const { first, last, bio, major, year } = profile;

cy.typeInForm('First', first);
cy.typeInForm('Last', last);
cy.selectInForm('Major', major);
cy.selectInForm('Graduation Year', year);
cy.typeInForm('Biography', bio);
cy.get('button').contains('Save').click();

cy.get('.Toastify').contains('Changes saved!').should('exist');

cy.get('section:contains("Current Profile")').within(() => {
Object.values(profile).forEach((value: string | number) => {
cy.contains(value).should('exist');
});
});
});
});
});
7 changes: 7 additions & 0 deletions cypress/fixtures/profile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"first": "John",
"last": "Doe",
"bio": "I am a testing account.",
"major": "Computer Engineering",
"year": "2026"
}
49 changes: 49 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1 +1,50 @@
declare global {
namespace Cypress {
interface Chainable {
/**
* Log in as the specified user, pulling details from accounts.json
* @example cy.login('standard')
*/
login(account: string): Chainable<void>;

/**
* Type text into a form input or textarea under specified label
* @param label - text of label that the input is a child of
* @param value - text to be typed into input
*/
typeInForm(label: string, value: string): Chainable<void>;

/**
* Select the given option in a select under specified label
* @param label - text of label that the select is a child of
* @param value - option to be selected
*/
selectInForm(label: string, value: string): Chainable<void>;
}
}
}

Cypress.Commands.add('login', (account: string) => {
cy.fixture('accounts.json').then(accs => {
if (!(account in accs))
throw new Error(`Account '${account}' isn't specified in \`accounts.json\``);
const { email, password } = accs[account];

cy.visit('/login');
cy.get('input[name="email"]').type(email);
raymosun marked this conversation as resolved.
Show resolved Hide resolved
cy.get('input[name="password"]').type(password);
cy.get('button').contains('Sign In').click();
});
});

Cypress.Commands.add('typeInForm', (label: string, value: string) => {
cy.get(`label:contains("${label}") input, label:contains("${label}") textarea`).as('input');
cy.get('@input').clear();
cy.get('@input').type(value as string);
});

Cypress.Commands.add('selectInForm', (label: string, value: string | number) => {
cy.get(`label:contains("${label}") select`).select(value);
});

export {};
3 changes: 3 additions & 0 deletions public/assets/icons/edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/assets/icons/email-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/assets/icons/facebook-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/assets/icons/github-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion public/assets/icons/ig-icon.svg

This file was deleted.

2 changes: 1 addition & 1 deletion public/assets/icons/instagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/assets/icons/leaderboard-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/assets/icons/link-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/assets/icons/linkedin-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions public/assets/icons/major-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/assets/icons/profile-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/assets/icons/twitter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions src/components/common/GifSafeImage/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { isSrcAGif } from '@/lib/utils';
import Image, { ImageProps } from 'next/image';

/**
* A next/image Image that is automatically unoptimized when `src` is a gif
* @param props - props for Next Image component
* @returns image component
*/
const GifSafeImage = ({ src, alt, ...restProps }: ImageProps) => {
farisashai marked this conversation as resolved.
Show resolved Hide resolved
return <Image src={src} alt={alt} unoptimized={isSrcAGif(src)} {...restProps} />;
};

export default GifSafeImage;
1 change: 1 addition & 0 deletions src/components/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export { default as Carousel } from './Carousel';
export { default as CommunityLogo } from './CommunityLogo';
export { default as Cropper } from './Cropper';
export { default as Dropdown } from './Dropdown';
export { default as GifSafeImage } from './GifSafeImage';
export { default as LinkButton } from './LinkButton';
export { default as Modal } from './Modal';
export { default as PaginationControls } from './PaginationControls';
Expand Down
Loading