Skip to content

Commit

Permalink
update code with main
Browse files Browse the repository at this point in the history
  • Loading branch information
pmclaren19 committed Feb 28, 2024
2 parents b89ce8d + ff199a7 commit 164dccd
Show file tree
Hide file tree
Showing 509 changed files with 13,009 additions and 4,436 deletions.
17 changes: 6 additions & 11 deletions .github/workflows/continuous-integration.yml
Expand Up @@ -14,14 +14,11 @@ concurrency:
jobs:
build:
name: Build
runs-on: self-hosted
runs-on: ubuntu-16-cores-latest
outputs:
entry_names: ${{ steps.get-changed-apps.outputs.entry_names }}
continuous_deployment: ${{ steps.get-changed-apps.outputs.continuous_deployment }}

env:
NODE_EXTRA_CA_CERTS: /etc/ssl/certs/VA-Internal-S2-RCA1-v1.cer.pem

strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -210,7 +207,7 @@ jobs:
name: Unit Tests
needs: [fetch-allow-lists, unit-tests-prep]
timeout-minutes: 30
runs-on: ubuntu-16-cores-latest
runs-on: ubuntu-latest
outputs:
app_folders: ${{ steps.get-changed-apps.outputs.folders }}
changed-files: ${{ steps.get-changed-apps.outputs.changed_files }}
Expand All @@ -222,8 +219,7 @@ jobs:
fail-fast: false
max-parallel: 72
matrix:
ci_node_index: [mock-form, ezr, post-911-gib-status, appeals, facility-locator, pre-need-integration, ask-a-question, financial-status-report, pre-need, ask-va, auth, avs, gi, hca, rated-disabilities, burial-poc-v6, burials, caregivers, check-in, claims-status, combined-debt-portal, coronavirus-research, coronavirus-screener, debt-letters, dhp-connected-devices, disability-benefits, discharge-wizard, ds-playground, ds-v3-playground, e-folders, edu-benefits, education-letters, enrollment-verification, find-forms, fry-dea, health-care-supply-reordering, income-limits, ivc-champva, letters, lgy, login, medical-copays, messages, mhv-inherited-proofing, mhv-landing-page, mhv, mock-sip-form, my-education-benefits, office-directory, pact-act, pensions, personalization, proxy-rewrite, public-outreach-materials, representative-search, representatives, resources-and-support, sah, search, simple-forms, static-pages, terms-of-use, third-party-app-directory, toe, travel-pay, vaos, verify-your-enrollment, verify, veteran-id-card, virtual-agent, vre, yellow-ribbon]

ci_node_index: [0,1,2,3,4,5,6,7,8,9]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -251,14 +247,14 @@ jobs:
output-type: 'folder'

- name: Run unit tests
run: yarn test:unit --app-folder ${{ matrix.ci_node_index }} ${APP_FOLDERS:+"{script,$APP_FOLDERS}/**/*.unit.spec.js?(x)"} --coverage
run: yarn test:unit ${APP_FOLDERS:+"{script,$APP_FOLDERS}/**/*.unit.spec.js?(x)"} --coverage
env:
MOCHA_FILE: test-results/unit-tests.xml
CHANGED_FILES: ${{ steps.get-changed-apps.outputs.changed_files }}
APP_FOLDERS: ${{ steps.get-changed-apps.outputs.folders }}
STEP: ${{ matrix.ci_node_index }}
IS_STRESS_TEST: false
NUM_CONTAINERS: 72
NUM_CONTAINERS: 10

- name: Archive unit test results
if: ${{ always() }}
Expand Down Expand Up @@ -334,12 +330,11 @@ jobs:

unit-tests-stress-test:
name: Unit Test Stability Review
runs-on: self-hosted
runs-on: ubuntu-latest
needs: [fetch-allow-lists, unit-tests-prep]
if: ${{ always() && needs.unit-tests-prep.outputs.tests-to-stress-test != '[]' && github.ref != 'refs/heads/main' }}

env:
NODE_EXTRA_CA_CERTS: /etc/ssl/certs/VA-Internal-S2-RCA1-v1.cer.pem
TESTS_TO_VERIFY: ${{ needs.unit-tests-prep.outputs.tests-to-stress-test }}
DISALLOWED_TESTS: '[]'

Expand Down
1 change: 0 additions & 1 deletion config/mocha.json
Expand Up @@ -4,7 +4,6 @@
"core-js/stable",
"regenerator-runtime/runtime",
"blob-polyfill",
"choma",
"isomorphic-fetch",
"mocha-snapshots",
"src/platform/testing/unit/mocha-setup.js",
Expand Down
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -150,7 +150,6 @@
"chai-dom": "^1.9.0",
"chalk": "^4.1.2",
"chokidar": "^3.5.2",
"choma": "^1.1.0",
"clear": "^0.1.0",
"cli-spinner": "^0.2.10",
"cli-table": "^0.3.6",
Expand Down Expand Up @@ -318,7 +317,7 @@
"url-search-params-polyfill": "^8.1.1",
"uswds": "1.6.10",
"vanilla-lazyload": "^16.1.0",
"vets-json-schema": "https://github.com/department-of-veterans-affairs/vets-json-schema.git#39dd490a3031bbb28ec30acdb1efa131122a77c8"
"vets-json-schema": "https://github.com/department-of-veterans-affairs/vets-json-schema.git#9e97ed438ab16e131513e7df72712dc91db4e6a3"
},
"resolutions": {
"**/lodash": "4.17.21",
Expand Down
92 changes: 65 additions & 27 deletions script/run-unit-test.js
@@ -1,14 +1,15 @@
/* eslint-disable no-console */
const commandLineArgs = require('command-line-args');
const glob = require('glob');
const path = require('path');
const printUnitTestHelp = require('./run-unit-test-help');
const { runCommand } = require('./utils');
// For usage instructions see https://github.com/department-of-veterans-affairs/vets-website#unit-tests

const specDirs = '{src,script}';
const defaultPath = `./${specDirs}/**/*.unit.spec.js?(x)`;
// const numContainers = process.env.NUM_CONTAINERS || 10;
// const matrixStep = process.env.STEP || 1;
const numContainers = process.env.NUM_CONTAINERS || 1;
const matrixStep = process.env.STEP || 0;

const COMMAND_LINE_OPTIONS_DEFINITIONS = [
{ name: 'log-level', type: String, defaultValue: 'log' },
Expand All @@ -26,16 +27,28 @@ const COMMAND_LINE_OPTIONS_DEFINITIONS = [
defaultValue: [defaultPath],
},
];
const allUnitTests = glob.sync(defaultPath);
const allUnitTestDirs = Array.from(
new Set(
allUnitTests.map(spec =>
JSON.stringify(
path
.dirname(spec)
.split('/')
.slice(1, 4),
),
),
),
).filter(spec => spec !== undefined);

// const allUnitTests = glob.sync(defaultPath);
// function splitArray(array, chunks) {
// const [...arrayCopy] = array;
// const arrayChunks = [];
// while (arrayCopy.length) {
// arrayChunks.push(arrayCopy.splice(0, chunks));
// }
// return arrayChunks;
// }
function splitArray(array, chunks) {
const [...arrayCopy] = array;
const arrayChunks = [];
while (arrayCopy.length) {
arrayChunks.push(arrayCopy.splice(0, chunks));
}
return arrayChunks;
}
const options = commandLineArgs(COMMAND_LINE_OPTIONS_DEFINITIONS);
let coverageInclude = '';

Expand Down Expand Up @@ -77,23 +90,48 @@ if (process.env.TESTS_TO_VERIFY) {
testsToVerify = JSON.parse(process.env.TESTS_TO_VERIFY).join(' ');
}

// const splitUnitTests = splitArray(
// allUnitTests,
// Math.ceil(allUnitTests.length / numContainers),
// );
console.log('app folder selected: ', options['app-folder']);
// const testsToRun = options['app-folder']
// ? `--recursive ${options.path.map(p => `'${p}'`).join(' ')}`
// : splitUnitTests[matrixStep].join(' ');
const splitUnitTests = splitArray(
allUnitTestDirs,
Math.ceil(allUnitTestDirs.length / numContainers),
);
const appsToRun = options['app-folder']
? [options['app-folder']]
: splitUnitTests[matrixStep];
if (testsToVerify === null) {
for (const dir of appsToRun) {
const updatedPath = options['app-folder']
? options.path.map(p => `'${p}'`).join(' ')
: options.path[0].replace(
`/${specDirs}/`,
`/${JSON.parse(dir).join('/')}/`,
);
const testsToRun = options['app-folder']
? `--recursive ${updatedPath}`
: `--recursive ${glob.sync(updatedPath)}`;
const command = `LOG_LEVEL=${options[
'log-level'
].toLowerCase()} ${testRunner} --max-old-space-size=8192 --config ${configFile} ${testsToRun.replace(
/,/g,
' ',
)} `;
if (testsToRun !== '') {
runCommand(command);
} else {
console.log('This app has no tests to run');
}
}
} else {
const command = `LOG_LEVEL=${options[
'log-level'
].toLowerCase()} ${testRunner} --max-old-space-size=8192 --config ${configFile} ${testsToVerify}`;
runCommand(command);
}

// const command = `LOG_LEVEL=${options[
// 'log-level'
// ].toLowerCase()} ${testRunner} --max-old-space-size=8192 --config ${configFile} ${testsToVerify ||
// testsToRun} `;
const command = `LOG_LEVEL=${options[
'log-level'
].toLowerCase()} ${testRunner} --max-old-space-size=8192 --config ${configFile} ${testsToVerify ||
`--recursive ${options.path.map(p => `'${p}'`).join(' ')}`} `;

console.log(command);

runCommand(command);
// const command = `LOG_LEVEL=${options[
// 'log-level'
// ].toLowerCase()} ${testRunner} --max-old-space-size=8192 --config ${configFile} ${testsToVerify ||
// `--recursive ${options.path.map(p => `'${p}'`).join(' ')}`} `;
Expand Up @@ -61,7 +61,7 @@ const defaultLogSettings = {
forwardErrorsToLogs: true,
forwardConsoleLogs: ['error'],
forwardReports: [],
telemetrySampleRate: 20, // default
telemetrySampleRate: 100, // default 20
};

const initializeBrowserLogging = customLogSettings => {
Expand Down
7 changes: 4 additions & 3 deletions src/applications/avs/components/YourTreatmentPlan.jsx
Expand Up @@ -13,9 +13,10 @@ const YourTreatmentPlan = props => {
const { avs } = props;
const { medChangesSummary, orders } = avs;

const medChanges = !allArraysEmpty(medChangesSummary)
? medChangesSummary
: null;
const medChanges =
medChangesSummary && !allArraysEmpty(medChangesSummary)
? medChangesSummary
: null;

const medsIntro = (
<>
Expand Down
4 changes: 4 additions & 0 deletions src/applications/avs/containers/Avs.jsx
Expand Up @@ -11,6 +11,8 @@ import { RequiredLoginView } from '@department-of-veterans-affairs/platform-user
import { getAvs } from '../api/v0';
import { getFormattedAppointmentDate } from '../utils';

import { useDatadogRum } from '../hooks/useDatadogRum';

import BreadCrumb from '../components/BreadCrumb';
import MoreInformation from '../components/MoreInformation';
import TextWithLineBreaks from '../components/TextWithLineBreaks';
Expand All @@ -24,6 +26,8 @@ const generateAppointmentHeader = avs => {
};

const Avs = props => {
useDatadogRum();

const user = useSelector(selectUser);
const { avsEnabled, featureTogglesLoading } = useSelector(
state => {
Expand Down
54 changes: 54 additions & 0 deletions src/applications/avs/hooks/useDatadogRum.jsx
@@ -0,0 +1,54 @@
import { useEffect } from 'react';
import { datadogRum } from '@datadog/browser-rum';

import environment from '@department-of-veterans-affairs/platform-utilities/environment';

const datadogRumConfig = {
applicationId: '8880279e-5c40-4f82-90f9-9a3cdb6d461b',
clientToken: 'pubcf8129b0768db883d760a1fd6abdc8a0',
site: 'ddog-gov.com',
service: 'avs',
env: environment.vspEnvironment(),
sampleRate: 100,
sessionReplaySampleRate: 100,
trackInteractions: true,
trackFrustrations: true,
trackResources: true,
trackLongTasks: true,
defaultPrivacyLevel: 'mask',
beforeSend: event => {
// Prevent PII from being sent to Datadog with click actions.
if (event.action?.type === 'click') {
// eslint-disable-next-line no-param-reassign
event.action.target.name = 'AVS item';
}
return true;
},
};

const initializeDatadogRum = () => {
if (
// Prevent RUM from running on local/CI environments.
environment.BASE_URL.indexOf('localhost') < 0 &&
// Prevent re-initializing the SDK.
!window.DD_RUM?.getInitConfiguration() &&
!window.Mocha
) {
if (!datadogRumConfig.env) {
datadogRumConfig.env = environment.vspEnvironment();
}
datadogRum.init(datadogRumConfig);
datadogRum.startSessionReplayRecording();
}
};

const useDatadogRum = config => {
useEffect(
() => {
initializeDatadogRum();
},
[config],
);
};

export { useDatadogRum };
Expand Up @@ -56,9 +56,7 @@ describe('Avs: Your Treatment Plan', () => {
delete avs.orders;
delete avs.patientInstructions;
delete avs.clinicalReminders;
avs.medChangesSummary.discontinuedMeds = [];
avs.medChangesSummary.newMedications = [];
avs.medChangesSummary.changedMedications = [];
avs.medChangesSummary = null;
const props = { avs };
const screen = render(<YourTreatmentPlan {...props} />);
expect(screen.queryByTestId('new-orders-heading')).to.not.exist;
Expand All @@ -73,4 +71,14 @@ describe('Avs: Your Treatment Plan', () => {
expect(screen.queryByTestId('discontinued-medications-list')).to.not.exist;
expect(screen.queryByTestId('changed-medications-list')).to.not.exist;
});

it('Med Changes section is not shown if all sub-sections are empty', async () => {
const avs = replacementFunctions.cloneDeep(avsData);
avs.medChangesSummary.discontinuedMeds = [];
avs.medChangesSummary.newMedications = [];
avs.medChangesSummary.changedMedications = [];
const props = { avs };
const screen = render(<YourTreatmentPlan {...props} />);
expect(screen.queryByTestId('changed-medications-list')).to.not.exist;
});
});
Expand Up @@ -94,7 +94,7 @@ const ApplicationDownloadLink = ({ form }) => {
if (errors?.length > 0) {
return (
<div className="caregiver-download-error">
<va-alert status="error">
<va-alert status="error" uswds>
<h3 slot="headline" className="vads-u-font-size--h4">
Something went wrong
</h3>
Expand Down

0 comments on commit 164dccd

Please sign in to comment.