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

DEV-155887 | Prebid - create testing env #38

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
},
"devDependencies": {
"@babel/eslint-parser": "^7.16.5",
"@playwright/test": "^1.44.1",
"@wdio/browserstack-service": "^8.29.0",
"@wdio/cli": "^8.29.0",
"@wdio/concise-reporter": "^8.29.0",
Expand Down Expand Up @@ -104,6 +105,7 @@
"morgan": "^1.10.0",
"node-html-parser": "^6.1.5",
"opn": "^5.4.0",
"playwright": "^1.44.1",
"resolve-from": "^5.0.0",
"sinon": "^4.1.3",
"through2": "^4.0.2",
Expand Down
79 changes: 79 additions & 0 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// @ts-check
const { defineConfig, devices } = require('@playwright/test');

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* @see https://playwright.dev/docs/test-configuration
*/
module.exports = defineConfig({
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});

42 changes: 42 additions & 0 deletions tests/prebid.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const {test, expect} = require('@playwright/test');

test('win events', async ({page}) => {

// Set up a listener for network requests
let networkEventFound = false;
let requestUrl = '';
let responseStatus = null;

page.on('request', (request) => {
if (request.url().includes('recommendations.notify-win-nurl')) {
networkEventFound = true;
requestUrl = request.url();
}
});

page.on('response', async (response) => {
if (response.url().includes('recommendations.notify-win-nurl')) {
responseStatus = response.status();
}
});

// Navigate to the URL
await page.goto('http://prebid.audex.svc.kube.taboolasyndication.com:9999/integrationExamples/gpt/hello_world.html');

// Wait for some time to ensure all network requests are captured
await page.waitForTimeout(5000); // Wait for 5 seconds or adjust as needed

// Check if the network event was found and its status
if (networkEventFound) {
if (responseStatus !== null) {
console.log(`Network event with "recommendations.notify-win-nurl" found Status: ${responseStatus}`);
await expect(responseStatus).toEqual(204);
} else {
console.log('Network event with "recommendations.notify-win-nurl" found, but no response status captured.');
}
} else {
console.log('Network event with "recommendations.notify-win-nurl" not found.');
}

});