Skip to content

Commit 27abc23

Browse files
chore: Modernize JS build, remove jQuery bundle (#492)
* chore: Modernize JS build, remove jQuery bundle * chore: Add js tests * Update action, fix linter * Potential fix for code scanning alert no. 512: Uncontrolled data used in path expression Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * Potential fix for code scanning alert no. 513: Uncontrolled data used in path expression Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * Potential fix for code scanning alert no. 514: Uncontrolled data used in path expression Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * Update npm packages --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 29b3955 commit 27abc23

33 files changed

+10196
-10214
lines changed

.babelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"presets": [
3-
["env", {
3+
["@babel/preset-env", {
44
"modules": false
55
}]
66
],
7-
"plugins": ["transform-runtime", "syntax-dynamic-import"]
7+
"plugins": ["@babel/plugin-syntax-dynamic-import"]
88
}

.eslintrc.js

Lines changed: 0 additions & 225 deletions
This file was deleted.

.github/workflows/frontend.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Frontend E2E Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- 'release/**'
8+
pull_request:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
e2e:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v5
20+
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '24'
25+
cache: 'npm'
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Install Playwright Chromium browser
31+
run: npx playwright install --with-deps chromium
32+
33+
- name: Run linter
34+
run: npx gulp lint
35+
36+
- name: Run E2E tests with coverage
37+
run: |
38+
npm run e2e
39+
npm run e2e:coverage:report

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ htmlcov/
1616
!djangocms_versioning/static/djangocms_versioning/js/dist
1717
docs/_build/
1818
node_modules
19+
coverage-e2e/
20+
.nyc_output/
21+
playwright-report/
22+
test-results/

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16
1+
24

babel.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
presets: [
3+
['@babel/preset-env', {
4+
targets: {
5+
browsers: ['last 2 versions', '> 1%']
6+
}
7+
}]
8+
],
9+
plugins: [
10+
'@babel/plugin-syntax-dynamic-import'
11+
]
12+
};
Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1+
const retryTime = 5000;
2+
const browserTime = 20;
3+
14
(function($) {
25
if (!$) {
36
return;
47
}
58

69
// Hide django messages after timeout occurs to prevent content overlap
7-
$('document').ready(function(){
10+
$('document').ready(function() {
811
// Targeting first item returned (there's only ever one messagelist per template):
9-
let messageList = document.getElementsByClassName("messagelist")[0];
10-
if(messageList != undefined){
11-
for(let item of messageList.children){
12-
item.style.opacity = 1;
13-
setTimeout(() => {
14-
let fader = setInterval(() => {
15-
item.style.opacity -= 0.05;
16-
if(item.style.opacity < 0) {
17-
item.style.display = "none";
18-
clearInterval(fader);
19-
}
20-
}, 20);
21-
}, 5000);
22-
}
12+
let messageList = document.getElementsByClassName('messagelist')[0];
13+
14+
if (messageList !== undefined) {
15+
for (let item of messageList.children) {
16+
item.style.opacity = 1;
17+
setTimeout(() => {
18+
let fader = setInterval(() => {
19+
item.style.opacity -= 0.05;
20+
if (item.style.opacity < 0) {
21+
item.style.display = 'none';
22+
clearInterval(fader);
23+
}
24+
}, browserTime);
25+
}, retryTime);
26+
}
2327
}
2428
});
25-
})((typeof django !== 'undefined' && django.jQuery) || (typeof CMS !== 'undefined' && CMS.$) || false);
29+
})((typeof django !== 'undefined' && django.jQuery) || (typeof CMS !== 'undefined' && CMS.$) || false);

0 commit comments

Comments
 (0)