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

ALMP-393 #81

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
131 changes: 131 additions & 0 deletions cypress/component/UserProfile.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import * as React from 'react'
import { composeStories } from '@storybook/testing-react'
import * as stories from '../../src/stories/UserProfile.stories'
import terminalLog from '../support/component'


const { Primary } = composeStories(stories)

describe('UserProfile.tsx', function () {

const user= {

            firstname: { control: 'text' },
lastName: { control: 'text' },

            image: { control: 'text' },

            email: { control: 'text' },

            planOfStudy: [

                {

                    status: { control: 'text' },

                    term: { control: 'text' },

                },

                {

                    status: { control: 'text' },

                    term: { control: 'text' },

                },

                {

                    status: { control: 'text' },

                    term: { control: 'text' },

                },

            ],

        }

    const    isCurrentUser={ control: 'boolean' }
beforeEach(() => {
cy.injectAxe()
})
it('should render component', () => {
cy.mount(< Primary />)
expect(cy.get('div')).to.exist




})
it('should have no accessibility violations', () => {
cy.mount(<Primary />)
cy.checkA11y(undefined, {
runOnly: {
type: 'tag',
values: ['wcag2a', 'wcag2aa', "section508"],
}
}, terminalLog)
})
it('should render component with a image ', () => {
cy.mount(<Primary />)

cy.get('span').should('have.class', 'cursor-pointer')
cy.get('img')





})
it('should render component with a sidebar which has Userinfo, Planofstudy and profile tabs ', () => {
cy.mount(<Primary />)

cy.get('button')
cy.get('li').should('have.class', 'py-1 px-3 hover:bg-gray-100 border-b border-gray-300 list-none')
cy.get('a[href="#user"]').should('have.class', 'text-base')
cy.get('li[role="UserInfo-Link"]').should('have.class', 'py-1 px-3 hover:bg-gray-100 border-b border-gray-300 list-none')
cy.get('a[href="#modules"]').should('have.class', 'text-base')
cy.get('li[role="PlanOfStudy-Link"]').should('have.class', 'py-1 px-3 hover:bg-gray-100 border-b border-gray-300 list-none')

})
it('should render component which shows UserInfo details ', () => {
cy.mount(<Primary />)

cy.get('form')
cy.get('div').should('have.class', 'flex md:flex-row md:justify-between flex-col mb-3')
cy.get('Input[name="firstName"]')
cy.get('Input[name="lastName"]')
cy.get('div').should('have.class', 'w-full mb-3')
cy.get('Input[name="email"]')
cy.get('Button[label="Update Profile"]')
cy.get('button').should('have.class','text-white border-red-400 bg-red-500 rounded w-auto px-4 py-2')


})
it('should render component which shows PlanOfStudy details ', () => {
cy.mount(<Primary />)

cy.get('h3').should('have.class', 'text-2xl bold border-b border-gray-200 mb-3')
cy.get('table').should('have.class', 'border-separate border-spacing-2 border border-slate-400')
cy.get('thead')
cy.get('tr')
cy.get('th[role="StatusRole"]').should('have.class', 'p-2 border border-slate-300')
cy.get('th[role="TermRole"]').should('have.class', 'p-2 border border-slate-300')
cy.get('tbody')
cy.get('tr')
cy.get('td[role="userStatus-index-0"]').should('have.class','p-2 border border-slate-300')
cy.get('td[role="termStatus-index-0"]').should('have.class','p-2 border border-slate-300')
cy.get('tr')
cy.get('td[role="userStatus-index-1"]').should('have.class','p-2 border border-slate-300')
cy.get('td[role="termStatus-index-1"]').should('have.class','p-2 border border-slate-300')
cy.get('tr')
cy.get('td[role="userStatus-index-2"]').should('have.class','p-2 border border-slate-300')
cy.get('td[role="termStatus-index-2"]').should('have.class','p-2 border border-slate-300')



})

})
20 changes: 10 additions & 10 deletions src/components/UserProfile/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const UserProfile = ({ user, isCurrentUser }: UserProfileProps) => {

<a className=" text-base" href="#user">
<li
className="py-1 px-3 hover:bg-gray-100 border-b border-gray-300 list-none"
className="py-1 px-3 hover:bg-gray-100 border-b border-gray-300 list-none" role ="UserInfo-Link"
// onClick={() => {
// setShowProfile(!showProfile),
// setShowPlanOfStudy(showPlanOfStudy)
Expand All @@ -44,7 +44,7 @@ export const UserProfile = ({ user, isCurrentUser }: UserProfileProps) => {
</a>
<a className="text-base" href="#modules">
<li
className="py-1 px-3 hover:bg-gray-100 border-b border-gray-300 list-none"
className="py-1 px-3 hover:bg-gray-100 border-b border-gray-300 list-none" role="PlanOfStudy-Link"
// onClick={() => {
// setShowPlanOfStudy(!showPlanOfStudy),
// setShowProfile(showProfile)
Expand Down Expand Up @@ -141,36 +141,36 @@ export const UserProfile = ({ user, isCurrentUser }: UserProfileProps) => {
<table className="border-separate border-spacing-2 border border-slate-400 ...">
<thead>
<tr>
<th className="p-2 border border-slate-300 ...">
<th className="p-2 border border-slate-300 ..." role="StatusRole">
Status
</th>
<th className="p-2 border border-slate-300 ...">
<th className="p-2 border border-slate-300 ..." role="TermRole">
Term
</th>
</tr>
</thead>
<tbody>
<tr>
<td className="p-2 border border-slate-300 ...">
<td className="p-2 border border-slate-300 ..." role="userStatus-index-0">
{user.planOfStudy[0].status}
</td>
<td className="p-2 border border-slate-300 ...">
<td className="p-2 border border-slate-300 ..." role="termStatus-index-0">
{user.planOfStudy[0].term}
</td>
</tr>
<tr>
<td className="p-2 border border-slate-300 ...">
<td className="p-2 border border-slate-300 ..." role="userStatus-index-1">
{user.planOfStudy[1].status}
</td>
<td className="p-2 border border-slate-300 ...">
<td className="p-2 border border-slate-300 ..." role="termStatus-index-1">
{user.planOfStudy[1].term}
</td>
</tr>
<tr>
<td className="p-2 border border-slate-300 ...">
<td className="p-2 border border-slate-300 ..." role="userStatus-index-2">
{user.planOfStudy[2].status}
</td>
<td className="p-2 border border-slate-300 ...">
<td className="p-2 border border-slate-300 ..." role="termStatus-index-2">
{user.planOfStudy[2].term}
</td>
</tr>
Expand Down
10 changes: 7 additions & 3 deletions src/stories/UserProfile.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import * as React from 'react'
import { UserProfile } from '../components/UserProfile'
import { ComponentMeta, ComponentStory } from '@storybook/react'

export default {
title: 'Organisms/User Profile',
component: UserProfile,
}
 argTypes:{

}
}as ComponentMeta<typeof UserProfile>

const Template = (args) => <UserProfile {...args} />

export const Primary = Template.bind({})
export const Primary: ComponentStory<typeof UserProfile> = Template.bind({})
Primary.args = {
isCurrentUser: 'true',
isCurrentUser: true,
user: {
firstname: 'Avantika',
lastName: 'Mittapally',
Expand Down