Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import { expect, test } from "@playwright/test";
import { expect, test, type Page } from "@playwright/test";
import { runtimeUrl } from "../../helpers/state.js";

const RUNNER_URL = "https://client.aps.amazon-adsystem.com/prebid-creative.js";
Expand All @@ -19,9 +19,34 @@ function clientAuctionBundlePaths() {
core: resolve(TSJS_CRATE, "dist/tsjs-core.js"),
gpt: resolve(TSJS_CRATE, "dist/tsjs-gpt.js"),
prebid: resolve(TSJS_CRATE, "dist/prebid", manifest.filename),
shim: resolve(TSJS_CRATE, "dist/tsjs-prebid.js"),
};
}

/**
* Load the client auction scripts in the order the server serves them.
*
* A coupled external bundle ships Prebid.js with the tsjs shim (and the
* trustedServer adapter) already installed. A decoupled external bundle is
* pure Prebid.js and stamps its manifest on `window.__tsjs_prebid_bundle`;
* the shim then arrives as the separately served deferred tsjs module, so
* this helper loads it whenever the stamp is present.
*/
async function loadClientAuctionBundles(page: Page): Promise<void> {
const bundles = clientAuctionBundlePaths();
await page.addScriptTag({ path: bundles.gpt });
await page.addScriptTag({ path: bundles.prebid });
const decoupledBundle = await page.evaluate(() =>
Boolean(
(window as unknown as { __tsjs_prebid_bundle?: unknown })
.__tsjs_prebid_bundle,
),
);
if (decoupledBundle) {
await page.addScriptTag({ path: bundles.shim });
}
}

function descriptor(
tagType: "iframe" | "script",
creativeUrl = tagType === "iframe"
Expand Down Expand Up @@ -211,9 +236,7 @@ test.describe("APS opaque renderer", () => {
});

await page.goto(runtimeUrl("/aps-prebid-adapter-test"));
const bundles = clientAuctionBundlePaths();
await page.addScriptTag({ path: bundles.gpt });
await page.addScriptTag({ path: bundles.prebid });
await loadClientAuctionBundles(page);

const result = await page.evaluate(async () => {
type PrebidBid = {
Expand Down
Loading