Skip to content

Commit

Permalink
Merge branch 'release-0.2.0' into fix/prashanth-transactions-comments…
Browse files Browse the repository at this point in the history
…-fix-1702
  • Loading branch information
prv-proton authored Jan 16, 2025
2 parents 47192ab + 549996a commit d175ec2
Show file tree
Hide file tree
Showing 33 changed files with 211 additions and 102 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""Update other_uses_fossil_derived in fuel_type
Revision ID: fe03799b4018
Revises: fa98709e7952
Create Date: 2025-01-14 18:12:43.683691
"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "fe03799b4018"
down_revision = "5163af6ba4a4"
branch_labels = None
depends_on = None


def upgrade() -> None:
# Set other_uses_fossil_derived to false
op.execute("""
UPDATE fuel_type
SET other_uses_fossil_derived = false
WHERE fuel_type IN (
'CNG', 'Electricity', 'Hydrogen', 'LNG', 'Propane',
'Natural gas-based gasoline', 'Petroleum-based diesel',
'Petroleum-based gasoline'
)
""")

# Set other_uses_fossil_derived to true
op.execute("""
UPDATE fuel_type
SET other_uses_fossil_derived = true
WHERE fuel_type IN (
'Alternative jet fuel', 'Biodiesel', 'Ethanol', 'HDRD',
'Other diesel fuel', 'Renewable gasoline', 'Renewable naphtha'
)
""")

def downgrade() -> None:
# Revert `other_uses_fossil_derived` to original values for false
op.execute("""
UPDATE fuel_type
SET other_uses_fossil_derived = true
WHERE fuel_type IN (
'CNG', 'Electricity', 'Hydrogen', 'LNG', 'Propane',
'Natural gas-based gasoline', 'Petroleum-based diesel',
'Petroleum-based gasoline'
)
""")

# Revert `other_uses_fossil_derived` to original values for true
op.execute("""
UPDATE fuel_type
SET other_uses_fossil_derived = false
WHERE fuel_type IN (
'Alternative jet fuel', 'Biodiesel', 'Ethanol', 'HDRD',
'Other diesel fuel', 'Renewable gasoline', 'Renewable naphtha'
)
""")
4 changes: 2 additions & 2 deletions backend/lcfs/services/keycloak/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async def authenticate(self, request):
await self.create_login_history(
user_token, False, error_text
)
raise HTTPException(status_code=401, detail=error_text)
raise HTTPException(status_code=403, detail=error_text)
else:
# Already found by keycloak_user_id => return
return AuthCredentials(["authenticated"]), user
Expand Down Expand Up @@ -204,7 +204,7 @@ async def authenticate(self, request):
if not user.is_active:
error_text = "The account is currently inactive."
await self.create_login_history(user_token, False, error_text)
raise HTTPException(status_code=401, detail=error_text)
raise HTTPException(status_code=403, detail=error_text)
else:
error_text = "preferred_username or email is required in JWT payload."
raise HTTPException(status_code=401, detail=error_text)
Expand Down
1 change: 1 addition & 0 deletions backend/lcfs/web/api/other_uses/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ async def get_formatted_fuel_types(
joinedload(FuelType.provision_1),
joinedload(FuelType.provision_2),
)
.order_by(FuelType.fuel_type)
)

result = await self.db.execute(query)
Expand Down
1 change: 0 additions & 1 deletion etl/nifi_scripts/organization.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def sourceQuery = """
coalesce(o.edrms_record, '') as edrms_record,
(
case
when os.status = 'Archived' then 'Suspended'
when oat.the_type = 'Buy And Sell' or oat.the_type = 'Sell Only' then 'Registered'
else 'Unregistered'
end
Expand Down
13 changes: 13 additions & 0 deletions frontend/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ export default defineConfig({
})
)

on('task', {
log(message) {
console.log(message)

return null
},
table(message) {
console.table(message)

return null
}
})

return config
}
}
Expand Down
5 changes: 3 additions & 2 deletions frontend/cypress/e2e/Pages/Transaction/Transaction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ When('the analyst starts a new initiative agreement transaction', () => {

When(
'the analyst enters {string} units to organization {string} with effective date {string} and comment {string}',
(units, orgId, effetiveDate, comment) => {
(units, orgId, effectiveDate, comment) => {
cy.get('#to-organization-id').click()
cy.get(`[data-value="${orgId}"]`).click()
cy.get('input[name="complianceUnits"]').type(units)
cy.get('input[name="transactionEffectiveDate"]').type(effetiveDate)
cy.get('input[name="transactionEffectiveDate"]').type(effectiveDate)
cy.get(':nth-child(2) > :nth-child(5)').click()
cy.get('textarea[name="govComment"]').type(comment)
}
)
Expand Down
10 changes: 8 additions & 2 deletions frontend/cypress/e2e/Pages/Transfer/Transfer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ When(
(qty, orgId, pricePerUnit, agreementDate) => {
cy.get('a[href="/transactions"]').click()
cy.get('#new-transfer-button').click()
cy.get("[data-testid='quantity']").type(qty)
cy.get("[data-test='quantity']").type(qty)
cy.get('#to-organization-id').click()
cy.get(`[data-value="${orgId}"]`).click()
cy.get('#price-per-unit').type(pricePerUnit)
Expand Down Expand Up @@ -175,7 +175,10 @@ When('I login as analyst and recommend', () => {
Cypress.env(`admin_idir_username`),
Cypress.env(`admin_idir_password`)
)

cy.wait(5000)
cy.setIDIRRoles('analyst')
cy.visit('/')
cy.getByDataTest('dashboard-container').should('exist')

cy.get('a[href="/transactions"]').click()
Expand Down Expand Up @@ -205,8 +208,9 @@ When('I login as director and records transfer', () => {
Cypress.env(`admin_idir_password`)
)
cy.wait(5000)
cy.setIDIRRoles('director')
cy.visit('/')
cy.getByDataTest('dashboard-container').should('exist')

cy.get('a[href="/transactions"]').click()
cy.wait(5000)
cy.get('div[row-index="0"]').click()
Expand All @@ -232,6 +236,8 @@ When('I login as director and refuse transfer', () => {
Cypress.env(`admin_idir_password`)
)
cy.wait(5000)
cy.setIDIRRoles('director')
cy.visit('/')
cy.getByDataTest('dashboard-container').should('exist')

cy.get('a[href="/transactions"]').click()
Expand Down
17 changes: 13 additions & 4 deletions frontend/cypress/e2e/accessibility.cy.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,40 @@
// npm run cypress:run -- --spec cypress/e2e/accessibility.cy.js

import { terminalLog } from '../support/e2e.js'

describe('Accessibility Tests for LCFS', () => {
// Test for Login Page Accessibility
describe('Login page accessibility', () => {
beforeEach(() => {
cy.visit('/login')
cy.injectAxe() // Injects the axe-core library
})

it('Should have no accessibility violations on load', () => {
cy.checkA11y()
cy.loginWith(
'idir',
Cypress.env('IDIR_TEST_USER'),
Cypress.env('IDIR_TEST_PASS')
)
cy.wait(5000)
cy.injectAxe() // Injects the axe-core library
cy.checkA11y(null, null, terminalLog)
})
})

// Test for Navigation Accessibility
describe('Navigation Accessibility', () => {
it('Should have no accessibility violations in the navigation bar', () => {
cy.visit('/')
cy.injectAxe()
cy.loginWith(
'idir',
Cypress.env('IDIR_TEST_USER'),
Cypress.env('IDIR_TEST_PASS')
)
cy.wait(5000)
cy.injectAxe() // Injects the axe-core library
cy.getByDataTest('bc-navbar').should('exist')
cy.getByDataTest('bc-navbar').within(() => {
cy.checkA11y()
cy.checkA11y(null, null, terminalLog)
})
})
})
Expand Down
32 changes: 0 additions & 32 deletions frontend/cypress/e2e/contact_us.cy.js

This file was deleted.

2 changes: 1 addition & 1 deletion frontend/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Cypress.Commands.add('setIDIRRoles', (role) => {
cy.url().should('match', /\/admin\/users\/\d+/)

// click edit button
cy.get('button[aria-label="edit"]').click()
cy.get('#edit-user-button').click()

// Ensure the URL has changed to the user edit page
cy.url().should('include', '/edit-user')
Expand Down
22 changes: 19 additions & 3 deletions frontend/cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,25 @@
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import 'cypress-axe'
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
export const terminalLog = (violations) => {
cy.task(
'log',
`${violations.length} accessibility violation${
violations.length === 1 ? '' : 's'
} ${violations.length === 1 ? 'was' : 'were'} detected`
)
// pluck specific keys to keep the table readable
const violationData = violations.map(
({ id, impact, description, nodes }) => ({
id,
impact,
description,
nodes: nodes.length
})
)

cy.task('table', violationData)
}
2 changes: 1 addition & 1 deletion frontend/src/components/BCDataGrid/BCDataGridServer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ const BCDataGridServer = ({
setPage(1)
setSize(paginationPageSize)
setSortModel(defaultSortModel || [])
setFilterModel(defaultFilterModel || [])
setFilterModel([])

// Clear UI filters
if (gridRef.current?.api) {
Expand Down
6 changes: 2 additions & 4 deletions frontend/src/components/BCDataGrid/BCGridViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const BCGridViewer = ({
setPage(1)
setSize(paginationPageSize)
setSortModel(defaultSortModel || [])
setFilterModel(defaultFilterModel || [])
setFilterModel([])

// Clear UI filters
if (ref.current?.api) {
Expand Down Expand Up @@ -122,13 +122,11 @@ export const BCGridViewer = ({
ref
])


useEffect(() => {
if (onSetResetGrid) {
onSetResetGrid(resetGrid)
}
}, [onSetResetGrid, resetGrid])

}, [onSetResetGrid])

const onFirstDataRendered = useCallback((params) => {
params.api.hideOverlay()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const AutocompleteCellEditor = forwardRef((props, ref) => {
}
})

const [isOpen, setIsOpen] = useState(false)
const inputRef = useRef()

useImperativeHandle(ref, () => ({
Expand All @@ -71,32 +72,40 @@ export const AutocompleteCellEditor = forwardRef((props, ref) => {
onValueChange(newValue)
}

const navigateToNextCell = () => {
const focusedCell = api.getFocusedCell()
if (focusedCell) {
api.startEditingCell({
rowIndex: focusedCell.rowIndex,
colKey: focusedCell.column.getId()
})
}
}

const handleKeyDown = (event) => {
if (onKeyDownCapture) {
onKeyDownCapture(event)
} else if (event.key === 'Tab') {
onValueChange(selectedValues)
}

// Handle Enter key to toggle dropdown
if (event.key === 'Enter') {
event.preventDefault()
api.stopEditing()
setIsOpen(!isOpen)
return
}

const navigateToNextCell = () => {
const focusedCell = api.getFocusedCell()
if (focusedCell) {
api.startEditingCell({
rowIndex: focusedCell.rowIndex,
colKey: focusedCell.column.getId()
})
}
}
// Handle Tab key navigation - directly move to next/previous cell
if (event.key === 'Tab') {
event.preventDefault()
onValueChange(selectedValues)
api.stopEditing()

if (event.shiftKey) {
// Shift + Tab: Move to the previous cell
api.tabToPreviousCell()
setTimeout(navigateToNextCell, 0) // Ensure editing starts after navigation
setTimeout(navigateToNextCell, 0)
} else {
// Tab: Move to the next cell
api.tabToNextCell()
setTimeout(navigateToNextCell, 0) // Ensure editing starts after navigation
setTimeout(navigateToNextCell, 0)
}
}
}
Expand Down Expand Up @@ -125,6 +134,9 @@ export const AutocompleteCellEditor = forwardRef((props, ref) => {
padding: '2px 0px 2px 0px'
}
}}
open={isOpen}
onOpen={() => setIsOpen(true)}
onClose={() => setIsOpen(false)}
openOnFocus={openOnFocus}
value={selectedValues}
onInputChange={freeSolo ? handleChange : null}
Expand Down
Loading

0 comments on commit d175ec2

Please sign in to comment.