Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWPW-135908 Add lana #29

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' });
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);
}
}
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.calledWith('Auto Blocking failed')).to.be.true;
});

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