From 0ad3488031b187c76ce1d29c8927430b7f7df8a7 Mon Sep 17 00:00:00 2001 From: Helder Oliveira Date: Wed, 30 Oct 2024 17:05:56 +0100 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20Remove=20testTools=20an?= =?UTF-8?q?d=20updates=20dependencies=20(#7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: 🤖 use workspace protocol * chore: 🤖 remove testTools * chore: 🤖 missing package * chore: 🤖 remove dependency * chore: 🤖 changeset * chore: 🤖 use public package versions * chore: 🤖 update lockfile * chore: 🤖 changeset --- .changeset/fifty-chefs-mix.md | 5 + .changeset/many-houses-camp.md | 5 + package.json | 2 +- pnpm-lock.yaml | 20 +-- src/testTools/inferAndCombineItContext.ts | 14 -- ...asesAndGraphqlWithBrowserSdkForEachTest.ts | 128 ------------------ ...tabasesAndGraphqlWithNodeSdkForEachTest.ts | 48 ------- src/testTools/secrets.ts | 5 - 8 files changed, 17 insertions(+), 210 deletions(-) create mode 100644 .changeset/fifty-chefs-mix.md create mode 100644 .changeset/many-houses-camp.md delete mode 100644 src/testTools/inferAndCombineItContext.ts delete mode 100644 src/testTools/mockDatabasesAndGraphqlWithBrowserSdkForEachTest.ts delete mode 100644 src/testTools/mockDatabasesAndGraphqlWithNodeSdkForEachTest.ts delete mode 100644 src/testTools/secrets.ts diff --git a/.changeset/fifty-chefs-mix.md b/.changeset/fifty-chefs-mix.md new file mode 100644 index 0000000..e89449b --- /dev/null +++ b/.changeset/fifty-chefs-mix.md @@ -0,0 +1,5 @@ +--- +'Examples': minor +--- + +Changes required during monorepository transition diff --git a/.changeset/many-houses-camp.md b/.changeset/many-houses-camp.md new file mode 100644 index 0000000..439fd23 --- /dev/null +++ b/.changeset/many-houses-camp.md @@ -0,0 +1,5 @@ +--- +"Examples": patch +--- + +Remove testTools and updates dependencies diff --git a/package.json b/package.json index 10dc6fc..4415252 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@changesets/cli": "^2.27.6", "@fleek-platform/errors": "^2.7.0", "@fleek-platform/utils-genql-client": "^0.2.1", - "@fleek-platform/utils-token": "^0.2.0", + "@fleek-platform/utils-token": "^0.2.2", "@jspm/core": "^2.0.1", "@tsconfig/node16": "^16.1.3", "@types/detect-node": "^2.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 925b356..797d776 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -52,8 +52,8 @@ importers: specifier: ^0.2.1 version: 0.2.1 '@fleek-platform/utils-token': - specifier: ^0.2.0 - version: 0.2.0 + specifier: ^0.2.2 + version: 0.2.2 '@jspm/core': specifier: ^2.0.1 version: 2.0.1 @@ -422,17 +422,14 @@ packages: resolution: {integrity: sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==} engines: {node: '>=14'} - '@fleek-platform/errors@2.5.1': - resolution: {integrity: sha512-yjShUD0bLzSceq61FyWj7ygc2RG0xdr3dqr43mRfwLF92c3YkZ2abDAq2CxriPbB8OhGKLASjrLzQQx6jQ/lcQ==} - '@fleek-platform/errors@2.7.0': resolution: {integrity: sha512-56moPR+V6bW6l+8KopmK4vfx0XU3i2s9UHNgAXXgGn/tBvgFN5bjHe4uT/K6i9Q/S3f5kAOgul6KseV1sucDKQ==} '@fleek-platform/utils-genql-client@0.2.1': resolution: {integrity: sha512-q2MtlgH4QkMnHh+1OBuBi0klZIn5UpBnM9VNO3n25EAh/91ppWxdjCV3kNALi/hNV2B+lOeoQDjeiE922lMiBA==} - '@fleek-platform/utils-token@0.2.0': - resolution: {integrity: sha512-vEFonU2lMMgxIA4qcyPppZc3PxgFde3KA2UJKPhIsL0lu5UT8v7LsNsWbc/ovJJ7klV+iQBlkREM2Mwx5qd3Dw==} + '@fleek-platform/utils-token@0.2.2': + resolution: {integrity: sha512-BpaXpgHIi13IcI8Yog+RgFVFv66bCYU9+jEqgQV4g4FiWS4x4Vn/crtquPdt4iXFRogJTvSI5tkCkrTNgsmgNQ==} engines: {node: '>=18.18.2'} '@inquirer/confirm@4.0.1': @@ -934,7 +931,6 @@ packages: bun@1.1.29: resolution: {integrity: sha512-SKhpyKNZtgxrVel9ec9xon3LDv8mgpiuFhARgcJo1YIbggY2PBrKHRNiwQ6Qlb+x3ivmRurfuwWgwGexjpgBRg==} - cpu: [arm64, x64] os: [darwin, linux, win32] hasBin: true @@ -2387,19 +2383,15 @@ snapshots: '@fastify/busboy@2.1.1': {} - '@fleek-platform/errors@2.5.1': - dependencies: - nanoid: 3.3.7 - '@fleek-platform/errors@2.7.0': dependencies: nanoid: 3.3.7 '@fleek-platform/utils-genql-client@0.2.1': {} - '@fleek-platform/utils-token@0.2.0': + '@fleek-platform/utils-token@0.2.2': dependencies: - '@fleek-platform/errors': 2.5.1 + '@fleek-platform/errors': 2.7.0 jose: 4.11.2 jscrypto: 1.0.3 nanoid: 3.3.7 diff --git a/src/testTools/inferAndCombineItContext.ts b/src/testTools/inferAndCombineItContext.ts deleted file mode 100644 index 14909bb..0000000 --- a/src/testTools/inferAndCombineItContext.ts +++ /dev/null @@ -1,14 +0,0 @@ -import * as vitest from 'vitest'; - -/** This function must be copied into each tested package. See docs for `mockDatabasesAndGraphqlForEachTest` in `@fleek-platform/tester` package. */ -export const inferAndCombineItContext = ( - _firstIt: ( - description: string, - callback: (context: TFirstContext) => Promise, - ) => void, - _secondIt?: ( - description: string, - callback: (context: TSecondContext) => Promise, - ) => void, - // eslint-disable-next-line @typescript-eslint/no-explicit-any -) => vitest.it as any as vitest.TestAPI; diff --git a/src/testTools/mockDatabasesAndGraphqlWithBrowserSdkForEachTest.ts b/src/testTools/mockDatabasesAndGraphqlWithBrowserSdkForEachTest.ts deleted file mode 100644 index 6605dac..0000000 --- a/src/testTools/mockDatabasesAndGraphqlWithBrowserSdkForEachTest.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -import { createYogaInstance } from '@fleek-platform/graphql/src/server'; -import { - mockBrowserEnvironmentForEachTest, - mockDatabasesAndGraphqlForEachTest, - seeds, -} from '@fleek-platform/tester'; -import { Decimal } from 'decimal.js'; -import { mapValues } from 'lodash'; -import * as vitest from 'vitest'; - -import type { FleekSdk, StaticAccessTokenService } from '../index'; -import { inferAndCombineItContext } from './inferAndCombineItContext'; -import { secrets } from './secrets'; - -type RunInBrowserArgs = { callback: () => Promise }; - -declare global { - // eslint-disable-next-line fleek-custom/no-interface - interface Window { - FleekSdk: typeof FleekSdk; - StaticAccessTokenService: typeof StaticAccessTokenService; - sdk: FleekSdk; - seeds: typeof seeds; - Decimal: typeof Decimal; - mapValues: typeof mapValues; - } -} - -type MockDatabasesAndGraphqlWithBrowserSdkForEachTestArgs = { - mockIpfs: T; -}; - -export const mockDatabasesAndGraphqlWithBrowserSdkForEachTest = < - T extends boolean, ->({ - mockIpfs, -}: MockDatabasesAndGraphqlWithBrowserSdkForEachTestArgs) => { - const { it: itWithBrowser } = mockBrowserEnvironmentForEachTest({ vitest }); - - const yoga = createYogaInstance({}); - - const { it: itWithMockSdk } = mockDatabasesAndGraphqlForEachTest({ - originalIt: itWithBrowser, - vitest, - yoga, - mockIpfs, - sdkFactory: async ({ - originalContext, - url, - accessToken, - ipfsStorageApiUrl, - }) => { - await originalContext.page.goto('http://localhost:8081'); - - return async ({ callback }: RunInBrowserArgs): Promise => { - await originalContext.page.evaluate( - (pageContextArgs) => { - const accessTokenService = new window.StaticAccessTokenService({ - accessToken: pageContextArgs.accessToken, - }); - window.sdk = new window.FleekSdk({ - graphqlServiceApiUrl: pageContextArgs.url, - accessTokenService, - ipfsStorageApiUrl: pageContextArgs.ipfsStorageApiUrl, - }); - - type ParseSeedsArgs = Record; - - const parseSeeds = ( - object: ParseSeedsArgs, - ): Record => { - return window.mapValues(object, (value) => { - if ( - !!value && - Object.getPrototypeOf(value) === Object.prototype - ) { - return parseSeeds(value); - } - - if ( - typeof value === 'string' && - value.startsWith('__Decimal__') - ) { - return new window.Decimal(value.slice(11)); - } - - return value; - }); - }; - - window.seeds = parseSeeds(pageContextArgs.seeds) as typeof seeds; - }, - { url, accessToken, seeds: serializeSeeds(seeds), ipfsStorageApiUrl }, - ); - - return originalContext.page.evaluate(callback); - }; - }, - sdkConfigs: { - josh: { - auth: { - userId: seeds.auth.user.josh.id, - secret: secrets.SECRET_JWT_IDENTITY, - projectId: seeds.auth.project.electronicCo.id, - }, - }, - }, - }); - - return { it: inferAndCombineItContext(itWithBrowser, itWithMockSdk) }; -}; - -type SerializeSeedsArgs = Record; - -const serializeSeeds = (object: SerializeSeedsArgs): Record => { - return mapValues(object, (value) => { - if (!!value && Object.getPrototypeOf(value) === Object.prototype) { - return serializeSeeds(value); - } - - if (Object.prototype.toString.call(value) === '[object Decimal]') { - return `__Decimal__${value.toString()}`; - } - - return value; - }); -}; diff --git a/src/testTools/mockDatabasesAndGraphqlWithNodeSdkForEachTest.ts b/src/testTools/mockDatabasesAndGraphqlWithNodeSdkForEachTest.ts deleted file mode 100644 index c95a876..0000000 --- a/src/testTools/mockDatabasesAndGraphqlWithNodeSdkForEachTest.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { createYogaInstance } from '@fleek-platform/graphql/src/server'; -import { - mockDatabasesAndGraphqlForEachTest, - seeds, -} from '@fleek-platform/tester'; -import * as vitest from 'vitest'; - -import { FleekSdk, StaticAccessTokenService } from '../index'; -import { inferAndCombineItContext } from './inferAndCombineItContext'; -import { secrets } from './secrets'; - -type MockDatabasesAndGraphqlWithNodeSdkForEachTestArgs = { - mockIpfs: T; -}; - -export const mockDatabasesAndGraphqlWithNodeSdkForEachTest = < - T extends boolean, ->({ - mockIpfs, -}: MockDatabasesAndGraphqlWithNodeSdkForEachTestArgs) => { - const yoga = createYogaInstance({}); - - const { it } = mockDatabasesAndGraphqlForEachTest({ - vitest, - yoga, - mockIpfs, - sdkFactory: ({ url, accessToken, ipfsStorageApiUrl }) => { - const accessTokenService = new StaticAccessTokenService({ accessToken }); - - return new FleekSdk({ - graphqlServiceApiUrl: url, - accessTokenService, - ipfsStorageApiUrl, - }); - }, - sdkConfigs: { - josh: { - auth: { - userId: seeds.auth.user.josh.id, - secret: secrets.SECRET_JWT_IDENTITY, - projectId: seeds.auth.project.electronicCo.id, - }, - }, - }, - }); - - return { it: inferAndCombineItContext(it) }; -}; diff --git a/src/testTools/secrets.ts b/src/testTools/secrets.ts deleted file mode 100644 index a2d1849..0000000 --- a/src/testTools/secrets.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { parseEnvs } from '@fleek-platform/env-guards'; - -export const secrets = parseEnvs([ - 'SECRET_JWT_IDENTITY', // -]);