Skip to content

Commit

Permalink
MWPW-135908 Add lana (#29)
Browse files Browse the repository at this point in the history
* MWPW-135908 Add lana

* tags
  • Loading branch information
meganthecoder committed Nov 16, 2023
1 parent 1e43e7e commit 977a792
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion blog/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,10 @@ const miloLibs = setLibs(LIBS);
}());

(async function loadPage() {
const { loadArea, setConfig } = await import(`${miloLibs}/utils/utils.js`);
const { loadArea, setConfig, loadLana } = await import(`${miloLibs}/utils/utils.js`);

setConfig({ ...CONFIG, miloLibs });
loadLana({ clientId: 'bacom-blog', tags: 'default' });
await buildAutoBlocks();
await loadArea();
}());
3 changes: 1 addition & 2 deletions blog/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ export async function buildAutoBlocks() {
await buildArticleHeader(mainEl);
}
} catch (error) {
// eslint-disable-next-line no-console
console.error('Auto Blocking failed', error);
window.lana?.log(`Auto Blocking failed: ${error}`, { tags: 'autoBlock' });
}
}
8 changes: 5 additions & 3 deletions test/scripts/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,26 @@ describe('Libs', () => {

const metadata = await readFile({ path: './mocks/tagsHead.html' });

window.lana = { log: () => {} };

describe('Auto Blocks', () => {
before(() => {
setLibs('/libs');
});

beforeEach(() => {
sinon.stub(console, 'error');
sinon.stub(window.lana, 'log');
});

afterEach(() => {
console.error.restore();
window.lana.log.restore();
});

it('catches errors', async () => {
document.head.innerHTML = metadata;
document.body.innerHTML = '';
await buildAutoBlocks();
expect(console.error.calledWith('Auto Blocking failed')).to.be.true;
expect(window.lana.log.called).to.be.true;
});

it('builds the tags block', async () => {
Expand Down

0 comments on commit 977a792

Please sign in to comment.