Commit 170ac699 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch 'ps-lib-logger-hello' into 'master'

Log hello message in browser console

See merge request gitlab-org/gitlab!69589
parents a02a6b3e a1defde1
const HANDSHAKE = String.fromCodePoint(0x1f91d);
const MAG = String.fromCodePoint(0x1f50e);
export const logHello = () => {
// eslint-disable-next-line no-console
console.log(
`%cWelcome to GitLab!%c
Does this page need fixes or improvements? Open an issue or contribute a merge request to help make GitLab more lovable. At GitLab, everyone can contribute!
${HANDSHAKE} Contribute to GitLab: https://about.gitlab.com/community/contribute/
${MAG} Create a new GitLab issue: https://gitlab.com/gitlab-org/gitlab/-/issues/new`,
`padding-top: 0.5em; font-size: 2em;`,
'padding-bottom: 0.5em;',
);
};
export const logHelloDeferred = async () => {
const { logHello } = await import(/* webpackChunkName: 'hello' */ './hello');
logHello();
};
......@@ -19,6 +19,7 @@ import initAlertHandler from './alert_handler';
import { removeFlashClickListener } from './flash';
import initTodoToggle from './header';
import initLayoutNav from './layout_nav';
import { logHelloDeferred } from './lib/logger/hello_deferred';
import { handleLocationHash, addSelectOnFocusBehaviour } from './lib/utils/common_utils';
import { localTimeAgo } from './lib/utils/datetime/timeago_utility';
import { getLocationHash, visitUrl } from './lib/utils/url_utility';
......@@ -40,6 +41,8 @@ import { initHeaderSearchApp } from '~/header_search';
import 'ee_else_ce/main_ee';
import 'jh_else_ce/main_jh';
logHelloDeferred();
applyGitLabUIConfig();
// expose jQuery as global (TODO: remove these)
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`~/lib/logger/hello logHello console logs a friendly hello message 1`] = `
Array [
Array [
"%cWelcome to GitLab!%c
Does this page need fixes or improvements? Open an issue or contribute a merge request to help make GitLab more lovable. At GitLab, everyone can contribute!
🤝 Contribute to GitLab: https://about.gitlab.com/community/contribute/
🔎 Create a new GitLab issue: https://gitlab.com/gitlab-org/gitlab/-/issues/new",
"padding-top: 0.5em; font-size: 2em;",
"padding-bottom: 0.5em;",
],
]
`;
import waitForPromises from 'helpers/wait_for_promises';
import { logHello } from '~/lib/logger/hello';
import { logHelloDeferred } from '~/lib/logger/hello_deferred';
jest.mock('~/lib/logger/hello');
describe('~/lib/logger/hello_deferred', () => {
it('dynamically imports and calls logHello', async () => {
logHelloDeferred();
expect(logHello).not.toHaveBeenCalled();
await waitForPromises();
expect(logHello).toHaveBeenCalled();
});
});
import { logHello } from '~/lib/logger/hello';
describe('~/lib/logger/hello', () => {
let consoleLogSpy;
beforeEach(() => {
// We don't `mockImplementation` so we can validate there's no errors thrown
consoleLogSpy = jest.spyOn(console, 'log');
});
describe('logHello', () => {
it('console logs a friendly hello message', () => {
expect(consoleLogSpy).not.toHaveBeenCalled();
logHello();
expect(consoleLogSpy.mock.calls).toMatchSnapshot();
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment