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

Todo Section - Dialogs #28

Merged
merged 3 commits into from
Aug 19, 2024
Merged
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
6 changes: 3 additions & 3 deletions cypress/e2e/components/comments.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ context('Business dashboard -> Comment side modal', () => {
}

it('Comment side modal is rendered', () => {
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, undefined, allFilings, true)
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, false, undefined, allFilings, true)

cy.get('[data-cy="header.actions.dropdown"] button').should('exist')
cy.get('[data-cy="header.actions.dropdown"] button').eq(0).click()
Expand All @@ -32,7 +32,7 @@ context('Business dashboard -> Comment side modal', () => {

it('Should add a comment', () => {
const commentText = 'Test comment'
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, undefined, allFilings, true)
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, false, undefined, allFilings, true)

cy.get('[data-cy="header.actions.dropdown"] button').should('exist')
cy.get('[data-cy="header.actions.dropdown"] button').eq(0).click()
Expand All @@ -56,7 +56,7 @@ context('Business dashboard -> Comment side modal', () => {

it('Should fail to add a comment over 2000', () => {
const commentText = getString(2001)
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, undefined, allFilings, true)
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, false, undefined, allFilings, true)

cy.get('[data-cy="header.actions.dropdown"] button').should('exist')
cy.get('[data-cy="header.actions.dropdown"] button').eq(0).click()
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/components/filings/section.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { administrativeDissolution } from '../../../fixtures/filings/dissolution

context('Filings history section', () => {
it('Verifies filing history is displayed, and it shows data', () => {
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, undefined, allFilings)
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, false, undefined, allFilings)

cy.get('[data-cy="filingHistoryItem-header"]').should('have.length', allFilings.length)

Expand All @@ -16,7 +16,7 @@ context('Filings history section', () => {
it('Verifies body of the filings -- document list, court number', () => {
// director change verification aka, verify body list
const filings = [directorChange, administrativeDissolution]
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, undefined, filings)
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, false, undefined, filings)

cy.fixture('filings/directorChange/documentList.json').then((response) => {
cy.intercept(
Expand Down Expand Up @@ -82,7 +82,7 @@ context('Filings history section', () => {
'GET',
`**/api/v2/businesses/**/filings/${directorChange.filingId}/comments`,
response).as('detailsList')
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, undefined, filings)
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, false, undefined, filings)

cy.get('[data-cy="details-list"]').should('not.exist')

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/components/todos/annual-report-filing.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
context('TODOs -> Annual Report Todo Task', () => {
it('Annual report filing to-do item is rendered and working as expected', () => {
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, 'taskAR.json')
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, false, 'taskAR.json')

cy.fixture('todos/taskAR.json').then((afrMockResponse) => {
cy.get('[data-cy="header_todo"]')
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/components/todos/conversion-filing.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
context('TODOs -> Conversion todo task and filing task', () => {
it('Conversion todo item is rendered for staff account', () => {
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, 'taskConversion.json', [], true)
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, false, 'taskConversion.json', [], true)

// todo section header should exist and show the correct count
cy.get('[data-cy="header_todo"]')
Expand Down Expand Up @@ -51,7 +51,7 @@ context('TODOs -> Conversion todo task and filing task', () => {
})

it('Non-staff account cannot see the conversion todo item', () => {
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, 'taskConversion.json', false)
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, false, 'taskConversion.json', false)

cy.get('[data-cy="header_todo"]').should('exist').contains('To Do (0)')
cy.get('[data-cy="todoItemList"]').should('exist').within(() => {
Expand Down
43 changes: 38 additions & 5 deletions cypress/e2e/components/todos/draft.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
context('TODOs -> Draft Filing', () => {
it('Test draft filing to-do item - base case (draft with no error)', () => {
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, 'draft/changeOfRegistration.json')
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, false, 'draft/changeOfRegistration.json')

cy.get('[data-cy="header_todo"]').should('exist')
cy.get('[data-cy="todoItemList"]').should('exist')
Expand All @@ -11,15 +11,48 @@ context('TODOs -> Draft Filing', () => {
// View More button should not exist
cy.get('[data-cy^="todoItem-showMore-"]').should('not.exist')

cy.get('[data-cy^="todoItemActions-"]').should('exist').as('actionSection')

// The action button should exist
cy.get('[data-cy^="todoItemActions-"]')
cy.get('@actionSection')
.find('button')
.should('exist')
.should('have.text', 'Resume')

// The dropdown menu should exist
cy.get('@actionSection')
.find('[data-cy="popover-button"]')
.should('exist')
.click() // open the dropdown menu

// The 'Delete draft' button should exist in the dropdown menu
// click the button to open the dialog
cy.get('@actionSection')
.find('[data-cy="menu-button-0"]')
.should('exist')
.should('have.text', 'Delete draft')
.click()
.get('[data-cy="bcros-dialog-confirm"]').should('exist').as('dialog')

// verify the dialog content
// click the cancel button to close the dialog
cy.get('@dialog').find('h1').should('have.text', 'Delete Draft?')
cy.get('@dialog')
.find('[data-cy="bcros-dialog-text"]')
.find('p')
.should('have.text', 'Delete your Change of Registration? Any changes you\'ve made will be lost.')
cy.get('@dialog')
.find('[data-cy="bcros-dialog-btn"]').should('have.length', 2)
.eq(0).should('have.text', 'Delete')
cy.get('@dialog')
.find('[data-cy="bcros-dialog-btn"]')
.eq(1).should('have.text', 'Cancel')
.click()
.get('[data-cy="bcros-dialog"]').should('not.exist')
})

it('Test draft filing to-do item - Incomplete payment', () => {
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, 'draft/incompletePayment.json')
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, false, 'draft/incompletePayment.json')

cy.get('[data-cy="header_todo"]').should('exist')
cy.get('[data-cy="todoItemList"]').should('exist')
Expand All @@ -46,7 +79,7 @@ context('TODOs -> Draft Filing', () => {

it('Conversion filing draft is visible for both staff account', () => {
// load the conversion filing draft with a staff account
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, 'draft/conversion.json', [], true)
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, false, 'draft/conversion.json', [], true)

// A staff user can see the conversion filing draft
cy.get('[data-cy="header_todo"]').should('exist')
Expand All @@ -62,7 +95,7 @@ context('TODOs -> Draft Filing', () => {

it('Conversion filing draft is visible for both staff account but the action button is hidden', () => {
// load the conversion filing draft with a staff account
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, 'draft/conversion.json')
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, false, 'draft/conversion.json')

// A non-staff user can see the conversion filing draft, but the action button is hidden
cy.get('[data-cy="header_todo"]').should('exist')
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/components/todos/error.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
context('TODOs -> Error Filing', () => {
it('Test error filing to-do item', () => {
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, 'error.json')
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, false, 'error.json')

cy.get('[data-cy="header_todo"]').should('exist')
cy.get('[data-cy="todoItemList"]').should('exist')
Expand Down
38 changes: 33 additions & 5 deletions cypress/e2e/components/todos/pending.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
context('TODOs -> Pending Filing', () => {
it('Test pending filing to-do item - pending payment', () => {
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, 'pendingPayment.json')
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, false, 'pendingPayment.json')

cy.get('[data-cy="header_todo"]').should('exist')
cy.get('[data-cy="todoItemList"]').should('exist')
Expand All @@ -15,15 +15,43 @@ context('TODOs -> Pending Filing', () => {
cy.get('[data-cy^="todoItem-showMore-"]').click()
cy.get('[data-cy="todoItem-content"]').should('exist').contains('Payment Incomplete')

cy.get('[data-cy^="todoItemActions-"]').should('exist').as('actionSection')

// The action button and dropdown menu should exist
cy.get('[data-cy^="todoItemActions-"]')
cy.get('@actionSection')
.find('button')
.should('exist')
.should('have.text', 'Resume Payment')
cy.get('[data-cy="popover-button"]').should('exist')
cy.get('[data-cy="popover-button"]').click()
cy.get('[data-cy="menu-button-0"]')

// The dropdown menu should exist
cy.get('@actionSection')
.find('[data-cy="popover-button"]')
.should('exist')
.click() // open the dropdown menu

// The 'Cancel Payment' button should exist in the dropdown menu
// click the button to open the dialog
cy.get('@actionSection')
.find('[data-cy="menu-button-0"]')
.should('exist')
.should('have.text', 'Cancel Payment')
.click()
.get('[data-cy="bcros-dialog-confirm"]').should('exist').as('dialog')

// verify the dialog content
// click the "Don't Cancel" button to close the dialog
cy.get('@dialog').find('h1').should('have.text', 'Cancel Payment?')
cy.get('@dialog')
.find('[data-cy="bcros-dialog-text"]')
.find('p')
.should('have.text', 'Cancel payment for your 2024 Annual Report?')
cy.get('@dialog')
.find('[data-cy="bcros-dialog-btn"]').should('have.length', 2)
.eq(0).should('have.text', 'Cancel Payment')
cy.get('@dialog')
.find('[data-cy="bcros-dialog-btn"]')
.eq(1).should('have.text', 'Don\'t Cancel')
.click()
.get('[data-cy="bcros-dialog"]').should('not.exist')
})
})
54 changes: 54 additions & 0 deletions cypress/e2e/error-flows/todo-errors/affiliation-error.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
context('Error flows in To-Do section -> Affiliation Requests', () => {
it('Error fetching affiliation requests', () => {
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, false, true)

cy.get('[data-cy="bcros-dialog-loadAffiliationError"]').should('exist').as('dialog')
cy.get('@dialog').find('h1').should('have.text', 'Error fetching affiliation invitation.')
cy.get('@dialog')
.find('[data-cy="bcros-dialog-text"]')
.find('p').eq(0)
.should('have.text', 'An error happened while fetching affiliation invitation.')
cy.get('@dialog')
.find('[data-cy="bcros-dialog-text"]')
.find('p').eq(1)
.should('have.text', 'Please try again later.')
cy.get('@dialog')
.find('[data-cy="bcros-dialog-btn"]')
.should('have.text', 'OK')
.click()
.get('[data-cy="bcros-dialog"]').should('not.exist')
})

it('Error authorizing affiliation requests', () => {
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, true, false)

cy.intercept(
'PATCH',
'**/api/v1/affiliationInvitations/**/authorization/accept',
{ statusCode: 500, body: { message: 'error accepting the affiliation request' } }
).as('acceptAffiliationRequest')

cy.get('[data-cy="todoItemActions-affiliation"]')
.find('button').eq(1)
.should('have.text', 'Authorize')
.click()

cy.wait('@acceptAffiliationRequest').its('response.statusCode').should('equal', 500)

cy.get('[data-cy="bcros-dialog-authorizeAffiliationError"]').should('exist').as('dialog')
cy.get('@dialog').find('h1').should('have.text', 'Error updating affiliation invitation.')
cy.get('@dialog')
.find('[data-cy="bcros-dialog-text"]')
.find('p').eq(0)
.should('have.text', 'An error happened while updating affiliation invitation.')
cy.get('@dialog')
.find('[data-cy="bcros-dialog-text"]')
.find('p').eq(1)
.should('have.text', 'Please try again later.')
cy.get('@dialog')
.find('[data-cy="bcros-dialog-btn"]')
.should('have.text', 'OK')
.click()
.get('[data-cy="bcros-dialog"]').should('not.exist')
})
})
41 changes: 26 additions & 15 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,30 @@ Cypress.Commands.add('interceptBusinessContact', (identifier, legalType) => {
})
})

Cypress.Commands.add('interceptAffiliationRequests', (hasAffiliationInvitations = false) => {
if (hasAffiliationInvitations) {
cy.fixture('todos/affiliationRequests').then((affiliationResponse) => {
Cypress.Commands.add('interceptAffiliationRequests',
(hasAffiliationInvitations = false, hasAffiliationInvitationError = false) => {
if (hasAffiliationInvitations) {
cy.fixture('todos/affiliationRequests').then((affiliationResponse) => {
cy.intercept(
'GET',
'**/api/v1/affiliationInvitations?**',
affiliationResponse
)
})
} else if (hasAffiliationInvitationError) {
cy.intercept(
'GET',
'**/api/v1/affiliationInvitations?**',
affiliationResponse
{ statusCode: 500, body: { message: 'error loading affiliation requests' } }
)
})
} else {
cy.intercept(
'GET',
'**/api/v1/affiliationInvitations?**',
{ affiliationInvitations: [] }
)
}
})
} else {
cy.intercept(
'GET',
'**/api/v1/affiliationInvitations?**',
{ affiliationInvitations: [] }
)
}
})

Cypress.Commands.add('interceptAddresses', (legalType) => {
let addressFixture = 'addressBEN'
Expand Down Expand Up @@ -126,6 +133,7 @@ Cypress.Commands.add('visitBusinessDash',
legalType = 'BEN',
isHistorical = false,
hasAffiliationInvitations = false,
hasAffiliationInvitationError = false,
taskFixture = 'tasksEmpty.json'
) => {
sessionStorage.setItem('FAKE_CYPRESS_LOGIN', 'true')
Expand All @@ -140,7 +148,8 @@ Cypress.Commands.add('visitBusinessDash',
cy.interceptBusinessInfo(identifier, legalType, isHistorical).as('getBusinessInfo')
cy.interceptAddresses(legalType).as('getAddresses')
cy.interceptParties(legalType, isHistorical).as('getParties')
cy.interceptAffiliationRequests(hasAffiliationInvitations).as('getAffiliationRequests')
cy.interceptAffiliationRequests(
hasAffiliationInvitations, hasAffiliationInvitationError).as('getAffiliationRequests')
cy.interceptTasks(taskFixture).as('getTasks')

cy.visit(`/${identifier}`)
Expand All @@ -163,6 +172,7 @@ Cypress.Commands.add('visitBusinessDashFor',
path: string,
identifier = undefined,
hasAffiliationInvitations = false,
hasAffiliationInvitationError = false,
taskFixture = 'tasksEmpty.json',
filings = [],
asStaff = false
Expand Down Expand Up @@ -197,7 +207,8 @@ Cypress.Commands.add('visitBusinessDashFor',
cy.interceptBusinessContact(business.identifier, 'BEN').as('getBusinessContact')
cy.interceptAddresses(business.legalType).as('getAddresses')
cy.interceptParties(business.legalType, business.state === BusinessStateE.HISTORICAL).as('getParties')
cy.interceptAffiliationRequests(hasAffiliationInvitations).as('getAffiliationRequests')
cy.interceptAffiliationRequests(
hasAffiliationInvitations, hasAffiliationInvitationError).as('getAffiliationRequests')
cy.interceptTasks(taskFixture).as('getTasks')
cy.interceptFilingHistory(business.identifier, filings).as('getFilingHistory')

Expand Down
5 changes: 3 additions & 2 deletions src/components/bcros/dialog/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<UModal
:attach="attach || ''"
:model-value="display"
data-cy="bcros-dialog"
:data-cy="'bcros-dialog' + (name ? `-${name}` : '')"
>
<div v-if="options" class="px-10 py-9">
<div class="flex">
Expand Down Expand Up @@ -33,7 +33,7 @@
<div class="pt-7">
<!-- can be replaced with <template v-slot:buttons> -->
<slot name="buttons" :options="options">
<div class="flex justify-center">
<div class="flex justify-center gap-5">
<div v-for="button, i in options.buttons" :key="'dialog-btn-' + i">
<slot :name="'dialog-btn-slot-' + button.slotId">
<dialog-button :button="button" data-cy="bcros-dialog-btn" @close="emit('close')" />
Expand All @@ -50,6 +50,7 @@
import { DialogButton, DialogContent } from './slot-templates'

const props = defineProps<{
name?: string,
attach?: string,
display: boolean,
options?: DialogOptionsI
Expand Down
Loading
Loading