From 6a46c951bce275f7cdc3df6b053039d38fe2e493 Mon Sep 17 00:00:00 2001 From: Jason Slavin Date: Mon, 26 Aug 2024 13:59:48 -0700 Subject: [PATCH 01/12] prefetch test --- head.html | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/head.html b/head.html index e1fb9ec..84fdf17 100644 --- a/head.html +++ b/head.html @@ -1,4 +1,16 @@ - + + + From 8c1629fee24df7c584b3f69899d050dbbe1cfdfc Mon Sep 17 00:00:00 2001 From: Jason Slavin Date: Mon, 26 Aug 2024 14:19:49 -0700 Subject: [PATCH 02/12] Added everything prefectch besides scripts/scripts, need to see how it does --- head.html | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/head.html b/head.html index 84fdf17..594e50b 100644 --- a/head.html +++ b/head.html @@ -1,5 +1,8 @@ - + + + + - + From dd0c6b554e57ed4a47019d8cfc3e09593b7a84d6 Mon Sep 17 00:00:00 2001 From: Jason Slavin Date: Mon, 26 Aug 2024 14:23:31 -0700 Subject: [PATCH 03/12] test --- head.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/head.html b/head.html index 594e50b..7ee2e81 100644 --- a/head.html +++ b/head.html @@ -18,7 +18,8 @@ const miloUtils = document.querySelector('#milo-utils'); miloUtils.setAttribute('href', `${libs}/utils/utils.js`); const miloDecorate = document.querySelector('#milo-decorate'); - miloDecorate.setAttribute('href', `${libs}/utils/decorate.js`)'' + miloDecorate.setAttribute('href', `${libs}/utils/decorate.js`); + console.log(miloStyles, miloDecorate, miloUtils) From fbed148e35a2426d727115616c5a55884978d669 Mon Sep 17 00:00:00 2001 From: Jason Slavin Date: Mon, 26 Aug 2024 14:27:38 -0700 Subject: [PATCH 04/12] Adding crossorigin --- head.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/head.html b/head.html index 7ee2e81..cda37e2 100644 --- a/head.html +++ b/head.html @@ -1,8 +1,8 @@ - - + + From 48fd42357fe6814a4ea461ef7115de209e86d687 Mon Sep 17 00:00:00 2001 From: Jason Slavin Date: Wed, 4 Sep 2024 09:08:45 -0700 Subject: [PATCH 06/12] Testing postbody --- scripts/aa-university.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/scripts/aa-university.js b/scripts/aa-university.js index 85488df..da3f7a7 100644 --- a/scripts/aa-university.js +++ b/scripts/aa-university.js @@ -3,16 +3,21 @@ 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}`)); } From 4b4e70c2da41700191c1f3f50961ac96941c02fc Mon Sep 17 00:00:00 2001 From: Jason Slavin Date: Thu, 5 Sep 2024 09:13:28 -0700 Subject: [PATCH 07/12] Adding the ability to have a group param added to the sandbox POST request. There is a default, so we do not want to send anything if we do not find the metadata --- scripts/aa-university.js | 4 +++- test/scripts/aa-university.test.js | 16 ++++++++++++++++ test/scripts/mocks/with-group.html | 8 ++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 test/scripts/mocks/with-group.html diff --git a/scripts/aa-university.js b/scripts/aa-university.js index da3f7a7..1706691 100644 --- a/scripts/aa-university.js +++ b/scripts/aa-university.js @@ -3,7 +3,7 @@ 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 group = document.querySelector('meta[name="sandboxgroup"]'); const postBody = { first_name: firstName?.value, @@ -20,4 +20,6 @@ export default function registerAAUniversity() { body: JSON.stringify(postBody), }) .catch((error) => window.lana.log(`Marketo AA University Error: ${error}`)); + + return postBody; } 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/mocks/with-group.html b/test/scripts/mocks/with-group.html new file mode 100644 index 0000000..3ec0f17 --- /dev/null +++ b/test/scripts/mocks/with-group.html @@ -0,0 +1,8 @@ + +Jane +Doe +janedoe@email.com + From 014b4dd469b54bea1477e5542d19ef201b71db55 Mon Sep 17 00:00:00 2001 From: Jason Slavin Date: Thu, 5 Sep 2024 09:20:28 -0700 Subject: [PATCH 08/12] Removing file not needed --- test/scripts/mocks/with-group.html | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 test/scripts/mocks/with-group.html diff --git a/test/scripts/mocks/with-group.html b/test/scripts/mocks/with-group.html deleted file mode 100644 index 3ec0f17..0000000 --- a/test/scripts/mocks/with-group.html +++ /dev/null @@ -1,8 +0,0 @@ - -Jane -Doe -janedoe@email.com - From 5aff88af7b82614cac631c5a96e5a909892b2ad3 Mon Sep 17 00:00:00 2001 From: Jason Slavin Date: Fri, 6 Sep 2024 09:18:18 -0700 Subject: [PATCH 09/12] Testing for CR --- head.html | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/head.html b/head.html index 8b58588..cd83520 100644 --- a/head.html +++ b/head.html @@ -1,8 +1,8 @@ - - - - + + + From 60ce02927835732db86454a92dddb59a3bdd2ff6 Mon Sep 17 00:00:00 2001 From: Jason Slavin Date: Fri, 6 Sep 2024 09:21:33 -0700 Subject: [PATCH 10/12] Testing --- head.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/head.html b/head.html index cd83520..5545867 100644 --- a/head.html +++ b/head.html @@ -28,7 +28,7 @@ miloUtils.setAttribute('href', `${libs}/utils/utils.js`); miloDecorate.setAttribute('href', `${libs}/utils/decorate.js`); - document.querySelector('[href="/styles/styles.css"]').after(miloStyles, miloUtils, miloDecorate); + document.head.append(miloStyles, miloUtils, miloDecorate); // document.querySelector('#milo-stylesheet').setAttribute('href', `${libs}/styles/styles.css`); // document.querySelector('#milo-utils').setAttribute('href', `${libs}/utils/utils.js`); // document.querySelector('#milo-decorate').setAttribute('href', `${libs}/utils/decorate.js`); From a4fd40a3ff61380b217588091bd3171dcce815a4 Mon Sep 17 00:00:00 2001 From: Jason Slavin Date: Fri, 6 Sep 2024 09:23:37 -0700 Subject: [PATCH 11/12] Again --- head.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/head.html b/head.html index 5545867..27308b7 100644 --- a/head.html +++ b/head.html @@ -21,7 +21,7 @@ miloStyles.setAttribute('href', `${libs}/styles/styles.css`); [miloUtils, miloDecorate].forEach((tag) => { - tag.setAttribute('crossorigin'); + tag.setAttribute('crossorigin', 'true'); tag.setAttribute('as', 'script'); }) From 74c9a11eef2ee780bdb64b6eb62ba298fcde4382 Mon Sep 17 00:00:00 2001 From: Jason Slavin Date: Fri, 6 Sep 2024 09:25:58 -0700 Subject: [PATCH 12/12] working as expected --- head.html | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/head.html b/head.html index 27308b7..89f84b8 100644 --- a/head.html +++ b/head.html @@ -1,8 +1,5 @@ - -