From 9b208f145342187a047fdd6f73c62c9d55c167bb Mon Sep 17 00:00:00 2001 From: Alex Zorkin Date: Tue, 17 Dec 2024 18:01:30 -0800 Subject: [PATCH 1/6] fix: removed continue on error so if tests fail the check fails --- .github/workflows/docker-auto-test.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/docker-auto-test.yaml b/.github/workflows/docker-auto-test.yaml index 837d2d171..70ee4fe57 100644 --- a/.github/workflows/docker-auto-test.yaml +++ b/.github/workflows/docker-auto-test.yaml @@ -53,7 +53,6 @@ jobs: - name: Run backend tests id: backend_tests - continue-on-error: true run: | cd backend poetry run pytest --junitxml=pytest-results.xml @@ -124,7 +123,6 @@ jobs: - name: Run frontend tests id: frontend_tests - continue-on-error: true run: | cd frontend npm run test:run -- --reporter=junit --outputFile=vitest-results.xml @@ -148,4 +146,4 @@ jobs: check_name: "Frontend Test Results" fail_on: "errors" report_individual_runs: "true" - deduplicate_classes_by_file_name: "true" \ No newline at end of file + deduplicate_classes_by_file_name: "true" From 4dd57f4d0a310338d83b40ddfb31329cfb15531a Mon Sep 17 00:00:00 2001 From: Kevin Hashimoto Date: Tue, 17 Dec 2024 16:32:07 -0800 Subject: [PATCH 2/6] feat: clear alert on action --- frontend/src/components/BCAlert/BCAlert2.jsx | 3 ++ .../components/BCDataGrid/BCGridEditor.jsx | 40 +++++++++++++++++++ .../FuelSupplies/AddEditFuelSupplies.jsx | 30 ++++++++------ 3 files changed, 61 insertions(+), 12 deletions(-) diff --git a/frontend/src/components/BCAlert/BCAlert2.jsx b/frontend/src/components/BCAlert/BCAlert2.jsx index e7b1d684d..fd92913ab 100644 --- a/frontend/src/components/BCAlert/BCAlert2.jsx +++ b/frontend/src/components/BCAlert/BCAlert2.jsx @@ -70,6 +70,9 @@ export const BCAlert2 = forwardRef( setSeverity(severity) setMessage(message) setTriggerCount((prevCount) => prevCount + 1) + }, + clearAlert: () => { + setAlertStatus('fadeOut') } })) diff --git a/frontend/src/components/BCDataGrid/BCGridEditor.jsx b/frontend/src/components/BCDataGrid/BCGridEditor.jsx index 03c9b4649..2c54f7183 100644 --- a/frontend/src/components/BCDataGrid/BCGridEditor.jsx +++ b/frontend/src/components/BCDataGrid/BCGridEditor.jsx @@ -181,6 +181,7 @@ export const BCGridEditor = ({ params.event.target.dataset.action && onAction ) { +<<<<<<< HEAD const action = params.event.target.dataset.action const transaction = await onAction(action, params) @@ -193,6 +194,17 @@ export const BCGridEditor = ({ const firstNewRow = res.add[0] startEditingFirstEditableCell(firstNewRow.rowIndex) } +======= + alertRef.current.clearAlert() + const transaction = await onAction( + params.event.target.dataset.action, + params + ) + // Focus and edit the first editable column of the duplicated row + if (transaction?.add.length > 0) { + const duplicatedRowNode = transaction.add[0] + startEditingFirstEditableCell(duplicatedRowNode.rowIndex) +>>>>>>> ce726f71 (feat: clear alert on action) } } } @@ -205,6 +217,7 @@ export const BCGridEditor = ({ setAnchorEl(null) } +<<<<<<< HEAD const handleAddRowsInternal = useCallback( async (numRows) => { let newRows = [] @@ -243,6 +256,33 @@ export const BCGridEditor = ({ setAnchorEl(null) }, [onAction, startEditingFirstEditableCell] +======= + const handleAddRows = useCallback( + (numRows) => { + alertRef.current.clearAlert() + let newRows = [] + if (props.onAddRows) { + newRows = props.onAddRows(numRows) + } else { + newRows = Array(numRows) + .fill() + .map(() => ({ id: uuid() })) + } + + // Add the new rows + ref.current.api.applyTransaction({ + add: newRows, + addIndex: ref.current.api.getDisplayedRowCount() + }) + + // Focus and start editing the first new row + const firstNewRowIndex = ref.current.api.getDisplayedRowCount() - numRows + startEditingFirstEditableCell(firstNewRowIndex) + + setAnchorEl(null) + }, + [props.onAddRows, startEditingFirstEditableCell] +>>>>>>> ce726f71 (feat: clear alert on action) ) const isGridValid = () => { diff --git a/frontend/src/views/FuelSupplies/AddEditFuelSupplies.jsx b/frontend/src/views/FuelSupplies/AddEditFuelSupplies.jsx index 4badf3167..9d3ae3134 100644 --- a/frontend/src/views/FuelSupplies/AddEditFuelSupplies.jsx +++ b/frontend/src/views/FuelSupplies/AddEditFuelSupplies.jsx @@ -64,24 +64,30 @@ export const AddEditFuelSupplies = () => { severity: location.state.severity || 'info' }) } - }, [location?.state?.message, location?.state?.severity]); + }, [location?.state?.message, location?.state?.severity]) - const validate = (params, validationFn, errorMessage, alertRef, field = null) => { - const value = field ? params.node?.data[field] : params; + const validate = ( + params, + validationFn, + errorMessage, + alertRef, + field = null + ) => { + const value = field ? params.node?.data[field] : params if (field && params.colDef.field !== field) { - return true; + return true } if (!validationFn(value)) { alertRef.current?.triggerAlert({ message: errorMessage, - severity: 'error', - }); - return false; + severity: 'error' + }) + return false } - return true; // Proceed with the update - }; + return true // Proceed with the update + } const onGridReady = useCallback( async (params) => { @@ -172,12 +178,12 @@ export const AddEditFuelSupplies = () => { const isValid = validate( params, (value) => { - return value !== null && !isNaN(value) && value > 0; + return value !== null && !isNaN(value) && value > 0 }, 'Quantity supplied must be greater than 0.', alertRef, - 'quantity', - ); + 'quantity' + ) if (!isValid) { return From db47165ef97446ee41742481a70f51c0b6d2eaa7 Mon Sep 17 00:00:00 2001 From: Kevin Hashimoto Date: Tue, 17 Dec 2024 17:52:02 -0800 Subject: [PATCH 3/6] feat: nested links --- .../components/ActivityLinkList.jsx | 118 ++++++++++++------ 1 file changed, 78 insertions(+), 40 deletions(-) diff --git a/frontend/src/views/ComplianceReports/components/ActivityLinkList.jsx b/frontend/src/views/ComplianceReports/components/ActivityLinkList.jsx index c968f8e4a..dc525b791 100644 --- a/frontend/src/views/ComplianceReports/components/ActivityLinkList.jsx +++ b/frontend/src/views/ComplianceReports/components/ActivityLinkList.jsx @@ -22,30 +22,33 @@ export const ActivityLinksList = () => { compliancePeriod ).replace(':complianceReportId', complianceReportId) ) - } - }, - { - name: t('report:activityLists.finalSupplyEquipment'), - action: () => { - navigate( - ROUTES.REPORTS_ADD_FINAL_SUPPLY_EQUIPMENTS.replace( - ':compliancePeriod', - compliancePeriod - ).replace(':complianceReportId', complianceReportId) - ) - } - }, - { - name: t('report:activityLists.allocationAgreements'), - action: () => { - navigate( - ROUTES.REPORTS_ADD_ALLOCATION_AGREEMENTS.replace( - ':compliancePeriod', - compliancePeriod - ).replace(':complianceReportId', complianceReportId) - ) - } + }, + children: [ + { + name: t('report:activityLists.finalSupplyEquipment'), + action: () => { + navigate( + ROUTES.REPORTS_ADD_FINAL_SUPPLY_EQUIPMENTS.replace( + ':compliancePeriod', + compliancePeriod + ).replace(':complianceReportId', complianceReportId) + ) + } + }, + { + name: t('report:activityLists.allocationAgreements'), + action: () => { + navigate( + ROUTES.REPORTS_ADD_ALLOCATION_AGREEMENTS.replace( + ':compliancePeriod', + compliancePeriod + ).replace(':complianceReportId', complianceReportId) + ) + } + } + ] }, + { name: t('report:activityLists.notionalTransfers'), action: () => { @@ -89,24 +92,59 @@ export const ActivityLinksList = () => { sx={{ maxWidth: '100%', listStyleType: 'disc' }} > {activityList.map((activity, index) => ( - - + - {activity.name} - - + + {activity.name} + + + {activity.children && ( + + {activity.children.map((activity, index) => ( + + + {activity.name} + + + ))} + + )} + ))} ) From 6deb4948104e18753fd4ad1dc6702ff6827534dc Mon Sep 17 00:00:00 2001 From: Kuan Fan <31664961+kuanfandevops@users.noreply.github.com> Date: Wed, 18 Dec 2024 10:28:23 -0800 Subject: [PATCH 4/6] Add email config for backend test (#1488) --- .github/workflows/test-ci.yaml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-ci.yaml b/.github/workflows/test-ci.yaml index 80d6690f2..f7643604b 100644 --- a/.github/workflows/test-ci.yaml +++ b/.github/workflows/test-ci.yaml @@ -19,14 +19,11 @@ jobs: outputs: cache-hit: ${{ steps.cache.outputs.cache-hit }} steps: - - name: Check out repository - uses: actions/checkout@v4.1.1 - - name: Set up cache for OpenShift CLI id: cache uses: actions/cache@v4.2.0 with: - path: /usr/local/bin/oc # Path where the `oc` binary will be installed + path: /usr/local/bin/oc # Path where the `oc` binary will be installed key: oc-cli-${{ runner.os }} - name: Install OpenShift CLI (if not cached) @@ -122,6 +119,12 @@ jobs: LCFS_REDIS_PORT: 6379 LCFS_REDIS_PASSWORD: development_only APP_ENVIRONMENT: dev + LCFS_CHES_CLIENT_ID: mock_client_id + LCFS_CHES_CLIENT_SECRET: mock_client_secret + LCFS_CHES_AUTH_URL: http://mock_auth_url + LCFS_CHES_SENDER_EMAIL: noreply@gov.bc.ca + LCFS_CHES_SENDER_NAME: Mock Notification System + LCFS_CHES_EMAIL_URL: http://mock_email_url - name: Run frontend tests id: frontend_tests @@ -189,6 +192,12 @@ jobs: output1: ${{ steps.set-pre-release.outputs.PRE_RELEASE }} steps: + - name: Restore oc command from Cache + uses: actions/cache@v4.2.0 + with: + path: /usr/local/bin/oc + key: oc-cli-${{ runner.os }} + - name: Log in to Openshift uses: redhat-actions/oc-login@v1.3 with: @@ -248,13 +257,17 @@ jobs: PRE_RELEASE: ${{ needs.set-pre-release.outputs.output1 }} steps: + - id: get-current-time + run: | + echo "CURRENT_TIME=$(TZ='America/Vancouver' date '+%Y-%m-%d %H:%M:%S %Z')" >> $GITHUB_OUTPUT + - name: Ask for approval for LCFS release-${{ env.VERSION }} Test deployment uses: trstringer/manual-approval@v1.6.0 with: secret: ${{ github.TOKEN }} approvers: AlexZorkin,kuanfandevops,hamed-valiollahi,airinggov,areyeslo,dhaselhan,Grulin,kevin-hashimoto minimum-approvals: 1 - issue-title: "LCFS ${{ env.VERSION }}-${{ env.PRE_RELEASE }} Test Deployment" + issue-title: "LCFS ${{ env.VERSION }}-${{ env.PRE_RELEASE }} Test Deployment at ${{ steps.get-current-time.outputs.CURRENT_TIME }}" - name: Restore oc command from Cache uses: actions/cache@v4.2.0 From 45a632247bef3c5d4cd423036d006f91f293b83b Mon Sep 17 00:00:00 2001 From: Alex Zorkin Date: Wed, 18 Dec 2024 11:05:04 -0800 Subject: [PATCH 5/6] fix: merge fix --- .../components/BCDataGrid/BCGridEditor.jsx | 40 ------------------- 1 file changed, 40 deletions(-) diff --git a/frontend/src/components/BCDataGrid/BCGridEditor.jsx b/frontend/src/components/BCDataGrid/BCGridEditor.jsx index 2c54f7183..03c9b4649 100644 --- a/frontend/src/components/BCDataGrid/BCGridEditor.jsx +++ b/frontend/src/components/BCDataGrid/BCGridEditor.jsx @@ -181,7 +181,6 @@ export const BCGridEditor = ({ params.event.target.dataset.action && onAction ) { -<<<<<<< HEAD const action = params.event.target.dataset.action const transaction = await onAction(action, params) @@ -194,17 +193,6 @@ export const BCGridEditor = ({ const firstNewRow = res.add[0] startEditingFirstEditableCell(firstNewRow.rowIndex) } -======= - alertRef.current.clearAlert() - const transaction = await onAction( - params.event.target.dataset.action, - params - ) - // Focus and edit the first editable column of the duplicated row - if (transaction?.add.length > 0) { - const duplicatedRowNode = transaction.add[0] - startEditingFirstEditableCell(duplicatedRowNode.rowIndex) ->>>>>>> ce726f71 (feat: clear alert on action) } } } @@ -217,7 +205,6 @@ export const BCGridEditor = ({ setAnchorEl(null) } -<<<<<<< HEAD const handleAddRowsInternal = useCallback( async (numRows) => { let newRows = [] @@ -256,33 +243,6 @@ export const BCGridEditor = ({ setAnchorEl(null) }, [onAction, startEditingFirstEditableCell] -======= - const handleAddRows = useCallback( - (numRows) => { - alertRef.current.clearAlert() - let newRows = [] - if (props.onAddRows) { - newRows = props.onAddRows(numRows) - } else { - newRows = Array(numRows) - .fill() - .map(() => ({ id: uuid() })) - } - - // Add the new rows - ref.current.api.applyTransaction({ - add: newRows, - addIndex: ref.current.api.getDisplayedRowCount() - }) - - // Focus and start editing the first new row - const firstNewRowIndex = ref.current.api.getDisplayedRowCount() - numRows - startEditingFirstEditableCell(firstNewRowIndex) - - setAnchorEl(null) - }, - [props.onAddRows, startEditingFirstEditableCell] ->>>>>>> ce726f71 (feat: clear alert on action) ) const isGridValid = () => { From ffb6a8e3ecd40cd963b1cacd37ace2237b5c6f87 Mon Sep 17 00:00:00 2001 From: Alex Zorkin Date: Wed, 18 Dec 2024 11:32:41 -0800 Subject: [PATCH 6/6] fix: test fix and package lock update --- frontend/package-lock.json | 18 +++++++++++------- .../AddEditAllocationAgreements.test.jsx | 15 ++++++++++++++- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 3fd41e4ec..ab2d9bd6d 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -12207,9 +12207,9 @@ } }, "node_modules/express": { - "version": "4.21.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz", - "integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", + "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", "dev": true, "dependencies": { "accepts": "~1.3.8", @@ -12231,7 +12231,7 @@ "methods": "~1.1.2", "on-finished": "2.4.1", "parseurl": "~1.3.3", - "path-to-regexp": "0.1.10", + "path-to-regexp": "0.1.12", "proxy-addr": "~2.0.7", "qs": "6.13.0", "range-parser": "~1.2.1", @@ -12246,6 +12246,10 @@ }, "engines": { "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/express/node_modules/cookie": { @@ -17129,9 +17133,9 @@ } }, "node_modules/path-to-regexp": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", - "integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==", + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", "dev": true }, "node_modules/path-type": { diff --git a/frontend/src/views/AllocationAgreements/__tests__/AddEditAllocationAgreements.test.jsx b/frontend/src/views/AllocationAgreements/__tests__/AddEditAllocationAgreements.test.jsx index ce7d72113..76c78d006 100644 --- a/frontend/src/views/AllocationAgreements/__tests__/AddEditAllocationAgreements.test.jsx +++ b/frontend/src/views/AllocationAgreements/__tests__/AddEditAllocationAgreements.test.jsx @@ -1,7 +1,7 @@ // src/views/AllocationAgreements/__tests__/AddEditAllocationAgreements.test.jsx import React from 'react' -import { render, screen, fireEvent, waitFor } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { describe, it, expect, beforeEach, vi } from 'vitest' import { AddEditAllocationAgreements } from '../AddEditAllocationAgreements' import * as useAllocationAgreementHook from '@/hooks/useAllocationAgreement' @@ -12,6 +12,19 @@ const mockUseLocation = vi.fn() const mockUseNavigate = vi.fn() const mockUseParams = vi.fn() +vi.mock('@react-keycloak/web', () => ({ + ReactKeycloakProvider: ({ children }) => children, + useKeycloak: () => ({ + keycloak: { + authenticated: true, + login: vi.fn(), + logout: vi.fn(), + register: vi.fn() + }, + initialized: true + }) +})) + vi.mock('react-router-dom', () => ({ ...vi.importActual('react-router-dom'), useLocation: () => mockUseLocation(),