Skip to content

Commit

Permalink
Fied integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
negyxo committed Nov 22, 2023
1 parent 007bf5d commit f931eae
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions integration-tests/playwright-test/tests/rum.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,39 @@ const COUNTRY = "US"; //country (c)
const APP_VERSION = "v1.0.0"; //app version(v)
const HT = true; //CacheHit (ht)



test.describe("RUM - Request data", () => {
let page: Page;
let RumRequest: any;
let RumRequestBody: any;


//catch Rum request and save it
test.beforeAll(async ({ baseURL }) => {
const browser = await chromium.launch();
page = await browser.newPage();

await page.setViewportSize({width: WIDTH, height: HEIGHT});

const promiseRumRequest = new Promise((resolve, reject) => {
page.goto(baseURL || "");


const promiseRumRequest = new Promise((resolve, reject) => {
//check if RUM request was sent
page.on('request', request => {
if (request.url().startsWith("https://rum.ingress.edgio.net/v1/")) {
resolve(request);
}
});

// when page is loaded, set visibilityState to hidden, so we can trigger
// RUM to send request
page.goto(baseURL || "").then(() => {
page.evaluate(() => {
Object.defineProperty(document, 'visibilityState', { value: 'hidden', writable: true })
Object.defineProperty(document, 'hidden', { value: true, writable: true })
window.dispatchEvent(new Event('visibilitychange'))
})
})
});

await page.setViewportSize({width: WIDTH, height: HEIGHT});

// console.debug("Waiting for Rum request")
RumRequest = await promiseRumRequest
Expand Down

0 comments on commit f931eae

Please sign in to comment.