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

feat: add oembed worker test cases #2960

Merged
merged 2 commits into from
May 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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';
14 changes: 14 additions & 0 deletions tests/packages/workers/oembed/image.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { expect, test } from '@playwright/test';
import { OEMBED_BASE_URL } from 'test/constants';

test('should render image if url is provided', async ({ request }) => {
const getImage = request.get(`${OEMBED_BASE_URL}/image`, {
params: {
hash: 'aHR0cHM6Ly9kaXNjb3JkLmNvbS9hc3NldHMvNjUyZjQwNDI3ZTFmNTE4NmFkNTQ4MzYwNzQ4OTgyNzkucG5n',
transform: 'large'
}
});

const response = await (await getImage).body();
expect(response).toBeTruthy();
});
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'
);
});
Loading