Remove refresh icon and fix Safari/WebKit runtime errors

- Removed manual refresh button from frontend (kept auto-refresh functionality)
- Fixed WebKit 'object cannot be found' error by replacing absolute positioning with flexbox
- Added lazy loading to images to prevent preload warnings
- Cleaned up unused imports and variables:
  - Removed unused useRef import
  - Removed unused colors state variable and colorService
  - Removed unused ColorSwatch import from FilamentTableV2
  - Removed unused getModifierIcon function from MaterialBadge
- Updated tests to match current implementation
- Improved layout stability for better cross-browser compatibility
- Removed temporary migration scripts

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
DaX
2025-06-30 22:37:30 +02:00
parent 58b3ff2dec
commit 12e91d4c3e
33 changed files with 1646 additions and 668 deletions

View File

@@ -34,9 +34,9 @@ describe('Filament CRUD Operations', () => {
tip: 'PLA',
finish: 'Basic',
boja: 'Black',
bojaHex: '#000000',
boja_hex: '#000000',
refill: '2',
vakum: '1 vakuum',
spulna: '1 spulna',
kolicina: '3',
cena: '3999'
};
@@ -61,14 +61,14 @@ describe('Filament CRUD Operations', () => {
expect(callArg).not.toHaveProperty('brand');
});
it('should transform bojaHex to boja_hex for backend', async () => {
it('should use boja_hex field directly', async () => {
const filamentWithHex = {
tip: 'PETG',
finish: 'Silk',
boja: 'Red',
bojaHex: '#FF0000',
boja_hex: '#FF0000',
refill: 'Ne',
vakum: 'Ne',
spulna: 'Ne',
kolicina: '1',
cena: '4500'
};
@@ -93,9 +93,9 @@ describe('Filament CRUD Operations', () => {
tip: 'ABS',
finish: 'Matte',
boja: 'Blue',
bojaHex: '#0000FF',
boja_hex: '#0000FF',
refill: '1',
vakum: '2 vakuum',
spulna: '2 spulna',
kolicina: '4',
cena: '5000'
};
@@ -135,7 +135,7 @@ describe('Filament CRUD Operations', () => {
});
describe('Get All Filaments', () => {
it('should retrieve all filaments and transform boja_hex to bojaHex', async () => {
it('should retrieve all filaments with boja_hex field', async () => {
const mockFilaments = [
{
id: '1',
@@ -144,7 +144,7 @@ describe('Filament CRUD Operations', () => {
boja: 'Black',
boja_hex: '#000000',
refill: '2',
vakum: '1 vakuum',
spulna: '1 spulna',
kolicina: '3',
cena: '3999'
},
@@ -155,43 +155,41 @@ describe('Filament CRUD Operations', () => {
boja: 'Red',
boja_hex: '#FF0000',
refill: 'Ne',
vakum: 'Ne',
spulna: 'Ne',
kolicina: '1',
cena: '4500'
}
];
const expectedTransformed = mockFilaments.map(f => ({
...f,
bojaHex: f.boja_hex
}));
// No transformation needed anymore - we use boja_hex directly
const expectedFilaments = mockFilaments;
jest.spyOn(filamentService, 'getAll').mockResolvedValue(expectedTransformed);
jest.spyOn(filamentService, 'getAll').mockResolvedValue(expectedFilaments);
const result = await filamentService.getAll();
expect(result).toEqual(expectedTransformed);
expect(result[0]).toHaveProperty('bojaHex', '#000000');
expect(result[1]).toHaveProperty('bojaHex', '#FF0000');
expect(result).toEqual(expectedFilaments);
expect(result[0]).toHaveProperty('boja_hex', '#000000');
expect(result[1]).toHaveProperty('boja_hex', '#FF0000');
});
});
describe('Quantity Calculations', () => {
it('should correctly calculate total quantity from refill and vakuum', () => {
it('should correctly calculate total quantity from refill and spulna', () => {
const testCases = [
{ refill: '2', vakum: '1 vakuum', expected: 3 },
{ refill: 'Ne', vakum: '3 vakuum', expected: 3 },
{ refill: '1', vakum: 'Ne', expected: 1 },
{ refill: 'Da', vakum: 'vakuum', expected: 2 }
{ refill: '2', spulna: '1 spulna', expected: 3 },
{ refill: 'Ne', spulna: '3 spulna', expected: 3 },
{ refill: '1', spulna: 'Ne', expected: 1 },
{ refill: 'Da', spulna: 'spulna', expected: 2 }
];
testCases.forEach(({ refill, vakum, expected }) => {
testCases.forEach(({ refill, spulna, expected }) => {
// Parse refill
const refillCount = parseInt(refill) || (refill?.toLowerCase() === 'da' ? 1 : 0);
// Parse vakuum
const vakuumMatch = vakum?.match(/^(\d+)\s*vakuum/);
const vakuumCount = vakuumMatch ? parseInt(vakuumMatch[1]) : (vakum?.toLowerCase().includes('vakuum') ? 1 : 0);
// Parse spulna
const vakuumMatch = spulna?.match(/^(\d+)\s*spulna/);
const vakuumCount = vakuumMatch ? parseInt(vakuumMatch[1]) : (spulna?.toLowerCase().includes('spulna') ? 1 : 0);
const total = refillCount + vakuumCount;