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

Adding lib tests #392

Merged
merged 2 commits into from
Jul 11, 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
28 changes: 28 additions & 0 deletions features/bacom/libs.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
name: 'libs',
features: [
{
tcid: '0',
name: '@libs test',
mapping: [
['https://business.adobe.com', 'https://business.adobe.com/libs'],
['https://business.adobe.com?milolibs=foo', 'https://business.adobe.com/libs'],
['https://business.stage.adobe.com', 'https://main--milo--adobecom.hlx.live/libs'],
['https://business.stage.adobe.com?milolibs=foo', 'https://foo--milo--adobecom.hlx.live/libs'],
['https://business.stage.adobe.com?milolibs=awesome--milo--forkedowner',
'https://awesome--milo--forkedowner.hlx.live/libs'],
['https://main--bacom--adobecom.hlx.page/', 'https://main--milo--adobecom.hlx.live/libs'],
['https://main--bacom--adobecom.hlx.page/?milolibs=foo', 'https://foo--milo--adobecom.hlx.live/libs'],
['https://main--bacom--adobecom.hlx.page/?milolibs=local', 'http://localhost:6456/libs'],
['https://main--bacom--adobecom.hlx.page/?milolibs=awesome--milo--forkedowner',
'https://awesome--milo--forkedowner.hlx.live/libs'],
['https://main--bacom--adobecom.hlx.live/', 'https://main--milo--adobecom.hlx.live/libs'],
['https://main--bacom--adobecom.hlx.live/?milolibs=foo', 'https://foo--milo--adobecom.hlx.live/libs'],
['https://main--bacom--adobecom.hlx.live/?milolibs=local', 'http://localhost:6456/libs'],
['https://main--bacom--adobecom.hlx.live/?milolibs=awesome--milo--forkedowner',
'https://awesome--milo--forkedowner.hlx.live/libs'],
],
tags: '@libs @bacom @smoke @regression',
},
],
};
50 changes: 50 additions & 0 deletions tests/bacom/libs.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { expect, test } from '@playwright/test';
import fs from 'fs';
import { features } from '../../features/bacom/libs.spec.js';

const authFile = './tests/bacom/.auth/user.json';
let context;
let page;

test.describe('Libs test suite', () => {
test.beforeAll(async ({ browser, browserName, headless }) => {
test.skip(browserName !== 'chromium', "Don't need to run on multiple browsers.");

const options = fs.existsSync(authFile) ? { storageState: authFile } : {};
context = await browser.newContext(options);
page = await context.newPage();
await page.goto('https://main--bacom--adobecom.hlx.page/');

if (Object.keys(options).length === 0 && !headless) {
console.log('authFile is empty. Update the authFile by logging into Okta manually and waiting 2 mins.');
test.setTimeout(1000 * 60 * 3);
await page.waitForTimeout(1000 * 60 * 2);
}

await page.waitForLoadState('networkidle');
await context.storageState({ path: authFile });
});

features[0].mapping.forEach((mapping) => {
const url = mapping[0];
const expectedLibs = mapping[1];

test(`Checking libs on ${url}`, { tag: '@libs' }, async () => {
let libs;

await page.route('**/libs/**', (route) => {
if (route.request().url().includes('/libs/utils/utils.js')) {
[libs] = route.request().url().split('/utils/');
route.abort();
} else {
route.continue();
}
});

await page.goto(url);
await page.waitForLoadState('networkidle');

await expect(libs).toBe(expectedLibs);
});
});
});
Loading