Skip to content

Commit

Permalink
Merge pull request #241 from adobecom/stage
Browse files Browse the repository at this point in the history
[Release] Stage to Main
  • Loading branch information
JasonHowellSlavin authored Sep 10, 2024
2 parents 0ea5679 + 229705f commit 3945fbd
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 7 deletions.
28 changes: 28 additions & 0 deletions head.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="preload" href="/styles/styles.css" as="style"/>
<script>
const libs = (() => {
const { hostname, search } = window.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`;
})();

const miloStyles = document.createElement('link');
const miloUtils = document.createElement('link');
const miloDecorate = document.createElement('link');

miloStyles.setAttribute('as', 'style');
miloStyles.setAttribute('href', `${libs}/styles/styles.css`);

[miloUtils, miloDecorate].forEach((tag) => {
tag.setAttribute('crossorigin', 'true');
tag.setAttribute('as', 'script');
})

miloUtils.setAttribute('href', `${libs}/utils/utils.js`);
miloDecorate.setAttribute('href', `${libs}/utils/decorate.js`);

[miloStyles, miloUtils, miloDecorate].forEach((tag) => tag.setAttribute('rel', 'preload'));
document.head.append(miloStyles, miloUtils, miloDecorate);
</script>
<script src="/scripts/scripts.js" type="module"></script>
<style>body { display: none; }</style>
<link rel="icon" href="data:,">
21 changes: 14 additions & 7 deletions scripts/aa-university.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
16 changes: 16 additions & 0 deletions test/scripts/aa-university.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});

0 comments on commit 3945fbd

Please sign in to comment.