diff --git a/.github/workflows/fg-sync-repos.yml b/.github/workflows/fg-sync-repos.yml index 0d0aa2b..8b83b49 100644 --- a/.github/workflows/fg-sync-repos.yml +++ b/.github/workflows/fg-sync-repos.yml @@ -1,6 +1,10 @@ name: Floodgate Repo Sync on: + push: + branches: + - stage + - main workflow_dispatch: inputs: syncBranch: @@ -28,7 +32,7 @@ jobs: - name: Checkout Repo uses: actions/checkout@v3 with: - ref: ${{ inputs.syncBranch }} + ref: ${{ inputs.syncBranch || github.ref_name }} - name: Clone Floodgate Repository and Checkout Selected Branch run: | @@ -41,7 +45,7 @@ jobs: echo "bacom branch" git branch env: - FG_SYNC_BRANCH: ${{ inputs.syncBranch }} + FG_SYNC_BRANCH: ${{ inputs.syncBranch || github.ref_name }} - name: Overwrite floodgate repo files with latest from source repo run: | @@ -54,14 +58,19 @@ jobs: git branch git config user.email "$FG_SYNC_BOT_EMAIL" git config user.name "$FG_SYNC_BOT_NAME" - git status - git remote set-url origin https://oauth2:$GITHUB_TOKEN@github.com/adobecom/bacom-pink.git - git remote -v - git add . - git commit -m "Syncing bacom to bacom-pink" - git push origin $FG_SYNC_BRANCH --force + git status + if [[ -n $(git status -s) ]]; then + git remote set-url origin https://oauth2:$GITHUB_TOKEN@github.com/adobecom/bacom-pink.git + git remote -v + git add . + git commit -m "Syncing bacom to bacom-pink" + git push origin $FG_SYNC_BRANCH --force + echo ":heavy_check_mark: Syncing branch $FG_SYNC_BRANCH on bacom to bacom-pink completed successfully." >> $GITHUB_STEP_SUMMARY + else + echo ":heavy_minus_sign: No changes detected on branch $FG_SYNC_BRANCH, nothing to sync." >> $GITHUB_STEP_SUMMARY + fi env: GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} FG_SYNC_BOT_EMAIL: ${{ secrets.FG_SYNC_BOT_EMAIL }} FG_SYNC_BOT_NAME: ${{ secrets.FG_SYNC_BOT_NAME }} - FG_SYNC_BRANCH: ${{ inputs.syncBranch }} + FG_SYNC_BRANCH: ${{ inputs.syncBranch || github.ref_name }} diff --git a/.github/workflows/graybox-sync-repos.yml b/.github/workflows/graybox-sync-repos.yml index 2717534..6df44fe 100644 --- a/.github/workflows/graybox-sync-repos.yml +++ b/.github/workflows/graybox-sync-repos.yml @@ -1,6 +1,10 @@ name: Graybox Repo Sync on: + push: + branches: + - stage + - main workflow_dispatch: inputs: syncBranch: @@ -10,6 +14,7 @@ on: type: choice options: - 'stage' + - 'main' jobs: build: @@ -28,7 +33,7 @@ jobs: uses: actions/checkout@v2 with: persist-credentials: false - ref: ${{ inputs.syncBranch }} + ref: ${{ inputs.syncBranch || github.ref_name }} - name: Clone Graybox Repository and Checkout Stage Branch run: | @@ -41,7 +46,7 @@ jobs: echo "bacom branch" git branch env: - GB_SYNC_BRANCH: ${{ inputs.syncBranch }} + GB_SYNC_BRANCH: ${{ inputs.syncBranch || github.ref_name }} - name: Overwrite graybox repo files with latest from source repo run: | @@ -54,13 +59,18 @@ jobs: git branch git config user.email "$FG_SYNC_BOT_EMAIL" git config user.name "milo-repo-sync[bot]" - git status - git remote set-url origin https://oauth2:$GITHUB_TOKEN@github.com/adobecom/bacom-graybox.git - git remote -v - git add . - git commit -m "Syncing bacom to bacom-graybox" - git push origin $GB_SYNC_BRANCH --force + git status + if [[ -n $(git status -s) ]]; then + git remote set-url origin https://oauth2:$GITHUB_TOKEN@github.com/adobecom/bacom-graybox.git + git remote -v + git add . + git commit -m "Syncing bacom to bacom-graybox" + git push origin $GB_SYNC_BRANCH --force + echo ":heavy_check_mark: Syncing branch $GB_SYNC_BRANCH on bacom to bacom-graybox completed successfully." >> $GITHUB_STEP_SUMMARY + else + echo ":heavy_minus_sign: No changes detected on branch $GB_SYNC_BRANCH, nothing to sync." >> $GITHUB_STEP_SUMMARY + fi env: GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} FG_SYNC_BOT_EMAIL: ${{ secrets.FG_SYNC_BOT_EMAIL }} - GB_SYNC_BRANCH: ${{ inputs.syncBranch }} + GB_SYNC_BRANCH: ${{ inputs.syncBranch || github.ref_name }} diff --git a/.github/workflows/run-e2e-daily.yaml b/.github/workflows/run-e2e-daily.yaml new file mode 100644 index 0000000..10251fa --- /dev/null +++ b/.github/workflows/run-e2e-daily.yaml @@ -0,0 +1,36 @@ +name: Bacom E2E Daily Run + +on: + workflow_dispatch: + schedule: + - cron: '0 16 * * *' + +jobs: + platform_matrix: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + name: Running tests on Browserstack + runs-on: ${{ matrix.os }} + env: + WORKFLOW_NAME: 'Bacom E2E Nala Daily Run' + DAILY_RUN: 'true' + + steps: + - name: Check out repository + uses: actions/checkout@v3 + with: + repository: adobecom/nala + ref: main + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: lts/* + + - name: Run Nala ${{ matrix.os }} + run: bash runOnBrowserstack.sh bacom @e2e + env: + BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} + BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} diff --git a/blocks/comparison/comparison.js b/blocks/comparison/comparison.js index 09ffa0b..78e220c 100644 --- a/blocks/comparison/comparison.js +++ b/blocks/comparison/comparison.js @@ -1,10 +1,10 @@ -import { getLibs } from '../../scripts/utils.js'; +import { LIBS } from '../../scripts/scripts.js'; /** * @param {Element} el */ const init = async (el) => { - const { createTag } = await import(`${getLibs()}/utils/utils.js`); + const { createTag } = await import(`${LIBS}/utils/utils.js`); const rows = Array.from(el.querySelectorAll(':scope > div')); const headers = Array.from(rows.shift().children); const headersRow = createTag('tr'); diff --git a/blocks/faas-decode/faas-decode.js b/blocks/faas-decode/faas-decode.js index f6976dc..0224600 100644 --- a/blocks/faas-decode/faas-decode.js +++ b/blocks/faas-decode/faas-decode.js @@ -1,7 +1,7 @@ -import { getLibs } from '../../scripts/utils.js'; +import { LIBS } from '../../scripts/scripts.js'; export default async function init(el) { - const { createTag, parseEncodedConfig } = await import(`${getLibs()}/utils/utils.js`); + const { createTag, parseEncodedConfig } = await import(`${LIBS}/utils/utils.js`); const url = el.querySelector('a')?.href; const resp = await fetch(url); diff --git a/blocks/redirects-formatter/redirects-formatter.js b/blocks/redirects-formatter/redirects-formatter.js index 700da63..f03288d 100644 --- a/blocks/redirects-formatter/redirects-formatter.js +++ b/blocks/redirects-formatter/redirects-formatter.js @@ -1,4 +1,4 @@ -import { getLibs } from '../../scripts/utils.js'; +import { LIBS } from '../../scripts/scripts.js'; export const SELECT_ALL_REGIONS = 'Select All Regions'; export const DESELECT_ALL_REGIONS = 'De-select All Regions'; @@ -12,7 +12,7 @@ const INSTRUCTIONS_TEXT = 'Select the locales you require by checking the checkb + ' press "Copy to clipboard" or select them with the cursor manually.'; async function createLocaleCheckboxes(prefixGroup) { - const { createTag } = await import(`${getLibs()}/utils/utils.js`); + const { createTag } = await import(`${LIBS}/utils/utils.js`); return Object.keys(prefixGroup).map((key) => { const { prefix } = prefixGroup[key]; @@ -87,7 +87,7 @@ export function stringifyListForExcel(urls) { } export default async function init(el) { - const { createTag } = await import(`${getLibs()}/utils/utils.js`); + const { createTag } = await import(`${LIBS}/utils/utils.js`); const xlPath = './locale-config.json'; const resp = await fetch(xlPath); if (!resp.ok) return; diff --git a/blocks/stats/stats.js b/blocks/stats/stats.js index 68055eb..84af4aa 100644 --- a/blocks/stats/stats.js +++ b/blocks/stats/stats.js @@ -1,4 +1,4 @@ -import { getLibs } from '../../scripts/utils.js'; +import { LIBS } from '../../scripts/scripts.js'; async function decorateRow(row, module) { const { decorateLinkAnalytics } = module; @@ -14,8 +14,8 @@ async function decorateRow(row, module) { } export default async function init(el) { - const { createTag } = await import(`${getLibs()}/utils/utils.js`); - const module = await import(`${getLibs()}/martech/attributes.js`); + const { createTag } = await import(`${LIBS}/utils/utils.js`); + const module = await import(`${LIBS}/martech/attributes.js`); module.decorateBlockAnalytics(el); const firstRow = el.querySelector(':scope > div'); diff --git a/blocks/tree-view/tree-view.js b/blocks/tree-view/tree-view.js index 771ac00..385cdb9 100644 --- a/blocks/tree-view/tree-view.js +++ b/blocks/tree-view/tree-view.js @@ -1,4 +1,4 @@ -import { getLibs } from '../../scripts/utils.js'; +import { LIBS } from '../../scripts/scripts.js'; const BACOM_HOSTS = ['localhost', '--bacom--adobecom.hlx.page', '--bacom--adobecom.hlx.live', 'business.adobe.com']; @@ -110,7 +110,7 @@ const init = async (el) => { if (!topList) return; - const { createTag } = await import(`${getLibs()}/utils/utils.js`); + const { createTag } = await import(`${LIBS}/utils/utils.js`); const subLists = topList.querySelectorAll('ul'); const isAccordion = subLists.length > 0; const links = el.querySelectorAll('a'); diff --git a/blocks/workfront-login/workfront-login.js b/blocks/workfront-login/workfront-login.js index 6c6d0c1..1b7ceda 100644 --- a/blocks/workfront-login/workfront-login.js +++ b/blocks/workfront-login/workfront-login.js @@ -1,4 +1,4 @@ -import { getLibs } from '../../scripts/utils.js'; +import { LIBS } from '../../scripts/scripts.js'; export async function createProofForm(createTag, replaceKey, config) { const form = createTag('form', { action: 'https://app.proofhq.com/login', method: 'post' }); @@ -105,8 +105,8 @@ export async function createSubdomainForm(createTag, replaceKey, config) { /* c8 ignore next 14 */ export default async function init(el) { - const { createTag, getConfig } = await import(`${getLibs()}/utils/utils.js`); - const { replaceKey } = await import(`${getLibs()}/features/placeholders.js`); + const { createTag, getConfig } = await import(`${LIBS}/utils/utils.js`); + const { replaceKey } = await import(`${LIBS}/features/placeholders.js`); const config = getConfig(); const isProof = el.classList.contains('proof'); diff --git a/head.html b/head.html index e1fb9ec..89f84b8 100644 --- a/head.html +++ b/head.html @@ -1,4 +1,32 @@ + + diff --git a/helix-query.yaml b/helix-query.yaml index 3db6545..5579faa 100644 --- a/helix-query.yaml +++ b/helix-query.yaml @@ -33,6 +33,14 @@ indices: select: head > meta[name="publishdate"] value: | attribute(el, 'content') + caas-url: + select: .columns div div a[href*="/tools/caas"], .text div div a[href*="/tools/caas"] + value: | + attribute(el, 'href') + marketo-url: + select: .marketo div div a[href*="/tools/marketo"] + value: | + attribute(el, 'href') sitemap-ae_ar: include: - '/ae_ar/' @@ -1742,6 +1750,6 @@ indices: properties: <<: *defaultProps faas-url: - select: .columns div div a, .text div div a + select: .columns div div a[href*="/tools/faas"], .text div div a[href*="/tools/faas"] value: | attribute(el, 'href') diff --git a/helix-sitemap.yaml b/helix-sitemap.yaml index 659c964..9e262bc 100644 --- a/helix-sitemap.yaml +++ b/helix-sitemap.yaml @@ -105,7 +105,7 @@ sitemaps: source: /in/query-index.json alternate: /in/{path}.html destination: /in/sitemap.xml - hreflang: en-GB + hreflang: en-IN in_hi: source: /in_hi/query-index.json alternate: /in_hi/{path}.html diff --git a/scripts/aa-university.js b/scripts/aa-university.js index 85488df..1706691 100644 --- a/scripts/aa-university.js +++ b/scripts/aa-university.js @@ -3,16 +3,23 @@ export default function registerAAUniversity() { const lastName = document.querySelector('input[name="LastName"]'); const email = document.querySelector('input[name="Email"]'); const country = document.querySelector('select[name="Country"]'); + const group = document.querySelector('meta[name="sandboxgroup"]'); + + const postBody = { + first_name: firstName?.value, + last_name: lastName?.value, + email: email?.value, + university: 'none', + country: country?.value, + }; + + if (group) postBody.group = group.content; fetch('https://us-central1-adobe---aa-university.cloudfunctions.net/register', { method: 'POST', - body: JSON.stringify({ - first_name: firstName?.value, - last_name: lastName?.value, - email: email?.value, - university: 'none', - country: country?.value, - }), + body: JSON.stringify(postBody), }) .catch((error) => window.lana.log(`Marketo AA University Error: ${error}`)); + + return postBody; } diff --git a/scripts/scripts.js b/scripts/scripts.js index 7710595..0cd25d8 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -1,6 +1,3 @@ -import { setLibs } from './utils.js'; - -const LIBS = '/libs'; const STYLES = ['/styles/styles.css']; const CONFIG = { imsClientId: 'bacom', @@ -68,7 +65,7 @@ const CONFIG = { il_en: { ietf: 'en-IL', tk: 'hah7vzn.css' }, il_he: { ietf: 'he', tk: 'qxw8hzm.css', dir: 'rtl' }, in_hi: { ietf: 'hi', tk: 'qxw8hzm.css' }, - in: { ietf: 'en-GB', tk: 'hah7vzn.css' }, + in: { ietf: 'en-IN', tk: 'hah7vzn.css' }, it: { ietf: 'it-IT', tk: 'hah7vzn.css' }, jp: { ietf: 'ja-JP', tk: 'dvg6awq' }, kr: { ietf: 'ko-KR', tk: 'qjs5sfm' }, @@ -120,15 +117,6 @@ const CONFIG = { geoRouting: 'on', productionDomain: 'business.adobe.com', prodDomains: ['business.adobe.com', 'www.adobe.com'], - stageDomainsMap: { - 'business.adobe.com': 'business.stage.adobe.com', - 'www.adobe.com': 'www.stage.adobe.com', - 'learning.adobe.com': 'learning.stage.adobe.com', - 'solutionpartners.adobe.com': 'solutionpartners.stage.adobe.com', - 'news.adobe.com': 'news.stage.adobe.com', - 'adobe.io': 'stage.adobe.io', - 'developer.adobe.com': 'developer-stage.adobe.com', - }, autoBlocks: [ { iframe: 'https://adobe-ideacloud.forgedx.com' }, { iframe: 'https://adobe.ideacloud.com' }, @@ -177,10 +165,18 @@ const loadStyle = (path) => { eagerLoad(marquee.querySelector('img')); }()); -const miloLibs = setLibs(LIBS); +export function setLibs(location) { + const { hostname, search } = location; + if (!['.hlx.', '.stage.', 'local'].some((i) => hostname.includes(i))) return '/libs'; + const branch = new URLSearchParams(search).get('milolibs') || 'main'; + if (branch === 'local') return 'http://localhost:6456/libs'; + return branch.includes('--') ? `https://${branch}.hlx.live/libs` : `https://${branch}--milo--adobecom.hlx.live/libs`; +} + +export const LIBS = setLibs(window.location); (function loadStyles() { - const paths = [`${miloLibs}/styles/styles.css`]; + const paths = [`${LIBS}/styles/styles.css`]; if (STYLES) { paths.push(...(Array.isArray(STYLES) ? STYLES : [STYLES])); } @@ -188,7 +184,7 @@ const miloLibs = setLibs(LIBS); }()); (async function loadPage() { - const { loadArea, loadLana, setConfig, createTag, getMetadata } = await import(`${miloLibs}/utils/utils.js`); + const { loadArea, loadLana, setConfig, createTag, getMetadata } = await import(`${LIBS}/utils/utils.js`); if (getMetadata('template') === '404') window.SAMPLE_PAGEVIEWS_AT_RATE = 'high'; const metaCta = document.querySelector('meta[name="chat-cta"]'); if (metaCta && !document.querySelector('.chat-cta')) { @@ -199,7 +195,7 @@ const miloLibs = setLibs(LIBS); if (lastSection) lastSection.insertAdjacentElement('beforeend', chatDiv); } } - setConfig({ ...CONFIG, miloLibs }); + setConfig({ ...CONFIG, miloLibs: LIBS }); loadLana({ clientId: 'bacom', tags: 'info' }); await loadArea(); @@ -210,4 +206,10 @@ const miloLibs = setLibs(LIBS); if (document.querySelector('.faas')) { loadStyle('/styles/faas.css'); } + const observer = new PerformanceObserver((list) => { + list.getEntries().forEach((entry) => { + if (entry.responseStatus === 404) window.lana?.log(`The resource ${entry.name} returned a 404 status.`, { tags: 'errorType=error,module=resource-404' }); + }); + }); + observer.observe({ type: 'resource', buffered: true }); }()); diff --git a/scripts/utils.js b/scripts/utils.js deleted file mode 100644 index bd9f037..0000000 --- a/scripts/utils.js +++ /dev/null @@ -1,15 +0,0 @@ -export const [setLibs, getLibs] = (() => { - let libs; - return [ - (prodLibs, location) => { - libs = (() => { - const { hostname, search } = location || window.location; - if (!['.hlx.', '.stage.', 'local'].some((i) => hostname.includes(i))) return prodLibs; - const branch = new URLSearchParams(search).get('milolibs') || 'main'; - if (branch === 'local') return 'http://localhost:6456/libs'; - return branch.includes('--') ? `https://${branch}.hlx.live/libs` : `https://${branch}--milo--adobecom.hlx.live/libs`; - })(); - return libs; - }, () => libs, - ]; -})(); diff --git a/templates/featured-story/featured-story.js b/templates/featured-story/featured-story.js index 5a6c596..6e463d0 100644 --- a/templates/featured-story/featured-story.js +++ b/templates/featured-story/featured-story.js @@ -2,9 +2,9 @@ Templates - featured story */ -import { getLibs } from '../../scripts/utils.js'; +import { LIBS } from '../../scripts/scripts.js'; -const { createTag } = await import(`${getLibs()}/utils/utils.js`); +const { createTag } = await import(`${LIBS}/utils/utils.js`); function init() { const i = 1; diff --git a/test/blocks/comparison/comparison.test.js b/test/blocks/comparison/comparison.test.js index a19a25f..40771e9 100644 --- a/test/blocks/comparison/comparison.test.js +++ b/test/blocks/comparison/comparison.test.js @@ -1,9 +1,7 @@ import { readFile } from '@web/test-runner-commands'; import { expect } from '@esm-bundle/chai'; import init from '../../../blocks/comparison/comparison.js'; -import { setLibs } from '../../../scripts/utils.js'; -setLibs('/libs'); document.body.innerHTML = await readFile({ path: './mocks/body.html' }); describe('Comparison Table', () => { it('Verify Comparison Table Exists', async () => { diff --git a/test/blocks/faas-decode/faas-decode.test.js b/test/blocks/faas-decode/faas-decode.test.js index e643aff..7d31a01 100644 --- a/test/blocks/faas-decode/faas-decode.test.js +++ b/test/blocks/faas-decode/faas-decode.test.js @@ -1,7 +1,6 @@ import { expect } from '@esm-bundle/chai'; import sinon from 'sinon'; import init from '../../../blocks/faas-decode/faas-decode.js'; -import { setLibs } from '../../../scripts/utils.js'; import waitForElement from '../../helpers/waitForElement.js'; window.lana = { log: () => {} }; @@ -9,7 +8,6 @@ window.lana = { log: () => {} }; describe('FaaS Decode', () => { before(() => { sinon.stub(window.lana, 'log'); - setLibs('/libs'); }); after(() => { diff --git a/test/blocks/redirects-formatter/redirects-formatter.test.js b/test/blocks/redirects-formatter/redirects-formatter.test.js index 9077128..ac9002a 100644 --- a/test/blocks/redirects-formatter/redirects-formatter.test.js +++ b/test/blocks/redirects-formatter/redirects-formatter.test.js @@ -1,7 +1,6 @@ import { readFile } from '@web/test-runner-commands'; import { expect } from '@esm-bundle/chai'; import sinon from 'sinon'; -import { setLibs } from '../../../scripts/utils.js'; const { default: init, @@ -14,8 +13,6 @@ const { } = await import('../../../blocks/redirects-formatter/redirects-formatter.js'); const { htmlIncluded, htmlExcluded, externalUrls, mixedSpaceTabUrls } = await import('./mocks/textAreaValues.js'); -setLibs('libs'); - describe('Redirects Formatter', () => { const ogFetch = window.fetch; diff --git a/test/blocks/stats/stats.test.js b/test/blocks/stats/stats.test.js index 0179ce3..9905012 100644 --- a/test/blocks/stats/stats.test.js +++ b/test/blocks/stats/stats.test.js @@ -1,10 +1,7 @@ import { expect } from '@esm-bundle/chai'; -import { setLibs } from '../../../scripts/utils.js'; const { default: init } = await import('../../../blocks/stats/stats.js'); -setLibs('libs'); - describe('Stats', () => { it('Allows intro', async () => { document.body.innerHTML = '
Intro
Stat 1
Stat 2
'; diff --git a/test/blocks/tree-view/tree-view.test.js b/test/blocks/tree-view/tree-view.test.js index 428284a..bd3abfe 100644 --- a/test/blocks/tree-view/tree-view.test.js +++ b/test/blocks/tree-view/tree-view.test.js @@ -1,12 +1,10 @@ import { readFile } from '@web/test-runner-commands'; import { expect } from '@esm-bundle/chai'; import sinon from 'sinon'; -import { setLibs } from '../../../scripts/utils.js'; const { default: init, isCurrentPage } = await import('../../../blocks/tree-view/tree-view.js'); window.lana = { log: () => {} }; -setLibs('libs'); describe('Tree View', () => { describe('simple', () => { diff --git a/test/blocks/workfront-login/workfront.test.js b/test/blocks/workfront-login/workfront.test.js index 25f5ef5..11511b5 100644 --- a/test/blocks/workfront-login/workfront.test.js +++ b/test/blocks/workfront-login/workfront.test.js @@ -1,12 +1,9 @@ import { expect } from '@esm-bundle/chai'; import sinon from 'sinon'; import waitForElement from '../../helpers/waitForElement.js'; -import { setLibs } from '../../../scripts/utils.js'; import { createTag, replaceKey, getConfig } from './mocks/workfront-utils.js'; import { createSubdomainForm, createProofForm, location } from '../../../blocks/workfront-login/workfront-login.js'; -setLibs('libs'); - const config = getConfig(); const delay = (timeOut, cb) => new Promise((resolve) => { diff --git a/test/scripts/aa-university.test.js b/test/scripts/aa-university.test.js index 976ab04..272d82e 100644 --- a/test/scripts/aa-university.test.js +++ b/test/scripts/aa-university.test.js @@ -29,4 +29,20 @@ describe('AA University', async () => { window.fetch = ogFetch; window.lana = ogLana; }); + + it('Sends the group parameter with POST if found', () => { + const meta = document.createElement('meta'); + meta.setAttribute('name', 'sandboxgroup'); + meta.setAttribute('content', 'group'); + document.body.prepend(meta); + const body = registerAAUniversity(); + expect(body.group).to.equal('group'); + + document.querySelector('meta').remove(); + }); + + it('Does not send the group parameter with POST if not found', () => { + const body = registerAAUniversity(); + expect(body.group).to.be.undefined; + }); }); diff --git a/test/scripts/scripts.test.js b/test/scripts/scripts.test.js new file mode 100644 index 0000000..3c75c51 --- /dev/null +++ b/test/scripts/scripts.test.js @@ -0,0 +1,36 @@ +import { expect } from '@esm-bundle/chai'; +import { setLibs, LIBS } from '../../scripts/scripts.js'; + +describe('Libs', () => { + const tests = [ + ['https://business.adobe.com', '/libs'], + ['https://business.adobe.com?milolibs=foo', '/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'], + ['http://localhost:3000', 'https://main--milo--adobecom.hlx.live/libs'], + ['http://localhost:3000?milolibs=foo', 'https://foo--milo--adobecom.hlx.live/libs'], + ['http://localhost:3000?milolibs=local', 'http://localhost:6456/libs'], + ['http://localhost:3000?milolibs=awesome--milo--forkedowner', 'https://awesome--milo--forkedowner.hlx.live/libs'], + ]; + + tests.forEach(([url, expected]) => { + it(`Sets libs for ${url}`, () => { + const location = new URL(url); + const libs = setLibs(location); + expect(libs).to.equal(expected); + }); + }); + + it('Sets LIBS', () => { + expect(LIBS).to.equal('https://main--milo--adobecom.hlx.live/libs'); + }); +}); diff --git a/test/scripts/utils.test.js b/test/scripts/utils.test.js deleted file mode 100644 index eb6cd39..0000000 --- a/test/scripts/utils.test.js +++ /dev/null @@ -1,45 +0,0 @@ -import { expect } from '@esm-bundle/chai'; -import { setLibs } from '../../scripts/utils.js'; - -describe('Libs', () => { - it('Sets 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'); - }); -});