Skip to content

Commit 8252012

Browse files
authored
Merge branch 'main' into sidebar-tooltips-pr
2 parents 2fce04a + 90330f2 commit 8252012

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+376
-147
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ body:
5757
validations:
5858
required: true
5959

60+
- type: dropdown
61+
attributes:
62+
label: Vue simulator version
63+
description: Select the version(s) of the Vue simulator you are using.
64+
multiple: true
65+
options:
66+
- 'v0'
67+
- 'v1'
68+
validations:
69+
required: true
70+
6071
- type: dropdown
6172
attributes:
6273
label: Used Vue simulator with or without backend?

.github/workflows/vitest.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions: {}
10+
11+
concurrency:
12+
group: ci-${{ github.event.pull_request.number || github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
test:
17+
name: Run Tests
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 10
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: '22'
29+
cache: 'npm'
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
34+
- name: Run tests
35+
run: npm run test -- --reporter=github-actions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"lint": "eslint --ext .js,.vue --ignore-path .gitignore --fix src",
1212
"format": "prettier . --write",
1313
"postinstall": "husky install",
14-
"test": "vitest"
14+
"test": "vitest --silent"
1515
},
1616
"dependencies": {
1717
"@fortawesome/fontawesome-free": "^6.5.1",

src/components/Navbar/Navbar.vue

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,12 @@
2323

2424
<script lang="ts" setup>
2525
import QuickButton from '@/Navbar/QuickButton/QuickButton.vue'
26-
import User from '@/Navbar/User/User.vue'
2726
import NavbarLinks from '@/Navbar/NavbarLinks/NavbarLinks.vue'
2827
import { useSimulatorMobileStore } from '#/store/simulatorMobileStore'
2928
3029
import navbarData from '#/assets/constants/Navbar/NAVBAR_DATA.json'
31-
import userDropdownItems from '#/assets/constants/Navbar/USER_DATA.json'
3230
3331
import Logo from '@/Logo/Logo.vue'
34-
import Hamburger from '@/Navbar/Hamburger/Hamburger.vue'
35-
import Hamburger2 from './Hamburger/Hamburger2.vue'
3632
import UserMenu from './User/UserMenu.vue'
3733
import { ref } from 'vue'
3834
import { useProjectStore } from '#/store/projectStore'

src/components/ReportIssue/ReportIssue.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ async function postUserIssue(message: string): Promise<void> {
243243
} catch (err) {
244244
const resultEl = document.getElementById('result')
245245
if (resultEl) {
246-
resultEl.innerHTML = `<i class='fa fa-minus-circle' style='color:red'></i> There seems to be a network issue. Please reach out to us at support@ciruitverse.org`
246+
resultEl.innerHTML = `<i class='fa fa-minus-circle' style='color:red'></i> There seems to be a network issue. Please reach out to us at support@circuitverse.org`
247247
}
248248
console.error(err)
249249
}

src/simulator/spec/vitestSetup.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { vi, afterEach } from 'vitest';
2+
13
global.window = window;
24
global.jQuery = require('jquery');
35
global.DPR = true;
@@ -9,3 +11,35 @@ window.$ = require('jquery');
911
window.restrictedElements = [];
1012
window.userSignedIn = true;
1113
window.embed = false;
14+
15+
vi.useFakeTimers()
16+
17+
afterEach(() => {
18+
vi.runOnlyPendingTimers()
19+
vi.clearAllTimers()
20+
})
21+
22+
vi.mock('@tauri-apps/api/event', () => ({
23+
listen: vi.fn(() => Promise.resolve(() => {})),
24+
}))
25+
26+
global.ResizeObserver = vi.fn().mockImplementation(() => ({
27+
observe: vi.fn(),
28+
unobserve: vi.fn(),
29+
disconnect: vi.fn(),
30+
}))
31+
32+
HTMLCanvasElement.prototype.getContext = vi.fn(() => ({
33+
clearRect: vi.fn(),
34+
fillRect: vi.fn(),
35+
fillText: vi.fn(),
36+
strokeRect: vi.fn(),
37+
beginPath: vi.fn(),
38+
moveTo: vi.fn(),
39+
lineTo: vi.fn(),
40+
stroke: vi.fn(),
41+
closePath: vi.fn(),
42+
arc: vi.fn(),
43+
fill: vi.fn(),
44+
rect: vi.fn(),
45+
}))

src/simulator/src/listeners.js

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ const unit = 10
4343
let listenToSimulator = true
4444
let coordinate;
4545
const returnCoordinate = {
46-
x: 0,
47-
y: 0
46+
x: 0,
47+
y: 0
4848
}
4949

5050
let currDistance = 0;
@@ -83,7 +83,7 @@ function getTap(e) {
8383
if (tapLength < 500 && tapLength > 0) {
8484
onDoubleClickorTap(e);
8585
} else {
86-
// Single tap
86+
// Single tap
8787
}
8888
lastTap = currentTime;
8989
e.preventDefault();
@@ -303,11 +303,11 @@ export default function startListeners() {
303303
})
304304

305305
$('#projectName').on('click', () => {
306-
simulationArea.lastSelected = globalScope.root;
307-
setTimeout(() => {
308-
document.getElementById("projname").select();
309-
}, 100);
310-
});
306+
simulationArea.lastSelected = globalScope.root;
307+
setTimeout(() => {
308+
document.getElementById("projname").select();
309+
}, 100);
310+
});
311311

312312
document
313313
.getElementById('simulationArea')
@@ -502,7 +502,7 @@ export default function startListeners() {
502502
!simulationArea.lastSelected.keyDown &&
503503
simulationArea.lastSelected.objectType != 'Wire' &&
504504
simulationArea.lastSelected.objectType !=
505-
'CircuitElement' &&
505+
'CircuitElement' &&
506506
!simulationArea.multipleObjectSelections.includes(
507507
simulationArea.lastSelected
508508
)
@@ -567,8 +567,8 @@ export default function startListeners() {
567567
)
568568

569569
document.getElementById('simulationArea').addEventListener('dblclick', e => {
570-
onDoubleClickorTap(e);
571-
});
570+
onDoubleClickorTap(e);
571+
});
572572

573573
function MouseScroll(event) {
574574
updateCanvasSet(true)
@@ -725,68 +725,68 @@ window.addEventListener('resize', resizeTabs)
725725
resizeTabs()
726726

727727
// direction is only 1 or -1
728-
function handleZoom (direction) {
728+
function handleZoom(direction) {
729729
if (globalScope.scale > 0.5 * DPR) {
730-
changeScale(direction * 0.1 * DPR);
730+
changeScale(direction * 0.1 * DPR);
731731
} else if (globalScope.scale < 4 * DPR) {
732-
changeScale(direction * 0.1 * DPR);
732+
changeScale(direction * 0.1 * DPR);
733733
}
734734
gridUpdateSet(true);
735735
scheduleUpdate();
736-
}
737-
export function ZoomIn () {
736+
}
737+
export function ZoomIn() {
738738
handleZoom(1);
739-
}
740-
export function ZoomOut () {
739+
}
740+
export function ZoomOut() {
741741
handleZoom(-1);
742-
}
743-
function zoomSliderListeners () {
742+
}
743+
function zoomSliderListeners() {
744744
document.getElementById("customRange1").value = 5;
745745
document.getElementById('simulationArea').addEventListener('DOMMouseScroll', zoomSliderScroll);
746746
document.getElementById('simulationArea').addEventListener('mousewheel', zoomSliderScroll);
747747
let curLevel = document.getElementById("customRange1").value;
748748
$(document).on('input change', '#customRange1', function (e) {
749-
const newValue = $(this).val();
750-
const changeInScale = newValue - curLevel;
751-
updateCanvasSet(true);
752-
changeScale(changeInScale * 0.1, 'zoomButton', 'zoomButton', 3)
753-
gridUpdateSet(true);
754-
curLevel = newValue;
749+
const newValue = $(this).val();
750+
const changeInScale = newValue - curLevel;
751+
updateCanvasSet(true);
752+
changeScale(changeInScale * 0.1, 'zoomButton', 'zoomButton', 3)
753+
gridUpdateSet(true);
754+
curLevel = newValue;
755755
});
756-
function zoomSliderScroll (e) {
757-
let zoomLevel = document.getElementById("customRange1").value;
758-
const deltaY = e.wheelDelta ? e.wheelDelta : -e.detail;
759-
const directionY = deltaY > 0 ? 1 : -1;
760-
if (directionY > 0) zoomLevel++
761-
else zoomLevel--
762-
if (zoomLevel >= 45) {
763-
zoomLevel = 45;
764-
document.getElementById("customRange1").value = 45;
765-
} else if (zoomLevel <= 0) {
766-
zoomLevel = 0;
767-
document.getElementById("customRange1").value = 0;
768-
} else {
769-
document.getElementById("customRange1").value = zoomLevel;
770-
curLevel = zoomLevel;
771-
}
756+
function zoomSliderScroll(e) {
757+
let zoomLevel = document.getElementById("customRange1").value;
758+
const deltaY = e.wheelDelta ? e.wheelDelta : -e.detail;
759+
const directionY = deltaY > 0 ? 1 : -1;
760+
if (directionY > 0) zoomLevel++
761+
else zoomLevel--
762+
if (zoomLevel >= 45) {
763+
zoomLevel = 45;
764+
document.getElementById("customRange1").value = 45;
765+
} else if (zoomLevel <= 0) {
766+
zoomLevel = 0;
767+
document.getElementById("customRange1").value = 0;
768+
} else {
769+
document.getElementById("customRange1").value = zoomLevel;
770+
curLevel = zoomLevel;
771+
}
772772
}
773-
function sliderZoomButton (direction) {
774-
const zoomSlider = $('#customRange1');
775-
let currentSliderValue = parseInt(zoomSlider.val(), 10);
776-
if (direction === -1) {
777-
currentSliderValue--;
778-
} else {
779-
currentSliderValue++;
780-
}
781-
zoomSlider.val(currentSliderValue).change();
773+
function sliderZoomButton(direction) {
774+
const zoomSlider = $('#customRange1');
775+
let currentSliderValue = parseInt(zoomSlider.val(), 10);
776+
if (direction === -1) {
777+
currentSliderValue--;
778+
} else {
779+
currentSliderValue++;
780+
}
781+
zoomSlider.val(currentSliderValue).change();
782782
}
783783
$('#decrement').click(() => {
784-
sliderZoomButton(-1);
784+
sliderZoomButton(-1);
785785
});
786786
$('#increment').click(() => {
787-
sliderZoomButton(1);
787+
sliderZoomButton(1);
788788
});
789-
}
789+
}
790790

791791
// Desktop App Listeners
792792

src/simulator/src/modules/AndGate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,5 @@ AndGate.prototype.verilogType = 'and'
164164
* @category modules
165165
*/
166166
AndGate.prototype.changeInputSize = changeInputSize
167-
AndGate.prototype.helplink = 'https://docs.circuitverse.org/#/chapter4/4gates?id=and-gate'
167+
AndGate.prototype.helplink = 'https://docs.circuitverse.org/chapter4/chapter4-gates#and-gate'
168168
AndGate.prototype.objectType = 'AndGate'

src/simulator/src/modules/NandGate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,5 @@ NandGate.prototype.changeInputSize = changeInputSize
162162
*/
163163
NandGate.prototype.verilogType = 'nand'
164164
NandGate.prototype.helplink =
165-
'https://docs.circuitverse.org/#/chapter4/4gates?id=nand-gate'
165+
'https://docs.circuitverse.org/chapter4/chapter4-gates#nand-gate'
166166
NandGate.prototype.objectType = 'NandGate'

src/simulator/src/modules/NorGate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,5 +175,5 @@ NorGate.prototype.changeInputSize = changeInputSize
175175
* @category modules
176176
*/
177177
NorGate.prototype.verilogType = 'nor'
178-
NorGate.prototype.helplink = 'https://docs.circuitverse.org/#/chapter4/4gates?id=nor-gate'
178+
NorGate.prototype.helplink = 'https://docs.circuitverse.org/chapter4/chapter4-gates#nor-gate'
179179
NorGate.prototype.objectType = 'NorGate'

0 commit comments

Comments
 (0)