feat : remove admin bypass ads
This commit is contained in:
@@ -1,21 +1,9 @@
|
||||
"use client";
|
||||
|
||||
import Script from "next/script";
|
||||
|
||||
import { authClient } from "@/lib/auth/client";
|
||||
|
||||
const clientId = process.env.NEXT_PUBLIC_GOOGLE_ADSENSE_CLIENT_ID?.trim();
|
||||
|
||||
export function GoogleAdsense() {
|
||||
const { data: session, error, isPending } = authClient.useSession();
|
||||
|
||||
if (
|
||||
process.env.NODE_ENV !== "production" ||
|
||||
!clientId ||
|
||||
isPending ||
|
||||
error ||
|
||||
session
|
||||
) {
|
||||
if (process.env.NODE_ENV !== "production" || !clientId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ describe("public rendering performance", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("loads AdSense only after confirming the visitor is signed out", async () => {
|
||||
it("loads AdSense for every visitor, including signed-in admins", async () => {
|
||||
const [adsense, home, guide, guideSection, adsTxt] = await Promise.all([
|
||||
repositoryFile("components/public/google-adsense.tsx"),
|
||||
repositoryFile("app/page.tsx"),
|
||||
@@ -68,9 +68,9 @@ describe("public rendering performance", () => {
|
||||
repositoryFile("public/ads.txt"),
|
||||
]);
|
||||
|
||||
expect(adsense).toContain("authClient.useSession()");
|
||||
expect(adsense).not.toContain("authClient.useSession()");
|
||||
expect(adsense).not.toContain('from "@/lib/auth/client"');
|
||||
expect(adsense).toContain('process.env.NODE_ENV !== "production"');
|
||||
expect(adsense).toMatch(/isPending \|\|\s+error \|\|\s+session/u);
|
||||
expect(adsense).toContain("pagead2.googlesyndication.com");
|
||||
expect(home).toContain("<GoogleAdsense />");
|
||||
expect(guide).toContain("<GoogleAdsense />");
|
||||
|
||||
Reference in New Issue
Block a user