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

Fix vulnerabilities #826

Merged
merged 41 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ae5a4f9
Removed react-scripts, npm audit fix
VladMstv Jan 27, 2025
5406bf1
add node tsconfig in apps for tests
VladMstv Jan 27, 2025
27c1703
remove node libs usage from some utils package files, move auth relat…
VladMstv Jan 30, 2025
57ec06f
Merge branch 'develop' into Fix-vulnerabilities
VladMstv Jan 30, 2025
9e72ba3
add dummy test to zambda-utils package
VladMstv Jan 30, 2025
2206da6
move make-presigned-file-url function back in zambda, moved makez3url…
VladMstv Jan 31, 2025
f1cc87e
moved and fixed imports for more zambda related utils
VladMstv Jan 31, 2025
8b06fec
remove unused scripts from package.json
VladMstv Jan 31, 2025
c7005dc
bring back performEffectWithEnvFile
VladMstv Jan 31, 2025
4555bb7
fix topLevelCatch imports
VladMstv Jan 31, 2025
90d51b6
Merge branch 'develop' into Fix-vulnerabilities
VladMstv Jan 31, 2025
575de4c
move zambda get-presigned-url related stuff into appropriate folders …
VladMstv Jan 31, 2025
a97f373
moved more backend-only things to zambda-utils package and updated im…
VladMstv Jan 31, 2025
73d3362
fix more vulnerabilities, fix sls runs and builds after updates
VladMstv Jan 31, 2025
e54dc01
fix more vulnerabilities, fix sls runs and builds after updates
VladMstv Jan 31, 2025
414c065
Merge branch 'develop' into Fix-vulnerabilities
VladMstv Jan 31, 2025
3b90b93
Merge branch 'develop' into Fix-vulnerabilities
VladMstv Feb 3, 2025
f06f57d
fix lint and errors after develop merge
VladMstv Feb 3, 2025
03878ad
fix lint after merge from develop
VladMstv Feb 3, 2025
39ba86e
Merge branch 'develop' into Fix-vulnerabilities
VladMstv Feb 5, 2025
020bba4
fix package-lock file
VladMstv Feb 6, 2025
87db15f
fix engine version in package.json files
VladMstv Feb 6, 2025
ebc3523
Merge branch 'develop' into Fix-vulnerabilities
VladMstv Feb 7, 2025
009a243
Merge branch 'develop' into Fix-vulnerabilities
VladMstv Feb 10, 2025
0ba259c
fix candid import
VladMstv Feb 10, 2025
1986eea
try fix tests
VladMstv Feb 12, 2025
24cacfa
Merge branch 'develop' into Fix-vulnerabilities
VladMstv Feb 12, 2025
a40829b
Merge branch 'develop' into Fix-vulnerabilities
VladMstv Feb 12, 2025
5c6a869
Merge branch 'develop' into Fix-vulnerabilities
VladMstv Feb 13, 2025
d15ab49
fix imports for zambda secrets
VladMstv Feb 13, 2025
59cd43b
try fix module issues in e2e run
VladMstv Feb 13, 2025
9883fe9
update package.json
VladMstv Feb 13, 2025
0dba076
fix eligibility zambda validation input typea
VladMstv Feb 13, 2025
de310bb
Merge branch 'develop' into Fix-vulnerabilities
VladMstv Feb 14, 2025
a83b17e
fix addPatient tests
VladMstv Feb 14, 2025
63203ca
Added PageWithTablePagination test class for testing pages with pagin…
VladMstv Feb 14, 2025
5ed9140
fix comment
VladMstv Feb 14, 2025
6b6c8b0
fix states page tests
VladMstv Feb 14, 2025
f8c3afc
comment part of ehr test that causes failute in CI but runs fine locally
VladMstv Feb 14, 2025
10c6237
fix past visits tests to remove test appointments after tests finish,…
VladMstv Feb 14, 2025
1d5cf6f
fix start now in-person flow tests
VladMstv Feb 14, 2025
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
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ vite.config.ts
vite-env.d.ts
build/
dist/
.esbuild/
.esbuild/
old-ottehr/
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
!apps/**/*.js
!apps/**/*.jsx
!/vite.config.ts
.esbuild/
.esbuild/
old-ottehr/
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ export const PatientsSearchTable: React.FC<{
backIconButtonProps={{
disabled: !searchResult?.pagination.prev || arePatientsLoading,
}}
data-testid={dataTestIds.pagination.paginationContainer}
/>
</TableRow>
</TableFooter>
Expand Down
4 changes: 3 additions & 1 deletion apps/ehr/src/components/ScheduleInformation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ import { ReactElement, useEffect, useMemo, useState } from 'react';
import { Link } from 'react-router-dom';
import { otherColors } from '../CustomThemeProvider';

import { Add } from '@mui/icons-material';
import Oystehr from '@oystehr/sdk';
import { HealthcareService, Location, Practitioner, Resource } from 'fhir/r4b';
import { DateTime } from 'luxon';
import { dataTestIds } from '../constants/data-test-ids';
import { OVERRIDE_DATE_FORMAT } from '../helpers/formatDateTime';
import { useApiClients } from '../hooks/useAppClients';
import { Closure, ClosureType, ScheduleExtension } from '../types/types';
import Loading from './Loading';
import { Add } from '@mui/icons-material';

export type ScheduleType = 'office' | 'provider' | 'group';

Expand Down Expand Up @@ -301,6 +302,7 @@ export const ScheduleInformation = ({ scheduleType }: ScheduleInformationProps):
page={pageNumber}
onPageChange={handleChangePage}
onRowsPerPageChange={handleChangeRowsPerPage}
data-testid={dataTestIds.pagination.paginationContainer}
/>
</TableContainer>
</Paper>
Expand Down
6 changes: 2 additions & 4 deletions apps/ehr/src/constants/data-test-ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ export const dataTestIds = {
prefilledPatientEmail: 'prefilled-patient-email',
},
pagination: {
nextPage: 'KeyboardArrowRightIcon',
previousPage: 'KeyboardArrowLeftIcon',
paginationContainer: 'pagination-container',
dropDownArrow: 'ArrowDropDownIcon',
},
patientHeader: {
patientId: 'header-patient-id',
Expand Down Expand Up @@ -109,7 +106,8 @@ export const dataTestIds = {
patientEmail: 'patient-email',
patientPhoneNumber: 'patient-phone-number',
patientAddress: 'patient-address',
searchResultRow: (patientId: string) => `search-result-row-${patientId}`,
searchResultsRowPrefix: 'search-result-row-',
searchResultRow: (patientId: string) => `${dataTestIds.patients.searchResultsRowPrefix}${patientId}`,
},
employeesPage: {
table: 'employees-providers-content-table',
Expand Down
5 changes: 3 additions & 2 deletions apps/ehr/src/pages/Employees.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import { AllStates, EmployeeDetails, State } from 'utils';
import { otherColors } from '../CustomThemeProvider';
import { getEmployees } from '../api/api';
import Loading from '../components/Loading';
import { EMPLOYEE_ROWS_PER_PAGE, PROVIDER_ROWS_PER_PAGE } from '../constants';
import { dataTestIds } from '../constants/data-test-ids';
import { formatDateUsingSlashes } from '../helpers/formatDateTime';
import { useApiClients } from '../hooks/useAppClients';
import PageContainer from '../layout/PageContainer';
import { EMPLOYEE_ROWS_PER_PAGE, PROVIDER_ROWS_PER_PAGE } from '../constants';
import { dataTestIds } from '../constants/data-test-ids';

enum PageTab {
employees = 'employees',
Expand Down Expand Up @@ -414,6 +414,7 @@ function EmployeesTable({
page={pageNumber}
onPageChange={handleChangePage}
onRowsPerPageChange={handleChangeRowsPerPage}
data-testid={dataTestIds.pagination.paginationContainer}
/>
</TableContainer>
</Paper>
Expand Down
4 changes: 3 additions & 1 deletion apps/ehr/src/telemed/features/telemed-admin/Insurance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ import React, { ReactElement } from 'react';
import { Link } from 'react-router-dom';
import { BooleanStateChip } from '../..';
import { INSURANCES_URL } from '../../../App';
import { INSURANCE_ROWS_PER_PAGE } from '../../../constants';
import { dataTestIds } from '../../../constants/data-test-ids';
import { otherColors } from '../../../CustomThemeProvider';
import { useInsurancesQuery } from './telemed-admin.queries';
import { INSURANCE_ROWS_PER_PAGE } from '../../../constants';

enum IsActiveStatus {
active,
Expand Down Expand Up @@ -206,6 +207,7 @@ export default function Insurances(): ReactElement {
page={pageNumber}
onPageChange={handleChangePage}
onRowsPerPageChange={handleChangeRowsPerPage}
data-testid={dataTestIds.pagination.paginationContainer}
/>
</TableContainer>
</Paper>
Expand Down
8 changes: 4 additions & 4 deletions apps/ehr/src/telemed/state/appointment/appointment.queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import { useAuth0 } from '@auth0/auth0-react';
import {
Appointment,
Bundle,
Coding,
DocumentReference,
Encounter,
FhirResource,
InsurancePlan,
Location,
Medication,
Patient,
QuestionnaireResponse,
RelatedPerson,
Coding,
Medication,
} from 'fhir/r4b';
import { DateTime } from 'luxon';
import { enqueueSnackbar } from 'notistack';
Expand All @@ -21,6 +21,7 @@ import {
ChartDataRequestedFields,
GetMedicationOrdersResponse,
INVENTORY_MEDICATION_TYPE_CODE,
IcdSearchRequestParams,
InstructionType,
MEDICATION_IDENTIFIER_NAME_SYSTEM,
MeetingData,
Expand All @@ -33,14 +34,13 @@ import {
createSmsModel,
filterResources,
relatedPersonAndCommunicationMaps,
IcdSearchRequestParams,
} from 'utils';
import { APPOINTMENT_REFRESH_INTERVAL, CHAT_REFETCH_INTERVAL, QUERY_STALE_TIME } from '../../../constants';
import { useApiClients } from '../../../hooks/useAppClients';
import { useAuthToken } from '../../../hooks/useAuthToken';
import useEvolveUser, { EvolveUser } from '../../../hooks/useEvolveUser';
import { getSelectors } from '../../../shared/store/getSelectors';
import { PromiseReturnType, OystehrTelemedAPIClient } from '../../data';
import { OystehrTelemedAPIClient, PromiseReturnType } from '../../data';
import { useGetAppointmentAccessibility } from '../../hooks';
import { useZapEHRAPIClient } from '../../hooks/useOystehrAPIClient';
import { createRefreshableAppointmentData, extractReviewAndSignAppointmentData } from '../../utils';
Expand Down
1 change: 1 addition & 0 deletions apps/ehr/test/e2e/page/AddPatientPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class AddPatientPage {
const locator = this.#page.locator('[placeholder="MM/DD/YYYY"]');
await locator.click();
await this.#page.waitForTimeout(2000);
// just because of date input for some reason not accepting wrong date
await locator.pressSequentially(dateOfBirth);
}

Expand Down
70 changes: 70 additions & 0 deletions apps/ehr/test/e2e/page/PageWithTablePagination.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { Page, expect } from '@playwright/test';
import { dataTestIds } from '../../../src/constants/data-test-ids';

export class PageWithTablePagination {
#page: Page;

constructor(page: Page) {
this.#page = page;
}

async clickNextPage(): Promise<void> {
await this.#page.getByTestId(dataTestIds.pagination.paginationContainer).getByTitle('Go to next page').click();
}

async clickPreviousPage(): Promise<void> {
await this.#page.getByTestId(dataTestIds.pagination.paginationContainer).getByTitle('Go to previous page').click();
}

async verifyPaginationState(rows: string): Promise<void> {
await expect(
this.#page.getByTestId(dataTestIds.pagination.paginationContainer).locator('p:text("' + rows + '")')
).toBeVisible();
}

async selectRowsPerPage(rowsPerPage: string): Promise<void> {
await this.#page.getByTestId(dataTestIds.pagination.paginationContainer).getByText('10', { exact: true }).click();
await this.#page.getByText(rowsPerPage).click();
}

async canGoNextPage(): Promise<boolean> {
return (
await this.#page.getByTestId(dataTestIds.pagination.paginationContainer).getByTitle('Go to next page')
).isEnabled();
}

/**
* Iterates through paginated results and finds an expected value.
* @param callback - A function that returns `true` when the expected element is found.
* @param pageLoadedCallback - (Optional) A function to wait for the page to load after pagination.
* @returns `true` if the element is found, otherwise `false`.
*/
async findInPages(callback: () => Promise<boolean>, pageLoadedCallback?: () => Promise<void>): Promise<boolean> {
if (pageLoadedCallback) {
await pageLoadedCallback(); // Wait for the page to load initially
}
do {
if (await callback()) {
return true; // Stop when the condition is met
}
} while (await this.goToNextPageIfPossible(pageLoadedCallback));

return false; // Element not found in any page
}

/**
* Moves to the next page and waits for it to load.
* @param pageLoadedCallback - (Optional) A function to wait for the page to fully load.
* @returns `true` if pagination moved to the next page, otherwise `false`.
*/
private async goToNextPageIfPossible(pageLoadedCallback?: () => Promise<void>): Promise<boolean> {
if (await this.canGoNextPage()) {
await this.clickNextPage();
if (pageLoadedCallback) {
await pageLoadedCallback(); // Wait for the page to load dynamically
}
return true;
}
return false;
}
}
59 changes: 43 additions & 16 deletions apps/ehr/test/e2e/page/PatientsPage.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { expect, Page } from '@playwright/test';
import { dataTestIds } from '../../../src/constants/data-test-ids';
import { PageWithTablePagination } from './PageWithTablePagination';

export class PatientsPage {
export class PatientsPage extends PageWithTablePagination {
#page: Page;

constructor(page: Page) {
super(page);
this.#page = page;
}

Expand All @@ -16,7 +18,7 @@ export class PatientsPage {
const locator = this.#page.getByTestId(dataTestIds.patients.searchByDateOfBirthField).locator('input');
await locator.click();
await this.#page.waitForTimeout(2000);
await locator.pressSequentially(dateOfBirth);
await locator.fill(dateOfBirth);
}

async searchByMobilePhone(phone: string): Promise<void> {
Expand All @@ -43,7 +45,6 @@ export class PatientsPage {

async clickSearchButton(): Promise<void> {
await this.#page.getByTestId(dataTestIds.patients.searchButton).click();
await this.#page.waitForTimeout(15000);
}

async clickResetFiltersButton(): Promise<void> {
Expand All @@ -67,19 +68,45 @@ export class PatientsPage {
phoneNumber: string;
address: string;
}): Promise<void> {
const rowLocator = this.#page.getByTestId(dataTestIds.patients.searchResultRow(patientInfo.id));
const rowPatientId = await rowLocator.getByTestId(dataTestIds.patients.patientId).innerText();
const rowPatientName = await rowLocator.getByTestId(dataTestIds.patients.patientName).innerText();
const rowPatientDateOfBirth = await rowLocator.getByTestId(dataTestIds.patients.patientDateOfBirth).innerText();
const rowPatientEmail = await rowLocator.getByTestId(dataTestIds.patients.patientEmail).innerText();
const rowPatientPhoneNumber = await rowLocator.getByTestId(dataTestIds.patients.patientPhoneNumber).innerText();
const rowPatientAddress = await rowLocator.getByTestId(dataTestIds.patients.patientAddress).innerText();
expect(rowPatientId).toBe(patientInfo.id);
expect(rowPatientName).toBe(patientInfo.lastName + ' ' + patientInfo.firstName);
expect(rowPatientDateOfBirth).toBe(patientInfo.dateOfBirth);
expect(rowPatientEmail).toBe(patientInfo.email);
expect(rowPatientPhoneNumber).toBe(patientInfo.phoneNumber);
expect(rowPatientAddress).toBe(patientInfo.address);
const patientPresent = await this.findInPages(
async () => {
const rowLocator = this.#page.getByTestId(dataTestIds.patients.searchResultRow(patientInfo.id));
if (!(await rowLocator.isVisible())) return Promise.resolve(false);
const rowPatientId = await rowLocator.getByTestId(dataTestIds.patients.patientId).innerText();
const rowPatientName = await rowLocator.getByTestId(dataTestIds.patients.patientName).innerText();
const rowPatientDateOfBirth = await rowLocator.getByTestId(dataTestIds.patients.patientDateOfBirth).innerText();
const rowPatientEmail = await rowLocator.getByTestId(dataTestIds.patients.patientEmail).innerText();
const rowPatientPhoneNumber = await rowLocator.getByTestId(dataTestIds.patients.patientPhoneNumber).innerText();
const rowPatientAddress = await rowLocator.getByTestId(dataTestIds.patients.patientAddress).innerText();
return new Promise((resolve) => {
if (
rowPatientId === patientInfo.id &&
rowPatientName === patientInfo.lastName + ' ' + patientInfo.firstName &&
rowPatientDateOfBirth === patientInfo.dateOfBirth &&
rowPatientEmail === patientInfo.email &&
rowPatientPhoneNumber === patientInfo.phoneNumber &&
rowPatientAddress === patientInfo.address
) {
resolve(true);
}
resolve(false);
});
},
async () => {
// Wait for the backend API call to complete
await this.#page.waitForResponse(
(response) => response.url().includes('/Patient?') && response.status() === 200
);

// Ensure search results update after response is received
await this.#page
.getByTestId(/search-result-row-/i)
.first()
.waitFor({ state: 'attached' });
}
);

expect(patientPresent).toBe(true);
}
}

Expand Down
23 changes: 3 additions & 20 deletions apps/ehr/test/e2e/page/StatesPage.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
import { expect, Page } from '@playwright/test';
import { dataTestIds } from '../../../src/constants/data-test-ids';
import { PageWithTablePagination } from './PageWithTablePagination';

export class StatesPage {
export class StatesPage extends PageWithTablePagination {
#page: Page;

constructor(page: Page) {
super(page);
this.#page = page;
}

async clickNextPage(): Promise<void> {
await this.#page.getByTestId(dataTestIds.pagination.nextPage).click();
}

async clickPreviousPage(): Promise<void> {
await this.#page.getByTestId(dataTestIds.pagination.previousPage).click();
}

async verifyPaginationState(rows: string): Promise<void> {
await expect(
this.#page.getByTestId(dataTestIds.pagination.paginationContainer).locator('p:text("' + rows + '")')
).toBeVisible();
}

async verifyStatePresent(state: string): Promise<void> {
await expect(this.#page.getByTestId(dataTestIds.statesPage.stateRow(state))).toBeVisible();
}
Expand All @@ -32,11 +20,6 @@ export class StatesPage {
);
}

async selectRowsPerPage(rowsPerPage: string): Promise<void> {
await this.#page.getByTestId(dataTestIds.pagination.paginationContainer).getByText('10', { exact: true }).click();
await this.#page.getByText(rowsPerPage).click();
}

async searchStates(text: string): Promise<void> {
await this.#page.getByTestId(dataTestIds.statesPage.statesSearch).locator('input').fill(text);
}
Expand Down
Loading