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

Qol 8453 add tests on alert and call out box #400

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions e2e/__tests__/components/alert-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('SWE Components testing', () => {
// 1. -> alert contains deprecate icon
await page.waitForSelector('.alert h2 i.fa');
// 2. -> warning appears in console
await page.waitForTimeout(5000);
expect(consoleMsg).toEqual('Please change the font awesome element in Alert from i to span, we\'ll be removing the css in this element before 22nd june 2022. Please refer to the https://github.com/qld-gov-au/qg-web-template/pull/391 for more details.');
});

Expand Down
1 change: 1 addition & 0 deletions e2e/__tests__/components/call-out-box-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('SWE Components testing', () => {
// 1. -> call out box contains deprecate icon
await page.waitForSelector('.qg-callout__box .qg-callout__icon i.fa');
// 2. -> warning appears in console
await page.waitForTimeout(5000);
expect(consoleMsg).toEqual('Please change the font awesome element in Callout box from i to span, we\'ll be removing the css in this element before 22nd june 2022. Please refer to the https://github.com/qld-gov-au/qg-web-template/pull/391 for more details.');
});

Expand Down
17 changes: 11 additions & 6 deletions src/assets/_project/_blocks/utils/qg-misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,15 @@
label: 'Alert',
},
];
deprecationWarnings.forEach(({selector, label}) => {
// use `show` if the element is created on the fly
$(selector).show(() => {
console.warn(`Please change the font awesome element in ${label} from i to span, we'll be removing the css in this element before 22nd june 2022. Please refer to the https://github.com/qld-gov-au/qg-web-template/pull/391 for more details.`);
});
});
// setTimeout is just a temporary solution for display the warning message in SPA as elements are created on the fly
setTimeout(
() => {
deprecationWarnings.forEach(({selector, label}) => {
if ($(selector).length) {
console.warn(`Please change the font awesome element in ${label} from i to span, we'll be removing the css in this element before 22nd june 2022. Please refer to the https://github.com/qld-gov-au/qg-web-template/pull/391 for more details.`);
}
});
},
5000,
);
})(jQuery, qg.swe);