-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dennis Li
committed
Jul 11, 2024
1 parent
0dad656
commit abc4559
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
}); |