Skip to content

Commit

Permalink
Merge pull request #2262 from beckn/feat-dsep-cypress-job-apply
Browse files Browse the repository at this point in the history
feat(DSEP): cypress text case for job apply page
  • Loading branch information
aniketceminds authored Oct 10, 2024
2 parents 7509dfe + e43edf9 commit 34b81a8
Show file tree
Hide file tree
Showing 13 changed files with 611 additions and 4 deletions.
7 changes: 5 additions & 2 deletions apps/dsep/pages/applicationSent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useRouter } from 'next/router'
import React from 'react'
import orderConfirmmark from '../public/images/orderConfirmmark.svg'
import { useLanguage } from '../hooks/useLanguage'
import { testIds } from '@shared/dataTestIds'

const applicationSent = () => {
const { t } = useLanguage()
Expand All @@ -22,7 +23,8 @@ const applicationSent = () => {
},
disabled: false,
variant: 'solid',
colorScheme: 'primary'
colorScheme: 'primary',
dataTest: testIds.jobSubmitted_viewNewJob
},
{
text: t.goBackBtn,
Expand All @@ -31,7 +33,8 @@ const applicationSent = () => {
},
disabled: false,
variant: 'outline',
colorScheme: 'primary'
colorScheme: 'primary',
dataTest: testIds.jobSubmitted_viewToHomePage
}
]
}}
Expand Down
3 changes: 3 additions & 0 deletions apps/dsep/pages/jobApply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { ConfirmResponseModel } from '../lib/types/confirm.types'
import 'react-toastify/dist/ReactToastify.css'
import { InitResponseModel } from '../lib/types/init.types'
import axios from '../services/axios'
import { testIds } from '@shared/dataTestIds'

const jobApply = () => {
const [selectedFiles, setSelectedFiles] = useState<File[]>([])
Expand Down Expand Up @@ -185,6 +186,7 @@ const jobApply = () => {
<LoaderWithMessage
loadingSubText=""
loadingText=""
dataTest={testIds.loadingIndicator}
/>
</Box>
)
Expand All @@ -200,6 +202,7 @@ const jobApply = () => {
<LoaderWithMessage
loadingSubText={t.applicationLoaderText}
loadingText={t.categoryLoadPrimary}
dataTest={testIds.loadingIndicator}
/>
</Box>
)
Expand Down
81 changes: 81 additions & 0 deletions cypress/e2e/dsep/jobApply.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { testIds } from '../../../shared/dataTestIds'
import { initResponse } from '../../fixtures/DSEP/checkoutPage/initResponse'
import { confirmResponse } from '../../fixtures/DSEP/orderConfirmation/confirmResponse'
import { orderResponse } from '../../fixtures/DSEP/orderConfirmation/orderResponse'
import { statusResponse } from '../../fixtures/DSEP/orderDetails/statusResponse'
import 'cypress-file-upload'

describe.only('job Apply Page', () => {
const searchTerm = 'Java'

before(() => {
cy.login(testIds.url_base, testIds.user_validEmail, testIds.user_validPassword)
cy.visit(`${testIds.url_base}${testIds.url_home}`)
cy.performSearch(searchTerm, {
fixture: 'DSEP/searchPage/searchResults.json'
})
cy.performSelect({ fixture: 'DSEP/checkoutPage/selectResponse.json' }, 'selectResponse')
cy.selectProduct(0)
cy.getByData(testIds.productpage_addTocartButton).click()
cy.getByData(testIds.cartButton).click()
cy.wait('@selectResponse')
cy.getByData(testIds.cartpage_cartOrderButton).click()
cy.getByData(testIds.feedback).getByData('close').click()
cy.intercept('GET', '**/api/profiles?populate[0]=documents.attachment', {
fixture: 'DSEP/checkoutPage/profilePopulate.json'
}).as('getProfilePopulate')
cy.url().should('include', '/checkoutPage')
cy.fillAndSaveShippingDetails()
cy.performInit(initResponse, 'initResponse')
cy.wait('@initResponse')
cy.getByData(testIds.checkoutpage_proceedToCheckout).click()
cy.performConfirm(confirmResponse, 'confirmResponse')
cy.performOrders(orderResponse, 'orderResponse')
cy.performStatus(statusResponse('PAYMENT_RECEIVED'), 'processStatusResponse')
cy.wait('@confirmResponse')
cy.wait('@orderResponse')
cy.url().should('include', '/orderConfirmation')
cy.getByData(testIds.orderConfirmation_viewOrderButton).click()
cy.wait('@processStatusResponse')
cy.getByData(testIds.job_main_container_job_search_link).click()
cy.intercept('POST', 'https://bap-gcl-prod.becknprotocol.io/search', {
fixture: 'DSEP/jobSearchResponse/jobSearchResponse.json'
}).as('jobSearchResponse')
cy.url().should('include', '/jobSearch')
cy.getByData('job-detail-link').eq(1).click()
cy.url().should('include', '/jobDetails?jobDetails')
cy.getByData(testIds.job_details_apply).click()
cy.intercept('GET', '**/api/profiles?populate[0]=documents.attachment', {
fixture: 'DSEP/jobApply/profilePopulate.json'
}).as('profilePopulate')
cy.intercept('POST', '**/select', {
fixture: 'DSEP/jobApply/selectResponse.json'
}).as('selectResponse')
cy.intercept('POST', '**/init', {
fixture: 'DSEP/jobApply/initResponse.json'
}).as('initResponse')
cy.url().should('include', '/jobApply?jobDetails')

cy.getByData(testIds.loadingIndicator).should('be.visible')
})
it('Should render job 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')
})

it('Should show error messages for invalid data fields', () => {
cy.get('#name').clear().type('1')
cy.get('#mobile').clear().type('w')
cy.get('#email').clear().type('2')
cy.get('#nameError').should('contain', 'Please enter a valid name.')
cy.get('#mobileError').should('contain', 'Please enter a valid 10-digit mobile number.')
cy.get('#emailError').should('contain', 'Please enter a valid email address.')
cy.get('#submitButton').should('be.disabled')
})
it('Should render job apply page With valid data', () => {
cy.fillDSEPJobApply()
cy.url().should('include', '/applicationSent')
})
})
5 changes: 3 additions & 2 deletions cypress/e2e/dsep/jobDetails.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ describe.only('job Details Page', () => {
cy.getByData(testIds.orderConfirmation_viewOrderButton).click()
cy.wait('@processStatusResponse')
cy.getByData(testIds.job_main_container_job_search_link).click()
cy.intercept('POST', 'https://bap-gcl-prod.becknprotocol.io/search', {
cy.url().should('include', '/jobSearch')
cy.intercept('POST', '**/search', {
fixture: 'DSEP/jobSearchResponse/jobSearchResponse.json'
}).as('jobSearchResponse')
cy.url().should('include', '/jobSearch')
cy.wait('@jobSearchResponse')
cy.getByData('job-detail-link').eq(1).click()
cy.url().should('include', '/jobDetails?jobDetails')
})
Expand Down
133 changes: 133 additions & 0 deletions cypress/e2e/dsep/jobSubmittedPage.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import { testIds } from '../../../shared/dataTestIds'
import { initResponse } from '../../fixtures/DSEP/checkoutPage/initResponse'
import { confirmResponse } from '../../fixtures/DSEP/orderConfirmation/confirmResponse'
import { orderResponse } from '../../fixtures/DSEP/orderConfirmation/orderResponse'
import { statusResponse } from '../../fixtures/DSEP/orderDetails/statusResponse'
import 'cypress-file-upload'

describe.only('Job Submitted Page', () => {
const searchTerm = 'Java'
context('should render Job Search Page when user click on search more jobs button', () => {
before(() => {
cy.login(testIds.url_base, testIds.user_validEmail, testIds.user_validPassword)
cy.visit(`${testIds.url_base}${testIds.url_home}`)
cy.performSearch(searchTerm, {
fixture: 'DSEP/searchPage/searchResults.json'
})
cy.performSelect({ fixture: 'DSEP/checkoutPage/selectResponse.json' }, 'selectResponse')
cy.selectProduct(0)
cy.getByData(testIds.productpage_addTocartButton).click()
cy.getByData(testIds.cartButton).click()
cy.wait('@selectResponse')
cy.getByData(testIds.cartpage_cartOrderButton).click()
cy.getByData(testIds.feedback).getByData('close').click()
cy.intercept('GET', '**/api/profiles?populate[0]=documents.attachment', {
fixture: 'DSEP/checkoutPage/profilePopulate.json'
}).as('getProfilePopulate')
cy.url().should('include', '/checkoutPage')
cy.fillAndSaveShippingDetails()
cy.performInit(initResponse, 'initResponse')
cy.wait('@initResponse')
cy.getByData(testIds.checkoutpage_proceedToCheckout).click()
cy.performConfirm(confirmResponse, 'confirmResponse')
cy.performOrders(orderResponse, 'orderResponse')
cy.performStatus(statusResponse('PAYMENT_RECEIVED'), 'processStatusResponse')
cy.wait('@confirmResponse')
cy.wait('@orderResponse')
cy.url().should('include', '/orderConfirmation')
cy.getByData(testIds.orderConfirmation_viewOrderButton).click()
cy.wait('@processStatusResponse')
cy.getByData(testIds.job_main_container_job_search_link).click()
cy.intercept('POST', 'https://bap-gcl-prod.becknprotocol.io/search', {
fixture: 'DSEP/jobSearchResponse/jobSearchResponse.json'
}).as('jobSearchResponse')
cy.url().should('include', '/jobSearch')
cy.getByData('job-detail-link').eq(1).click()
cy.url().should('include', '/jobDetails?jobDetails')
cy.getByData(testIds.job_details_apply).click()
cy.intercept('GET', '**/api/profiles?populate[0]=documents.attachment', {
fixture: 'DSEP/jobApply/profilePopulate.json'
}).as('profilePopulate')
cy.intercept('POST', '**/select', {
fixture: 'DSEP/jobApply/selectResponse.json'
}).as('selectResponse')
cy.intercept('POST', '**/init', {
fixture: 'DSEP/jobApply/initResponse.json'
}).as('initResponse')
cy.url().should('include', '/jobApply?jobDetails')
cy.getByData(testIds.loadingIndicator).should('be.visible')
cy.fillDSEPJobApply()
cy.url().should('include', '/applicationSent')
})
it('should display job submitted details after API call', () => {
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',
'The company will evaluate your application and get back to you soon'
)
})
it('should have a button to search more jobs and navigate to job search page when clicked', () => {
cy.getByData(testIds.jobSubmitted_viewNewJob).click()
cy.url().should('include', '/jobSearch')
})
})
context('should render Home Page when user click on go back home button', () => {
before(() => {
cy.login(testIds.url_base, testIds.user_validEmail, testIds.user_validPassword)
cy.visit(`${testIds.url_base}${testIds.url_home}`)
cy.performSearch(searchTerm, {
fixture: 'DSEP/searchPage/searchResults.json'
})
cy.performSelect({ fixture: 'DSEP/checkoutPage/selectResponse.json' }, 'selectResponse')
cy.selectProduct(0)
cy.getByData(testIds.productpage_addTocartButton).click()
cy.getByData(testIds.cartButton).click()
cy.wait('@selectResponse')
cy.getByData(testIds.cartpage_cartOrderButton).click()
cy.getByData(testIds.feedback).getByData('close').click()
cy.intercept('GET', '**/api/profiles?populate[0]=documents.attachment', {
fixture: 'DSEP/checkoutPage/profilePopulate.json'
}).as('getProfilePopulate')
cy.url().should('include', '/checkoutPage')
cy.fillAndSaveShippingDetails()
cy.performInit(initResponse, 'initResponse')
cy.wait('@initResponse')
cy.getByData(testIds.checkoutpage_proceedToCheckout).click()
cy.performConfirm(confirmResponse, 'confirmResponse')
cy.performOrders(orderResponse, 'orderResponse')
cy.performStatus(statusResponse('PAYMENT_RECEIVED'), 'processStatusResponse')
cy.wait('@confirmResponse')
cy.wait('@orderResponse')
cy.url().should('include', '/orderConfirmation')
cy.getByData(testIds.orderConfirmation_viewOrderButton).click()
cy.wait('@processStatusResponse')
cy.getByData(testIds.job_main_container_job_search_link).click()
cy.intercept('POST', 'https://bap-gcl-prod.becknprotocol.io/search', {
fixture: 'DSEP/jobSearchResponse/jobSearchResponse.json'
}).as('jobSearchResponse')
cy.url().should('include', '/jobSearch')
cy.getByData('job-detail-link').eq(1).click()
cy.url().should('include', '/jobDetails?jobDetails')
cy.getByData(testIds.job_details_apply).click()
cy.intercept('GET', '**/api/profiles?populate[0]=documents.attachment', {
fixture: 'DSEP/jobApply/profilePopulate.json'
}).as('profilePopulate')
cy.intercept('POST', '**/select', {
fixture: 'DSEP/jobApply/selectResponse.json'
}).as('selectResponse')
cy.intercept('POST', '**/init', {
fixture: 'DSEP/jobApply/initResponse.json'
}).as('initResponse')
cy.url().should('include', '/jobApply?jobDetails')
cy.getByData(testIds.loadingIndicator).should('be.visible')
cy.fillDSEPJobApply()
cy.url().should('include', '/applicationSent')
})

it('should have a button to go back home and navigate to home page when clicked', () => {
cy.getByData(testIds.jobSubmitted_viewToHomePage).click()
cy.url().should('include', '/')
})
})
})
Loading

0 comments on commit 34b81a8

Please sign in to comment.