Skip to content

Commit

Permalink
feat: add oembed worker test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint committed May 27, 2023
1 parent 3096031 commit 5ba3903
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ export const PRERENDER_BASE_URL = isNightly
export const METADATA_BASE_URL = isNightly
? 'https://metadata.lenster.xyz'
: 'http://localhost:8083';
export const OEMBED_BASE_URL = isNightly
? 'https://oembed.lenster.xyz'
: 'http://localhost:8087';
41 changes: 41 additions & 0 deletions tests/packages/workers/oembed/oembed.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { expect, test } from '@playwright/test';
import { OEMBED_BASE_URL } from 'test/constants';

test('should return false if payload is not provided', async ({ request }) => {
const getOembed = request.get(OEMBED_BASE_URL, {});
const response = await (await getOembed).json();

expect(response.success).toBeFalsy();
});

test('should return valid oembed response if url is provided', async ({
request
}) => {
const url = 'https://github.com/lensterxyz/lenster';
const getOembed = request.get(OEMBED_BASE_URL, { params: { url } });
const response = await (await getOembed).json();

expect(response.success).toBeTruthy();
expect(response.oembed.url).toBe(url);
expect(response.oembed.title).toContain('GitHub - lensterxyz/lenster');
expect(response.oembed.description).toContain(
'Lenster is a decentralized and permissionless social media app'
);
expect(response.oembed.image).toContain('transform=large');
expect(response.oembed.site).toBe('GitHub');
expect(response.oembed.isLarge).toBeTruthy();
expect(response.oembed.html).toBeNull();
});

test('should return valid oembed response if url supports iframe is provided', async ({
request
}) => {
const url = 'https://www.youtube.com/watch?v=H5v3kku4y6Q';
const getOembed = request.get(OEMBED_BASE_URL, { params: { url } });
const response = await (await getOembed).json();

expect(response.success).toBeTruthy();
expect(response.oembed.html).toContain(
'https://www.youtube.com/embed/H5v3kku4y6Q'
);
});

0 comments on commit 5ba3903

Please sign in to comment.