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

Wes/create widget adapter #5

Merged
merged 21 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
2872b83
build the ui before running e2e
wesrisenmay-mx Dec 6, 2024
f78e977
build the ui before running start:e2e
wesrisenmay-mx Dec 6, 2024
408e394
Merge pull request #155 from Universal-Connect-Project/wes/improvemen…
wesrisenmay-mx Dec 6, 2024
699d8f1
testing out a tagging workflow
wesrisenmay-mx Dec 9, 2024
92c54da
add authentication
wesrisenmay-mx Dec 9, 2024
7a710b8
testing adding permissions
wesrisenmay-mx Dec 9, 2024
68a9a51
removing fluff
wesrisenmay-mx Dec 9, 2024
888b262
simplify workflow
wesrisenmay-mx Dec 9, 2024
45102af
only run on merge to main
wesrisenmay-mx Dec 9, 2024
3891c71
Merge pull request #156 from Universal-Connect-Project/wes/autoTag
wesrisenmay-mx Dec 9, 2024
1ffd077
changing widgetAdapter to createWidgetAdapter
wesrisenmay-mx Dec 9, 2024
1e8291c
Merge pull request #157 from Universal-Connect-Project/wes/createWidg…
wesrisenmay-mx Dec 9, 2024
8a3c9ec
Filter test institutions from favorites (#154)
tphalp Dec 9, 2024
a59d59c
Merge branch 'main' of https://github.com/Universal-Connect-Project/u…
wesrisenmay-mx Dec 9, 2024
736da97
changing widget adapter to createWidgetAdapter
wesrisenmay-mx Dec 9, 2024
5a4fcd6
Merge pull request #17 from Universal-Connect-Project/wes/sync
wesrisenmay-mx Dec 9, 2024
f1b9bf6
testing tagging based on the published package
wesrisenmay-mx Dec 10, 2024
bb73c58
tick version and only tag on main
wesrisenmay-mx Dec 10, 2024
628461e
Merge pull request #18 from Universal-Connect-Project/wes/tagPackageV…
wesrisenmay-mx Dec 10, 2024
3678ce4
Merge branch 'main' of https://github.com/Universal-Connect-Project/u…
wesrisenmay-mx Dec 10, 2024
a840770
switch to createWidgetAdapter
wesrisenmay-mx Dec 10, 2024
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
5 changes: 0 additions & 5 deletions .github/workflows/e2e-cypress-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,8 @@ jobs:

# Vars
echo -e "${{ needs.setup-env.outputs.env_vars }}" >> ${ENV_FILE_PATH}

echo ENV=prod >> ${ENV_FILE_PATH}

# Secrets (can't load these from another job, due to GH security features)

cat ${ENV_FILE_PATH}

- name: Cypress run
uses: cypress-io/github-action@v6
env:
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Tag based on package.json version

on:
push:
branches:
- main

permissions:
contents: write

jobs:
tag-package-version:
runs-on: ubuntu-latest

steps:
- name: "Check for package dir"
if: ${{ vars.PACKAGE_DIR == '' }}
run: |
echo Missing required environment variable
exit 1

- name: Checkout Repository
uses: actions/checkout@v3

- name: Set Up Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/Iron"

- name: Configure Git
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"

- name: Create tag
run: |
version=$(jq -r '.version' ${{ vars.PACKAGE_DIR }}/package.json)
tag="v$version"
echo "Creating tag: $tag"

git tag "$tag"
git push origin "$tag"
3 changes: 2 additions & 1 deletion apps/server/cachedDefaults/testData/testPreferences.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

"recommendedInstitutions": [
"5e498f60-3496-4299-96ed-f8eb328ae8af",
"4c1b2595-a5aa-41a1-a2c6-f6caa1e226a6"
"4c1b2595-a5aa-41a1-a2c6-f6caa1e226a6",
"cd27ed3b-f81c-4fa9-94a9-039a9f534c7b"
]
}
7 changes: 7 additions & 0 deletions apps/server/cypress/e2e/prodSuite/testBanks.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@ describe("testBanks", () => {
cy.findAllByText(prodBank).should("exist");
cy.findByText(TEST_EXAMPLE_A_ONLY_INSTITUTION_NAME).should("not.exist");
});

it("filters out test banks from recommended institutions list when prod is the env", () => {
visitAgg();

cy.findAllByText(prodBank).should("exist");
cy.findByText(TEST_EXAMPLE_A_ONLY_INSTITUTION_NAME).should("not.exist");
});
});
10 changes: 5 additions & 5 deletions apps/server/cypress/e2e/suite1/search.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const institutionThatIsInFavoritesButDoesntSupportIdentification =

describe("search", () => {
it("filters recommended institutions by job type", () => {
visitAgg({});
visitAgg();

const institutionThatIsInFavoriteAndSupportsAll =
TEST_EXAMPLE_A_ONLY_INSTITUTION_NAME;
Expand All @@ -33,7 +33,7 @@ describe("search", () => {

describe("Fuzzy Search: Should be able to find certain banks with keywords and misspellings", () => {
it("Finds expected banks", () => {
visitAgg({});
visitAgg();

searchByText("tex");
cy.findByText(TEST_EXAMPLE_A_ONLY_INSTITUTION_NAME, {
Expand All @@ -47,7 +47,7 @@ describe("search", () => {
});

it("Ranks search results in the best way", () => {
visitAgg({});
visitAgg();

cy.findByPlaceholderText("Search").clear().type("TestExample");
cy.findByText(TEST_EXAMPLE_B_ONLY_INSTITUTION_NAME).should("exist");
Expand All @@ -73,7 +73,7 @@ describe("search", () => {

describe("Job type influences the returned institutions", () => {
it(`shows ${institutionThatIsInFavoritesButDoesntSupportIdentification} for agg job type`, () => {
visitAgg({});
visitAgg();

searchByText(institutionThatIsInFavoritesButDoesntSupportIdentification);
cy.findByText(
Expand All @@ -97,7 +97,7 @@ describe("search", () => {

describe("Search by routing number", () => {
it('shows "America First Credit Union" when the routing number is entered into search', () => {
visitAgg({});
visitAgg();

searchByText("111111111");
cy.findByText(TEST_EXAMPLE_B_ONLY_INSTITUTION_NAME).should("exist");
Expand Down
10 changes: 6 additions & 4 deletions apps/server/src/adapterIndex.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getDataFromVCJwt, VCDataTypes } from "@repo/utils";
import { getAggregatorAdapter, getData, getVC } from "./adapterIndex";
import { createAggregatorWidgetAdapter, getData, getVC } from "./adapterIndex";
import type { Aggregator } from "./adapterSetup";
import { TEST_EXAMPLE_A_AGGREGATOR_STRING, TestAdapter } from "./test-adapter";
import { testVcAccountsData } from "./test/testData/testVcData";
Expand Down Expand Up @@ -48,15 +48,17 @@ describe("adapterSetup", () => {
});
});

describe("getAggregatorAdapter", () => {
describe("createAggregatorWidgetAdapter", () => {
it("throws an error if its an unsupported aggregator", async () => {
expect(() => getAggregatorAdapter("junk" as Aggregator)).toThrow(
expect(() => createAggregatorWidgetAdapter("junk" as Aggregator)).toThrow(
"Unsupported aggregator junk",
);
});

it("returns the testExample widget adapter", () => {
const adapter = getAggregatorAdapter(TEST_EXAMPLE_A_AGGREGATOR_STRING);
const adapter = createAggregatorWidgetAdapter(
TEST_EXAMPLE_A_AGGREGATOR_STRING,
);

expect(adapter).toBeInstanceOf(TestAdapter);
});
Expand Down
17 changes: 11 additions & 6 deletions apps/server/src/adapterIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import { info } from "./infra/logger";
import type { Aggregator } from "./adapterSetup";
import { adapterMap } from "./adapterSetup";

export function getAggregatorAdapter(aggregator: Aggregator): WidgetAdapter {
const widgetAdapter = adapterMap[aggregator as keyof typeof adapterMap]?.widgetAdapter;
export function createAggregatorWidgetAdapter(
aggregator: Aggregator,
): WidgetAdapter {
const createWidgetAdapter =
adapterMap[aggregator as keyof typeof adapterMap]?.createWidgetAdapter;

if (widgetAdapter) {
return widgetAdapter;
if (createWidgetAdapter) {
return createWidgetAdapter();
}

throw new Error(`Unsupported aggregator ${aggregator}`);
Expand All @@ -32,7 +35,8 @@ export async function getData({
type,
userId,
}: DataParameters) {
const dataAdapter = adapterMap[aggregator as keyof typeof adapterMap]?.dataAdapter;
const dataAdapter =
adapterMap[aggregator as keyof typeof adapterMap]?.dataAdapter;

if (dataAdapter) {
info("Getting vc from aggregator", aggregator);
Expand All @@ -59,7 +63,8 @@ export async function getVC({
type,
userId,
}: DataParameters) {
const vcAdapter = adapterMap[aggregator as keyof typeof adapterMap]?.vcAdapter;
const vcAdapter =
adapterMap[aggregator as keyof typeof adapterMap]?.vcAdapter;

if (vcAdapter) {
info("Getting vc from aggregator", aggregator);
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/adapters/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// eslint-disable @typescript-eslint/naming-convention
import { aggregators } from "../adapterSetup";
import { getAggregatorAdapter } from "../adapterIndex";
import { createAggregatorWidgetAdapter } from "../adapterIndex";
import * as logger from "../infra/logger";
import { AnalyticsClient } from "../services/analyticsClient";
import { resolveInstitutionAggregator } from "../services/institutionResolver";
Expand Down Expand Up @@ -62,7 +62,7 @@ export class AggregatorAdapterBase {
this.analyticsClient = new AnalyticsClient(token);
try {
if (this.context?.aggregator) {
this.aggregatorAdapter = getAggregatorAdapter(
this.aggregatorAdapter = createAggregatorWidgetAdapter(
this.context?.aggregator as Aggregator,
);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/connect/connectApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
transformedInstitutionList,
} from "../test/testData/institution";
import { ConnectApi } from "./connectApi";
import { TEST_EXAMPLE_A_AGGREGATOR_STRING } from "../test-adapter";
import {
TEST_EXAMPLE_A_AGGREGATOR_STRING,
TEST_EXAMPLE_B_AGGREGATOR_STRING,
testExampleInstitution,
} from "../test-adapter/constants";
Expand Down
8 changes: 4 additions & 4 deletions apps/server/src/connect/connectApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ export class ConnectApi extends AggregatorAdapterBase {
this.context.updated = true;
this.context.aggregator = null;

const recommendedInstitutions = await getRecommendedInstitutions(
this.context.job_type as MappedJobTypes,
);
const recommendedInstitutions = await getRecommendedInstitutions({
jobType: this.context.job_type as MappedJobTypes,
});
return recommendedInstitutions
.filter((ins) => ins != null)
.filter((ins: CachedInstitution) => ins != null)
.map(mapCachedInstitution);
}
}
1 change: 1 addition & 0 deletions apps/server/src/connect/institutionEndpoints.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Request, Response } from "express";

import type { MappedJobTypes } from "../shared/contract";
import { mapCachedInstitution } from "./connectApi";
import { search, searchByRoutingNumber } from "../services/ElasticSearchClient";
Expand Down
14 changes: 9 additions & 5 deletions apps/server/src/connect/userEndpoints.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { Response } from "express";
import { getAggregatorAdapter } from "../adapterIndex";
import type { Aggregator } from "../shared/contract";
import { Aggregators } from "../shared/contract";
import { listUsersData } from "../test/testData/users";
import { invalidAggregatorString } from "../utils/validators";
import type { UserDeleteRequest } from "./userEndpoints";
import { userDeleteHandler } from "./userEndpoints";
import * as adapterIndex from "../adapterIndex";
import type { WidgetAdapter } from "@repo/utils";

const user = listUsersData.users[0];

Expand Down Expand Up @@ -54,10 +55,13 @@ describe("userEndpoints", () => {
it("responds with a failure if TestA deletion fails", async () => {
// Mock DeleteUser from TestAdapter
jest
.spyOn(getAggregatorAdapter(Aggregators.TEST_A), "DeleteUser")
.mockImplementation(() => {
throw new Error("User delete failed");
});
.spyOn(adapterIndex, "createAggregatorWidgetAdapter")
.mockReturnValue({
DeleteUser: () => {
throw new Error("Delete failed");
},
ResolveUserId: () => "test",
} as unknown as WidgetAdapter);

const res = {
send: jest.fn(),
Expand Down
38 changes: 19 additions & 19 deletions apps/server/src/connect/userEndpoints.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import type { Response } from 'express'
import { getAggregatorAdapter } from '../adapterIndex'
import { withValidateAggregatorInPath } from '../utils/validators'
import type { Aggregator } from '../adapterSetup'
import type { Response } from "express";
import { createAggregatorWidgetAdapter } from "../adapterIndex";
import { withValidateAggregatorInPath } from "../utils/validators";
import type { Aggregator } from "../adapterSetup";

interface UserDeleteParameters {
aggregator: Aggregator
userId: string
aggregator: Aggregator;
userId: string;
}

export interface UserDeleteRequest {
params: UserDeleteParameters
params: UserDeleteParameters;
}

export const userDeleteHandler = withValidateAggregatorInPath(
async (req: UserDeleteRequest, res: Response) => {
const { userId, aggregator } = req.params
const { userId, aggregator } = req.params;

try {
const aggregatorAdapter = getAggregatorAdapter(aggregator)
const failIfUserNotFound = true
const aggregatorAdapter = createAggregatorWidgetAdapter(aggregator);
const failIfUserNotFound = true;
const aggregatorUserId = await aggregatorAdapter.ResolveUserId(
userId,
failIfUserNotFound
)
const ret = await aggregatorAdapter.DeleteUser(aggregatorUserId)
res.status(ret.status)
res.send(ret.data)
failIfUserNotFound,
);
const ret = await aggregatorAdapter.DeleteUser(aggregatorUserId);
res.status(ret.status);
res.send(ret.data);
} catch (error) {
res.status(400)
res.send('User delete failed')
res.status(400);
res.send("User delete failed");
}
}
)
},
);
8 changes: 4 additions & 4 deletions apps/server/src/dataEndpoints/dataEndpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import he from "he";
import { VCDataTypes } from "@repo/utils";
import type { Aggregator } from "../shared/contract";
import { withValidateAggregatorInPath } from "../utils/validators";
import { getAggregatorAdapter, getData, getVC } from "../adapterIndex";
import { createAggregatorWidgetAdapter, getData, getVC } from "../adapterIndex";

export interface AccountsDataQueryParameters {
connectionId: string;
Expand All @@ -30,7 +30,7 @@ export const createAccountsDataHandler = (isVc: boolean) =>
withValidateAggregatorInPath(async (req: AccountsRequest, res: Response) => {
const { aggregator, connectionId, userId } = req.params;

const aggregatorAdapter = getAggregatorAdapter(aggregator);
const aggregatorAdapter = createAggregatorWidgetAdapter(aggregator);
const aggregatorUserId = await aggregatorAdapter.ResolveUserId(userId);

const dataArgs = {
Expand Down Expand Up @@ -67,7 +67,7 @@ export const createIdentityDataHandler = (isVc: boolean) =>
withValidateAggregatorInPath(async (req: IdentityRequest, res: Response) => {
const { aggregator, connectionId, userId } = req.params;

const aggregatorAdapter = getAggregatorAdapter(aggregator);
const aggregatorAdapter = createAggregatorWidgetAdapter(aggregator);
const aggregatorUserId = await aggregatorAdapter.ResolveUserId(userId);

const dataArgs = {
Expand Down Expand Up @@ -110,7 +110,7 @@ export const createTransactionsDataHandler = (isVc: boolean) =>
const { accountId, aggregator, userId } = req.params;
const { start_time, end_time } = req.query;

const aggregatorAdapter = getAggregatorAdapter(aggregator);
const aggregatorAdapter = createAggregatorWidgetAdapter(aggregator);
const aggregatorUserId = await aggregatorAdapter.ResolveUserId(userId);

const dataArgs = {
Expand Down
Loading
Loading