Skip to content
This repository has been archived by the owner on Jan 19, 2025. It is now read-only.

Commit

Permalink
fix(hotfix): make bluesky sync work; prevent jest to fail
Browse files Browse the repository at this point in the history
  • Loading branch information
louisgrasset committed Nov 28, 2023
1 parent 4296947 commit b6b1044
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
22 changes: 12 additions & 10 deletions meta/testing/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
module.exports = {
// general
rootDir: '../../',
preset: 'ts-jest/presets/default-esm',
modulePaths: ['<rootDir>/src/'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
// coverage
collectCoverageFrom: ["src/**/*.ts", "!**/__tests__/**/*"],
coveragePathIgnorePatterns : [
coveragePathIgnorePatterns: [
"<rootDir>/src/index.ts",
"<rootDir>/src/constants.ts",
"<rootDir>/src/helpers/cache/migrations/index.ts"
],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
modulePaths: ['<rootDir>/src/'],
rootDir: '../../',
// jest
setupFilesAfterEnv: ['<rootDir>/meta/testing/jest.setup.cjs'],
maxWorkers: "50%",
testRegex: '(/__tests__/.*\\.spec)\\.ts?$',
testTimeout: 25000,
preset: "ts-jest/presets/default-esm",
verbose: false,
maxWorkers: "50%",
transform: {
"^.+\\.[tj]s$": "ts-jest"
},
}
};
7 changes: 7 additions & 0 deletions meta/testing/jest.setup.cjs
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
jest.retryTimes(0);

// Mock @atproto/api with the actual implementation to bypass some type errors such as
// TypeError: api_1.default.RichText is not a constructor.

jest.mock("@atproto/api", () => ({
...jest.requireActual("@atproto/api"),
}));
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/helpers/post/make-bluesky-post.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BskyAgent, RichText } from "@atproto/api";
import bsky, { BskyAgent } from "@atproto/api";
import { Tweet } from "@the-convocation/twitter-scraper";

import { BLUESKY_IDENTIFIER } from "../../constants.js";
Expand Down Expand Up @@ -53,7 +53,7 @@ export const makeBlueskyPost = async (
: undefined;
}

const post = new RichText({ text: tweet.text! });
const post = new bsky.RichText({ text: tweet.text! });
await post.detectFacets(client); // automatically detects mentions and links

return {
Expand Down
4 changes: 2 additions & 2 deletions src/services/bluesky-sender.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BskyAgent, RichText } from "@atproto/api";
import bsky, { BskyAgent } from "@atproto/api";
import { Ora } from "ora";

import { DEBUG, VOID } from "../constants.js";
Expand Down Expand Up @@ -110,7 +110,7 @@ export const blueskySenderService = async (
* If the tweet is long, each child chunk will reference the previous one as replyId.
*/
for (const chunk of post.chunks) {
const richText = new RichText({ text: chunk });
const richText = new bsky.RichText({ text: chunk });
await richText.detectFacets(client);

const data: {
Expand Down

0 comments on commit b6b1044

Please sign in to comment.