Skip to content

Commit

Permalink
feat(dsep): added test cases for dsep
Browse files Browse the repository at this point in the history
1. added tewst cases for scholarship apply page
2. added test cases for scholarship confirmation page
3. added test cases for scholarship order page
  • Loading branch information
skrushna1506 committed Oct 10, 2024
1 parent 34b81a8 commit dbc8de6
Show file tree
Hide file tree
Showing 13 changed files with 490 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React from 'react'
import { Button, Typography } from '@beckn-ui/molecules'
import CartEmpty from '../../../public/images/cartEmptyIcon.svg'
import { useLanguage } from '../../../hooks/useLanguage'
import { testIds } from '@shared/dataTestIds'

const EmptyScholarship: React.FC = () => {
const { t } = useLanguage()
Expand All @@ -25,6 +26,7 @@ const EmptyScholarship: React.FC = () => {
>
<Image
src={CartEmpty}
data-test={testIds.cartpage_emptyImage}
width={'306px'}
height={'245px'}
alt="empty cart logo"
Expand All @@ -37,6 +39,7 @@ const EmptyScholarship: React.FC = () => {
>
<Typography
fontSize="15px"
dataTest={testIds.noScholarship}
fontWeight="600"
text={t.noScholarship}
style={{
Expand All @@ -50,6 +53,7 @@ const EmptyScholarship: React.FC = () => {
lineHeight: '25px'
}}
text={t.noScholarshipText1}
dataTest={testIds.noScholarshipText1}
/>
<Typography
fontSize="12px"
Expand All @@ -58,10 +62,12 @@ const EmptyScholarship: React.FC = () => {
lineHeight: '25px'
}}
text={t.noScholarshipText2}
dataTest={testIds.noScholarshipText2}
/>
</Flex>

<Button
dataTest={testIds.emptyScholarshipButton}
text={t.searchScholarships}
color={'rgba(var(--text-color))'}
disabled={false}
Expand Down
4 changes: 3 additions & 1 deletion apps/dsep/pages/scholarshipConfirmationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useRouter } from 'next/router'
import orderConfirmmark from '../public/images/orderConfirmmark.svg'
import { ParsedScholarshipData } from '../components/scholarship/scholarshipCard/Scholarship.types'
import { useLanguage } from '../hooks/useLanguage'
import { testIds } from '@shared/dataTestIds'

const scholarshipConfirmationPage = () => {
const { t } = useLanguage()
Expand Down Expand Up @@ -38,7 +39,8 @@ const scholarshipConfirmationPage = () => {
},
disabled: false,
variant: 'solid',
colorScheme: 'primary'
colorScheme: 'primary',
dataTest: testIds.scholarshipConfirmation_cart
}
]
}}
Expand Down
79 changes: 53 additions & 26 deletions cypress/e2e/dsep/myScholarshipPage.cy.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,59 @@
import { testIds } from '../../../shared/dataTestIds'
describe('My Scholarship Page', () => {
before(() => {
cy.login(testIds.url_base, testIds.user_validEmail, testIds.user_validPassword)
cy.visit(`${testIds.url_base}${testIds.url_home}`)
cy.getByData(testIds.threeDots).click()
cy.getByData(testIds.myScholarship_text).click()
cy.intercept('GET', '**/orders?filters[category]=2', {
fixture: 'DSEP/myScholarshipOrder/myScholarshipOrderResponse.json'
}).as('myScholarshipOrderResponse')
context('Show empty page when there is no order response for scholarship page', () => {
before(() => {
cy.login(testIds.url_base, testIds.user_firstTimeLoginvalidEmail, testIds.user_firstTimeLoginvalidPassword)
cy.visit(`${testIds.url_base}${testIds.url_home}`)
cy.getByData(testIds.threeDots).click()
cy.getByData(testIds.myScholarship_text).click()
cy.intercept('GET', '**/orders?filters[category]=2', {
fixture: 'DSEP/myScholarshipOrder/emptyScholarshipOrderResponse.json'
}).as('emptyScholarshipOrderResponse')
})
it('Should render Empty Scholarship Search Page ', () => {
cy.getByData(testIds.cartpage_emptyImage).should('be.visible')
cy.getByData(testIds.noScholarship).should('be.visible')
cy.getByData(testIds.noScholarshipText1).should('be.visible')
cy.getByData(testIds.noScholarshipText2).should('be.visible')
cy.getByData(testIds.emptyScholarshipButton).should('be.visible')
})
it('Should Navigate to My Scholarship Page when Click on Button', () => {
cy.getByData(testIds.noScholarship).should('contain.text', 'No Scholarship!')
cy.getByData(testIds.noScholarshipText1).should('contain.text', 'Look like you haven’t applied for any')
cy.getByData(testIds.noScholarshipText2).should('contain.text', 'Scholarship!')
cy.getByData(testIds.emptyScholarshipButton).click()
cy.url().should('include', '/scholarshipSearchPage')
})
})
context('Show Search Page when there is order response for scholarship page', () => {
before(() => {
cy.login(testIds.url_base, testIds.user_validEmail, testIds.user_validPassword)
cy.visit(`${testIds.url_base}${testIds.url_home}`)
cy.getByData(testIds.threeDots).click()
cy.getByData(testIds.myScholarship_text).click()
cy.intercept('GET', '**/orders?filters[category]=2', {
fixture: 'DSEP/myScholarshipOrder/myScholarshipOrderResponse.json'
}).as('myScholarshipOrderResponse')
})

it('Should render My Scholarship Page All Elements', () => {
cy.getByData(testIds.scholarshipCardHeading).eq(1).should('be.visible')
cy.getByData(testIds.scholarshipCardTime).eq(1).should('be.visible')
cy.getByData(testIds.scholarshipCardID).eq(1).should('be.visible')
cy.getByData(testIds.scholarshipCardButton).should('be.visible')
})
it('Should render My Scholarship Page', () => {
cy.getByData(testIds.scholarshipCardHeading).eq(1).should('contain.text', 'MS Ramaiah Memorial Scholarship')
cy.getByData(testIds.scholarshipCardTime).eq(1).should('contain.text', '27th May 2024, 10:36pm')
cy.getByData(testIds.scholarshipCardID).eq(1).should('contain.text', 'ID: 1338')
})
it('Should Navigate to scholarship Search page', () => {
cy.getByData(testIds.scholarshipCardButton).click()
cy.intercept('POST', '**/search', {
fixture: 'DSEP/myScholarshipOrder/scholarshipSearchResult.json'
}).as('scholarshipSearchResult')
cy.getByData(testIds.loadingIndicator).should('be.visible')
cy.url().should('include', '/scholarshipSearchPage')
it('Should render My Scholarship Page All Elements', () => {
cy.getByData(testIds.scholarshipCardHeading).eq(1).should('be.visible')
cy.getByData(testIds.scholarshipCardTime).eq(1).should('be.visible')
cy.getByData(testIds.scholarshipCardID).eq(1).should('be.visible')
cy.getByData(testIds.scholarshipCardButton).should('be.visible')
})
it('Should render My Scholarship Page', () => {
cy.getByData(testIds.scholarshipCardHeading).eq(1).should('contain.text', 'MS Ramaiah Memorial Scholarship')
cy.getByData(testIds.scholarshipCardTime).eq(1).should('contain.text', '27th May 2024, 10:36pm')
cy.getByData(testIds.scholarshipCardID).eq(1).should('contain.text', 'ID: 1338')
})
it('Should Navigate to scholarship Search page', () => {
cy.getByData(testIds.scholarshipCardButton).click()
cy.intercept('POST', '**/search', {
fixture: 'DSEP/myScholarshipOrder/scholarshipSearchResult.json'
}).as('scholarshipSearchResult')
cy.getByData(testIds.loadingIndicator).should('be.visible')
cy.url().should('include', '/scholarshipSearchPage')
})
})
})
64 changes: 64 additions & 0 deletions cypress/e2e/dsep/scholarshipApply.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { testIds } from '../../../shared/dataTestIds'
import 'cypress-file-upload'
describe('Scholarship search page', () => {
before(() => {
cy.login(testIds.url_base, testIds.user_validEmail, testIds.user_validPassword)
cy.visit(`${testIds.url_base}${testIds.url_home}`)
cy.getByData(testIds.threeDots).click()
cy.getByData(testIds.myScholarship_text).click()
cy.intercept('GET', '**/orders?filters[category]=2', {
fixture: 'DSEP/myScholarshipOrder/myScholarshipOrderResponse.json'
}).as('myScholarshipOrderResponse')
cy.wait(1000)
cy.getByData(testIds.scholarshipCardButton).click()
cy.intercept('POST', '**/search', {
fixture: 'DSEP/myScholarshipOrder/scholarshipSearchResult.json'
}).as('scholarshipSearchResult')
cy.getByData(testIds.loadingIndicator).should('be.visible')
cy.url().should('include', '/scholarshipSearchPage')
cy.getByData(testIds.search_card_link).eq(0).click()
cy.url().should('include', '/scholarshipDetailsPage')
cy.getByData(testIds.scholarship_details_Button).click()
cy.intercept('POST', '**/api/profiles?populate[0]=documents.attachment', {
fixture: 'DSEP/scholarshipApply/profilePopulate.json'
}).as('profilePopulate')
cy.intercept('POST', '**/select', {
fixture: 'DSEP/scholarshipApply/selectResponse.json'
}).as('selectResponse')
cy.intercept('POST', '**/init', {
fixture: 'DSEP/scholarshipApply/initResponse.json'
}).as('initResponse')
cy.getByData(testIds.loadingIndicator).should('be.visible')
cy.url().should('include', '/applyScholarship')
})
it('Should Render Scholarship Apply Page ', () => {
cy.get('#xinputform').should('be.visible')
cy.get('#nameLabel').should('be.visible')
cy.get('#mobileLabel').should('be.visible')
cy.get('#emailLabel').should('be.visible')
cy.get('#reasonLabel').should('be.visible')
cy.get('#reasonLabel').should('be.visible')
cy.get('#zipcodeLabel').should('be.visible')
cy.get('#submitButton').should('be.visible')
})

it('Should Validate Apply Scholarship page With non Valid data', () => {
cy.get('#name').type('1')
cy.get('#nameError').should('contain.text', 'Please enter a valid name.')
cy.get('#mobile').type('609')
cy.get('#mobileError').should('contain.text', 'Please enter a valid 10-digit mobile number.')
cy.get('#email').type('santosh.k@gmail')
cy.get('#emailError').should('contain.text', 'Please enter a valid email address.')
cy.get('#zipcode').type('123')
cy.get('#zipcodeError').should('contain.text', 'Please enter a valid zip code.')
cy.get('#submitButton').should('be.disabled')
})
it('Should Render Scholarship Apply page With Valid data and navigate to Scholarship Confirmation page ', () => {
cy.fillDSEP_x_inputScholarshipApplyForm()
cy.intercept('POST', '**/x-input/submit', {
fixture: 'DSEP/scholarshipApply/x-inputSubmitResponse.json'
}).as('x-inputSubmitResponse')
cy.wait(1000)
cy.url().should('include', '/scholarshipConfirmationPage')
})
})
51 changes: 51 additions & 0 deletions cypress/e2e/dsep/scholarshipConfirmation.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { testIds } from '../../../shared/dataTestIds'
import 'cypress-file-upload'
describe('Scholarship search page', () => {
before(() => {
cy.login(testIds.url_base, testIds.user_validEmail, testIds.user_validPassword)
cy.visit(`${testIds.url_base}${testIds.url_home}`)
cy.getByData(testIds.threeDots).click()
cy.getByData(testIds.myScholarship_text).click()
cy.intercept('GET', '**/orders?filters[category]=2', {
fixture: 'DSEP/myScholarshipOrder/myScholarshipOrderResponse.json'
}).as('myScholarshipOrderResponse')
cy.wait(1000)
cy.getByData(testIds.scholarshipCardButton).click()
cy.intercept('POST', '**/search', {
fixture: 'DSEP/myScholarshipOrder/scholarshipSearchResult.json'
}).as('scholarshipSearchResult')
cy.getByData(testIds.loadingIndicator).should('be.visible')
cy.url().should('include', '/scholarshipSearchPage')
cy.getByData(testIds.search_card_link).eq(0).click()
cy.url().should('include', '/scholarshipDetailsPage')
cy.getByData(testIds.scholarship_details_Button).click()
cy.intercept('POST', '**/api/profiles?populate[0]=documents.attachment', {
fixture: 'DSEP/scholarshipApply/profilePopulate.json'
}).as('profilePopulate')
cy.intercept('POST', '**/select', {
fixture: 'DSEP/scholarshipApply/selectResponse.json'
}).as('selectResponse')
cy.intercept('POST', '**/init', {
fixture: 'DSEP/scholarshipApply/initResponse.json'
}).as('initResponse')
cy.getByData(testIds.loadingIndicator).should('be.visible')
cy.url().should('include', '/applyScholarship')
cy.fillDSEP_x_inputScholarshipApplyForm()
cy.intercept('POST', '**/x-input/submit', {
fixture: 'DSEP/scholarshipApply/x-inputSubmitResponse.json'
}).as('x-inputSubmitResponse')
cy.url().should('include', '/scholarshipConfirmationPage')
})
it('should display Scholarship Confirmation Page', () => {
cy.getByData(testIds.confirmPageImage).should('have.attr', 'src')
cy.getByData(testIds.orderConfirmation_successOrderMessage).should('contain.text', 'Application Submitted!')
cy.getByData(testIds.orderConfirmation_gratefulMessage).should(
'contain.text',
'We will evaluate your application ID'
)
})
it('should navigate to Cart page when clicked On go to cart button', () => {
cy.getByData(testIds.scholarshipConfirmation_cart).click()
cy.url().should('include', '/cart')
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"meta": {
"pagination": {
"page": 1,
"pageSize": 25,
"pageCount": 1,
"total": 22
}
}
}
Binary file not shown.
Loading

0 comments on commit dbc8de6

Please sign in to comment.