-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MWPW-134706 Reevaluate bacom-blog repo
- Loading branch information
Showing
11 changed files
with
2,415 additions
and
7,021 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
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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,45 @@ | ||
import { expect } from '@esm-bundle/chai'; | ||
import { setLibs } from '../../scripts/utils.js'; | ||
|
||
describe('Libs', () => { | ||
it('Default Libs', () => { | ||
const libs = setLibs('/libs'); | ||
expect(libs).to.equal('https://main--milo--adobecom.hlx.live/libs'); | ||
}); | ||
|
||
it('Does not support milolibs query param on prod', () => { | ||
const location = { | ||
hostname: 'business.adobe.com', | ||
search: '?milolibs=foo', | ||
}; | ||
const libs = setLibs('/libs', location); | ||
expect(libs).to.equal('/libs'); | ||
}); | ||
|
||
it('Supports milolibs query param', () => { | ||
const location = { | ||
hostname: 'localhost', | ||
search: '?milolibs=foo', | ||
}; | ||
const libs = setLibs('/libs', location); | ||
expect(libs).to.equal('https://foo--milo--adobecom.hlx.live/libs'); | ||
}); | ||
|
||
it('Supports local milolibs query param', () => { | ||
const location = { | ||
hostname: 'localhost', | ||
search: '?milolibs=local', | ||
}; | ||
const libs = setLibs('/libs', location); | ||
expect(libs).to.equal('http://localhost:6456/libs'); | ||
}); | ||
|
||
it('Supports forked milolibs query param', () => { | ||
const location = { | ||
hostname: 'localhost', | ||
search: '?milolibs=awesome--milo--forkedowner', | ||
}; | ||
const libs = setLibs('/libs', location); | ||
expect(libs).to.equal('https://awesome--milo--forkedowner.hlx.live/libs'); | ||
}); | ||
}); |
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
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,79 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import { importMapsPlugin } from '@web/dev-server-import-maps'; | ||
import { defaultReporter } from '@web/test-runner'; | ||
|
||
function customReporter() { | ||
return { | ||
async reportTestFileResults({ logger, sessionsForTestFile }) { | ||
sessionsForTestFile.forEach((session) => { | ||
session.testResults.tests.forEach((test) => { | ||
if (!test.passed && !test.skipped) { | ||
logger.log(test); | ||
} | ||
}); | ||
}); | ||
}, | ||
}; | ||
} | ||
export default { | ||
coverageConfig: { | ||
exclude: [ | ||
'**/mocks/**', | ||
'**/node_modules/**', | ||
'**/test/**', | ||
'**/deps/**', | ||
], | ||
}, | ||
plugins: [importMapsPlugin({})], | ||
reporters: [ | ||
defaultReporter({ reportTestResults: true, reportTestProgress: true }), | ||
customReporter(), | ||
], | ||
testRunnerHtml: (testFramework) => ` | ||
<html> | ||
<head> | ||
<script type='module'> | ||
const oldFetch = window.fetch; | ||
window.fetch = async (resource, options) => { | ||
if (!resource.startsWith('/') && !resource.startsWith('http://localhost')) { | ||
console.error( | ||
'** fetch request for an external resource is disallowed in unit tests, please find a way to mock! https://github.com/orgs/adobecom/discussions/814#discussioncomment-6060759 provides guidance on how to fix the issue.', | ||
resource | ||
); | ||
} | ||
return oldFetch.call(window, resource, options); | ||
}; | ||
const oldXHROpen = XMLHttpRequest.prototype.open; | ||
XMLHttpRequest.prototype.open = async function (...args) { | ||
let [method, url, asyn] = args; | ||
if (!resource.startsWith('/') && url.startsWith('http://localhost')) { | ||
console.error( | ||
'** XMLHttpRequest request for an external resource is disallowed in unit tests, please find a way to mock! https://github.com/orgs/adobecom/discussions/814#discussioncomment-6060759 provides guidance on how to fix the issue.', | ||
url | ||
); | ||
} | ||
return oldXHROpen.apply(this, args); | ||
}; | ||
const observer = new MutationObserver((mutationsList, observer) => { | ||
for(let mutation of mutationsList) { | ||
if (mutation.type === 'childList') { | ||
for(let node of mutation.addedNodes) { | ||
if(node.nodeName === 'SCRIPT' && node.src && !node.src.startsWith('http://localhost')) { | ||
console.error( | ||
'** An external 3rd script has been added. This is disallowed in unit tests, please find a way to mock! https://github.com/orgs/adobecom/discussions/814#discussioncomment-6060891 provides guidance on how to fix the issue.', | ||
node.src | ||
); | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
observer.observe(document.head, { childList: true }); | ||
</script> | ||
</head> | ||
<body> | ||
<script type='module' src='${testFramework}'></script> | ||
</body> | ||
</html>`, | ||
}; |
This file was deleted.
Oops, something went wrong.