Skip to content

Commit

Permalink
21349 - Todo section & affiliation invitations. (#15)
Browse files Browse the repository at this point in the history
* 21349 - Todo section & affiliation invitations.

* 21349 - Eslint fixes and c&p cleanup.

* 21349 - Adding the tests.

* eslint fix.
  • Loading branch information
hfekete authored Jul 10, 2024
1 parent 2602e86 commit 5d11c03
Show file tree
Hide file tree
Showing 20 changed files with 628 additions and 55 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ dist
# Node dependencies
node_modules

# cypress
cypress/screenshots

# Logs
logs
*.log
Expand Down
38 changes: 38 additions & 0 deletions cypress/e2e/components/todos/affiliation-requests.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
context('TODOs -> Affiliation Requests', () => {
it('Tood section is rendered when there are affiliation requests', () => {
cy.visitBusinessDashFor('businessInfo/ben/active.json', undefined, true)

cy.fixture('todos/affiliationRequests.json').then((afrMockResponse) => {
// section exists
cy.get('[data-cy="header_todo"]').should('exist')

// item list exist
cy.get('[data-cy="todoItemList"]').should('exist')

// verify affiliation items exist
cy.get('[data-cy="todoItem-affiliation"]')
.should('have.length', afrMockResponse.affiliationInvitations.length)

// verify buttons are here
cy.get('[data-cy="todoItem-affiliation-showMore"]')
.should('have.length', afrMockResponse.affiliationInvitations.length)
cy.get('[data-cy="todoItem-affiliation-doNotAuthorizeButton"]')
.should('have.length', afrMockResponse.affiliationInvitations.length)
cy.get('[data-cy="todoItem-affiliation-authorizeButton"]')
.should('have.length', afrMockResponse.affiliationInvitations.length)

// no body of todo item expanded
cy.get('[data-cy="todoItemBody-affiliation"]').should('not.exist')
cy.get('Hide details').should('not.exist')

cy.get('[data-cy="todoItem-affiliation-showMore"]').first().click()

cy.get('[data-cy="todoItemBody-affiliation"]').should('exist')

// no body of todo item hidden
cy.get('[data-cy="todoItem-affiliation-showMore"]').first().click()

cy.get('[data-cy="todoItemBody-affiliation"]').should('not.exist')
})
})
})
48 changes: 48 additions & 0 deletions cypress/fixtures/todos/affiliationRequests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"affiliationInvitations": [
{
"additionalMessage": "",
"businessIdentifier": "BC0814603",
"expiresOn": "2024-07-05T22:19:41+00:00",
"fromOrg": {
"id": 3101,
"name": "Kial Dev 2 (BTR test account)",
"orgType": "PREMIUM"
},
"id": 344,
"isDeleted": false,
"recipientEmail": "[email protected],[email protected],[email protected]",
"sentDate": "2024-07-05T22:04:41+00:00",
"status": "PENDING",
"toOrg": {
"id": 3113,
"name": "Kial Dev 1 (BTR test account)",
"orgType": "PREMIUM"
},
"token": ".eJyrVspMUbIyNjHRUUorys_1L0r3BPENDQx1lEry4VxDYx2lpNLizLzU4mLPlNS8ksy0zNQiJSslJ2cDC0MTMwNjpVoATksWSQ.Zoht-g.NYyfPARLpGSrkdmt1CO5I6L2MTM",
"type": "REQUEST"
},
{
"additionalMessage": "This is additional message, please make sure its seen !!!",
"businessIdentifier": "BC0814603",
"expiresOn": "2024-07-05T22:19:41+00:00",
"fromOrg": {
"id": 3102,
"name": "Kial Dev 3 (BTR test account)",
"orgType": "PREMIUM"
},
"id": 344,
"isDeleted": false,
"recipientEmail": "[email protected],[email protected],[email protected]",
"sentDate": "2024-07-05T22:04:41+00:00",
"status": "PENDING",
"toOrg": {
"id": 3113,
"name": "Kial Dev 1 (BTR test account)",
"orgType": "PREMIUM"
},
"token": ".eJyrVspMUbIyNjHRUUorys_1L0r3BPENDQx1lEry4VxDYx2lpNLizLzU4mLPlNS8ksy0zNQiJSslJ2cDC0MTMwNjpVoATksWSQ.Zoht-g.NYyfPARLpGSrkdmt1CO5I6L2MTM",
"type": "REQUEST"
}
]
}
151 changes: 100 additions & 51 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@ Cypress.Commands.add('interceptBusinessContact', (identifier, legalType) => {
})
})

Cypress.Commands.add('interceptAffiliationRequests', (hasTodos = false) => {
if (hasTodos) {
cy.fixture('todos/affiliationRequests').then((affiliationResponse) => {
cy.intercept(
'GET',
'**/api/v1/affiliationInvitations?**',
affiliationResponse
)
})
} else {
cy.intercept(
'GET',
'**/api/v1/affiliationInvitations?**',
{ affiliationInvitations: [] }
)
}
})

Cypress.Commands.add('interceptAddresses', (legalType) => {
let addressFixture = 'addressBEN'
if (legalType === 'SP' || legalType === 'GP') {
Expand Down Expand Up @@ -70,58 +88,89 @@ Cypress.Commands.add('interceptParties', (legalType, hasCustodian = false) => {
})
})

Cypress.Commands.add('visitBusinessDash', (identifier = 'BC0871427', legalType = 'BEN', isHistorical = false) => {
sessionStorage.setItem('FAKE_CYPRESS_LOGIN', 'true')
cy.intercept('GET', '**/api/v1/users/**/settings', { fixture: 'settings.json' }).as('getSettings')
cy.intercept(
'REPORT',
'https://app.launchdarkly.com/sdk/evalx/**/context',
{ fixture: 'ldarklyContext.json' }
).as('getLdarklyContext')
cy.intercept('GET', '**/api/v1/orgs/**/products*', { fixture: 'products.json' }).as('getProducts')
cy.interceptBusinessContact(identifier, legalType).as('getBusinessContact')
cy.interceptBusinessInfo(identifier, legalType, isHistorical).as('getBusinessInfo')
cy.interceptAddresses(legalType).as('getAddresses')
cy.interceptParties(legalType, isHistorical).as('getParties')

cy.visit(`/${identifier}`)
cy.wait(['@getSettings', '@getProducts', '@getBusinessContact', '@getBusinessInfo', '@getAddresses', '@getParties'])
cy.injectAxe()
})

Cypress.Commands.add('visitBusinessDashFor', (path: string, identifier = undefined) => {
sessionStorage.setItem('FAKE_CYPRESS_LOGIN', 'true')
// settings
cy.intercept('GET', '**/api/v1/users/**/settings', { fixture: 'settings.json' }).as('getSettings')
// login & credentials
cy.intercept(
'REPORT',
'https://app.launchdarkly.com/sdk/evalx/**/context',
{ fixture: 'ldarklyContext.json' }
).as('getLdarklyContext')

// products
cy.intercept('GET', '**/api/v1/orgs/**/products*', { fixture: 'products.json' }).as('getProducts')

// business related info
cy.fixture(path).then((b: { business: BusinessI }) => {
const business = b.business
if (identifier) {
business.identifier = identifier
}

// load interceptors
cy.interceptBusinessInfoFor(business).as('getBusinessInfo')
cy.interceptBusinessContact(business.identifier, 'BEN').as('getBusinessContact')
cy.interceptAddresses(business.legalType).as('getAddresses')
cy.interceptParties(business.legalType, business.state === BusinessStateE.HISTORICAL).as('getParties')

// go !
cy.visit(`/${business.identifier}`)
cy.wait(['@getSettings', '@getProducts', '@getBusinessContact', '@getBusinessInfo', '@getAddresses', '@getParties'])
Cypress.Commands.add('visitBusinessDash',
(
identifier = 'BC0871427',
legalType = 'BEN',
isHistorical = false,
hasAffiliationInvitations = false
) => {
sessionStorage.setItem('FAKE_CYPRESS_LOGIN', 'true')
cy.intercept('GET', '**/api/v1/users/**/settings', { fixture: 'settings.json' }).as('getSettings')
cy.intercept(
'REPORT',
'https://app.launchdarkly.com/sdk/evalx/**/context',
{ fixture: 'ldarklyContext.json' }
).as('getLdarklyContext')
cy.intercept('GET', '**/api/v1/orgs/**/products*', { fixture: 'products.json' }).as('getProducts')
cy.interceptBusinessContact(identifier, legalType).as('getBusinessContact')
cy.interceptBusinessInfo(identifier, legalType, isHistorical).as('getBusinessInfo')
cy.interceptAddresses(legalType).as('getAddresses')
cy.interceptParties(legalType, isHistorical).as('getParties')
cy.interceptAffiliationRequests(hasAffiliationInvitations).as('getAffiliationRequests')

cy.visit(`/${identifier}`)
cy.wait([
'@getSettings',
'@getProducts',
'@getBusinessContact',
'@getBusinessInfo',
'@getAddresses',
'@getParties',
'@getAffiliationRequests'
])
cy.injectAxe()
})
})
}
)

Cypress.Commands.add('visitBusinessDashFor',
(
path: string,
identifier = undefined,
hasAffiliationInvitations = false
) => {
sessionStorage.setItem('FAKE_CYPRESS_LOGIN', 'true')
// settings
cy.intercept('GET', '**/api/v1/users/**/settings', { fixture: 'settings.json' }).as('getSettings')
// login & credentials
cy.intercept(
'REPORT',
'https://app.launchdarkly.com/sdk/evalx/**/context',
{ fixture: 'ldarklyContext.json' }
).as('getLdarklyContext')

// products
cy.intercept('GET', '**/api/v1/orgs/**/products*', { fixture: 'products.json' }).as('getProducts')

// business related info
cy.fixture(path).then((b: { business: BusinessI }) => {
const business = b.business
if (identifier) {
business.identifier = identifier
}

// load interceptors
cy.interceptBusinessInfoFor(business).as('getBusinessInfo')
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')

// go !
cy.visit(`/${business.identifier}`)
cy.wait([
'@getSettings',
'@getProducts',
'@getBusinessContact',
'@getBusinessInfo',
'@getAddresses',
'@getParties',
'@getAffiliationRequests'
])
cy.injectAxe()
})
}
)

Cypress.Commands.add('visitBusinessDashAuthError', (identifier = 'BC0871427', legalType = 'BEN') => {
sessionStorage.setItem('FAKE_CYPRESS_LOGIN', 'true')
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"moment": "^2.30.1",
"nuxt": "^3.11.2",
"sass": "^1.77.3",
"uuid": "^10.0.0",
"vue": "^3.4.27",
"vue-router": "^4.3.2"
},
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/components/bcros/businessDetails/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const route = useRoute()
const t = useNuxtApp().$i18n.t
const business = useBcrosBusiness()
const filings = useBcrosFilings()
const todos = useBcrosTodos()
const { currentBusiness, currentBusinessContact } = storeToRefs(business)
const businessInfo = ref([] as { term: string, value: string }[])
Expand All @@ -59,6 +60,9 @@ async function loadComponentData (identifier: string) {
filings.loading = true
await filings.loadFilings(identifier)
filings.loading = false
todos.loading = true
await todos.loadAffiliations(identifier)
todos.loading = false
}
// watcher required because layouts start rendering before the route is initialized
Expand Down
33 changes: 33 additions & 0 deletions src/components/bcros/todo/Item.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<template>
<BcrosTodoItemsAffiliation
v-if="displayItem===DisplayItem.AffiliationInvitation"
:todo-item="item"
:for-business-name="business.currentBusiness.legalName"
/>

<div v-if="displayItem===DisplayItem.None">
NONE NONE
</div>
</template>

<script setup lang="ts">
import type { TodoItemI } from '~/interfaces/todo-i'
const business = useBcrosBusiness()
const props = defineProps({
item: { type: Object as PropType<TodoItemI>, required: true }
})
enum DisplayItem {
None,
AffiliationInvitation
}
let displayItem = DisplayItem.None
if (props.item.affiliationInvitationDetails) {
displayItem = DisplayItem.AffiliationInvitation
}
</script>
21 changes: 21 additions & 0 deletions src/components/bcros/todo/List.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<div
class="flex flex-col gap-1.5 bg-gray-100"
data-cy="todoItemList"
>
<BcrosTodoItem
v-for="todoItem in todos"
:key="todoItem.uiUuid"
:item="todoItem"
:title="todoItem.title"
/>
</div>
</template>

<script setup lang="ts">
import type { TodoItemI } from '~/interfaces/todo-i'
defineProps({
todos: { type: Array<TodoItemI>, required: true }
})
</script>
Loading

0 comments on commit 5d11c03

Please sign in to comment.