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: implemented the dev card OG image #3903

Merged
merged 13 commits into from
Aug 9, 2024
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
24 changes: 22 additions & 2 deletions e2e/user-profile.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from "@playwright/test";
import playwrightConfig from "../playwright.config";
import config from "../playwright.config";

const baseUrl = process.env.NEXT_PUBLIC_BASE_URL ?? playwrightConfig.use?.baseURL ?? "http://localhost:3000";
const baseUrl = process.env.NEXT_PUBLIC_BASE_URL ?? config.use?.baseURL ?? "http://localhost:3000";

test("Loads user profile page", async ({ page }) => {
await page.goto("/u/bdougie");
Expand All @@ -10,6 +10,13 @@ test("Loads user profile page", async ({ page }) => {

await expect(page.getByRole("heading", { name: "bdougie", exact: true })).toBeVisible();

// Check for the OG image
const expectedUrl = `${config.use?.baseURL}/og-images/dev-card?username=bdougie`;

await expect(page.locator('meta[property="og:image"]')).toHaveAttribute("content", expectedUrl);
await expect(page.locator('meta[name="twitter:image"]')).toHaveAttribute("content", expectedUrl);
await expect(page.locator('meta[name="twitter:card"]')).toHaveAttribute("content", "summary_large_image");

// Check for login button for viewing OSCR
await page
.getByRole("button", { name: "Log in to view Open Source Contributor Rating (OSCR)", exact: true })
Expand All @@ -18,6 +25,19 @@ test("Loads user profile page", async ({ page }) => {
await expect(page.url()).toContain("https://github.com/login");
});

test("Loads user dev card page", async ({ page }) => {
await page.goto("/u/bdougie/card");

expect(await page.title()).toBe("bdougie | OpenSauced");

// Check for the OG image
const expectedUrl = `${config.use?.baseURL}/og-images/dev-card?username=bdougie`;

await expect(page.locator('meta[property="og:image"]')).toHaveAttribute("content", expectedUrl);
await expect(page.locator('meta[name="twitter:image"]')).toHaveAttribute("content", expectedUrl);
await expect(page.locator('meta[name="twitter:card"]')).toHaveAttribute("content", "summary_large_image");
});

test("Redirects to user profile page", async ({ page }) => {
await page.goto("/user/bdougie");

Expand Down
3 changes: 0 additions & 3 deletions lib/utils/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ export const isValidUrl = (url: string) => {
*/
export const cardPageUrl = (username: string) => siteUrl(`user/${username}/card`);

export const cardImageUrl = (username: string, opts: { size?: string } = {}) =>
siteUrl(`api/card`, { username, ...opts });

export const twitterCardShareUrl = (username: string) => {
const url = new URL("https://twitter.com/intent/tweet");
url.searchParams.append("text", "Check out my open-source contributions card!");
Expand Down
Loading
Loading