summaryrefslogtreecommitdiff
path: root/packages/backend/test
diff options
context:
space:
mode:
Diffstat (limited to 'packages/backend/test')
-rw-r--r--packages/backend/test/e2e/oauth.ts10
-rw-r--r--packages/backend/test/utils.ts7
2 files changed, 9 insertions, 8 deletions
diff --git a/packages/backend/test/e2e/oauth.ts b/packages/backend/test/e2e/oauth.ts
index 7434701e67..47851e9474 100644
--- a/packages/backend/test/e2e/oauth.ts
+++ b/packages/backend/test/e2e/oauth.ts
@@ -19,7 +19,7 @@ import {
ResourceOwnerPassword,
} from 'simple-oauth2';
import pkceChallenge from 'pkce-challenge';
-import { JSDOM } from 'jsdom';
+import { load as cheerio } from 'cheerio';
import Fastify, { type FastifyInstance, type FastifyReply } from 'fastify';
import { api, port, sendEnvUpdateRequest, signup } from '../utils.js';
import type * as misskey from 'misskey-js';
@@ -73,11 +73,11 @@ const clientConfig: ModuleOptions<'client_id'> = {
};
function getMeta(html: string): { transactionId: string | undefined, clientName: string | undefined, clientLogo: string | undefined } {
- const fragment = JSDOM.fragment(html);
+ const fragment = cheerio(html);
return {
- transactionId: fragment.querySelector<HTMLMetaElement>('meta[name="misskey:oauth:transaction-id"]')?.content,
- clientName: fragment.querySelector<HTMLMetaElement>('meta[name="misskey:oauth:client-name"]')?.content,
- clientLogo: fragment.querySelector<HTMLMetaElement>('meta[name="misskey:oauth:client-logo"]')?.content,
+ transactionId: fragment('meta[name="misskey:oauth:transaction-id"][content]').attr('content'),
+ clientName: fragment('meta[name="misskey:oauth:client-name"][content]').attr('content'),
+ clientLogo: fragment('meta[name="misskey:oauth:client-logo"][content]').attr('content'),
};
}
diff --git a/packages/backend/test/utils.ts b/packages/backend/test/utils.ts
index 7b69cb04f4..7f2768488f 100644
--- a/packages/backend/test/utils.ts
+++ b/packages/backend/test/utils.ts
@@ -11,11 +11,12 @@ import { inspect } from 'node:util';
import WebSocket, { ClientOptions } from 'ws';
import fetch, { File, RequestInit, type Headers } from 'node-fetch';
import { DataSource } from 'typeorm';
-import { JSDOM } from 'jsdom';
+import { load as cheerio } from 'cheerio';
import { type Response } from 'node-fetch';
import Fastify from 'fastify';
import { entities } from '../src/postgres.js';
import { loadConfig } from '../src/config.js';
+import type { CheerioAPI } from 'cheerio';
import type * as misskey from 'misskey-js';
import { DEFAULT_POLICIES } from '@/core/RoleService.js';
import { validateContentTypeSetAsActivityPub } from '@/core/activitypub/misc/validator.js';
@@ -464,7 +465,7 @@ export function makeStreamCatcher<T>(
export type SimpleGetResponse = {
status: number,
- body: any | JSDOM | null,
+ body: any | CheerioAPI | null,
type: string | null,
location: string | null
};
@@ -495,7 +496,7 @@ export const simpleGet = async (path: string, accept = '*/*', cookie: any = unde
const body =
jsonTypes.includes(res.headers.get('content-type') ?? '') ? await res.json() :
- htmlTypes.includes(res.headers.get('content-type') ?? '') ? new JSDOM(await res.text()) :
+ htmlTypes.includes(res.headers.get('content-type') ?? '') ? cheerio(await res.text()) :
await bodyExtractor(res);
return {