Remove Tailwind CSS and all remaining references (#2413)
Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
committed by
acx10
co-authored by
acx10
parent
5d9e535a14
commit
a0870cac86
@@ -1,4 +1,4 @@
|
||||
import {beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {EnvironmentInjector, runInInjectionContext} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {of} from 'rxjs';
|
||||
@@ -139,16 +139,17 @@ describe('AuthService', () => {
|
||||
|
||||
it('should logout and clear all tokens', () => {
|
||||
service.getRxStompService = vi.fn().mockReturnValue(rxStompServiceMock);
|
||||
const loc = {href: ''};
|
||||
vi.stubGlobal('window', {location: loc});
|
||||
routerMock.navigate.mockReturnValue(Promise.resolve(true));
|
||||
|
||||
service.logout();
|
||||
|
||||
expect(localStorage.removeItem).toHaveBeenCalledWith('accessToken_Internal');
|
||||
expect(localStorage.removeItem).toHaveBeenCalledWith('refreshToken_Internal');
|
||||
expect(oAuthStorageMock.removeItem).toHaveBeenCalledWith('access_token');
|
||||
expect(oAuthStorageMock.removeItem).toHaveBeenCalledWith('refresh_token');
|
||||
expect(oAuthStorageMock.removeItem).toHaveBeenCalledWith('id_token');
|
||||
expect(rxStompServiceMock.deactivate).toHaveBeenCalled();
|
||||
expect(loc.href).toBe('/login');
|
||||
expect(routerMock.navigate).toHaveBeenCalledWith(['/login']);
|
||||
});
|
||||
|
||||
it('should initialize websocket connection if token exists', () => {
|
||||
|
||||
@@ -99,7 +99,9 @@ export class AuthService {
|
||||
this.tokenSubject.next(null);
|
||||
this.postLoginInitialized = false;
|
||||
this.getRxStompService().deactivate();
|
||||
window.location.href = '/login';
|
||||
this.router.navigate(['/login']).then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
getRxStompService(): RxStompService {
|
||||
|
||||
@@ -11,6 +11,8 @@ describe('CustomFontService', () => {
|
||||
let service: CustomFontService;
|
||||
let httpClientMock: any;
|
||||
let authServiceMock: any;
|
||||
let fontsSet: any[];
|
||||
let originalDocumentFonts: any;
|
||||
|
||||
const mockFont: CustomFont = {
|
||||
id: 1,
|
||||
@@ -41,19 +43,25 @@ describe('CustomFontService', () => {
|
||||
this.load = vi.fn().mockResolvedValue(this);
|
||||
};
|
||||
|
||||
const fontsSet: any[] = [];
|
||||
(globalThis as any).document = {
|
||||
fonts: {
|
||||
add: vi.fn(font => fontsSet.push(font)),
|
||||
delete: vi.fn(font => {
|
||||
// Store original and create mock fonts set
|
||||
originalDocumentFonts = document.fonts;
|
||||
fontsSet = [];
|
||||
|
||||
// Mock document.fonts
|
||||
Object.defineProperty(document, 'fonts', {
|
||||
value: {
|
||||
add: vi.fn((font: any) => fontsSet.push(font)),
|
||||
delete: vi.fn((font: any) => {
|
||||
const idx = fontsSet.indexOf(font);
|
||||
if (idx !== -1) fontsSet.splice(idx, 1);
|
||||
}),
|
||||
[Symbol.iterator]: function* () {
|
||||
yield* fontsSet;
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
@@ -109,17 +117,17 @@ describe('CustomFontService', () => {
|
||||
it('should mark font as loaded after loadFontFace', async () => {
|
||||
await service.loadFontFace(mockFont);
|
||||
expect(service.isFontLoaded(mockFont.fontName)).toBe(true);
|
||||
const fontsArr = Array.from((globalThis as any).document.fonts);
|
||||
const fontsArr = Array.from(document.fonts);
|
||||
expect(fontsArr.some((f: any) => f.family === mockFont.fontName)).toBe(true);
|
||||
});
|
||||
|
||||
it('should call removeFontFace on delete', () => {
|
||||
const fontObj = {family: mockFont.fontName};
|
||||
(globalThis as any).document.fonts.add(fontObj);
|
||||
const fontObj = new (globalThis as any).FontFace(mockFont.fontName, 'url(test.ttf)');
|
||||
document.fonts.add(fontObj);
|
||||
service['fontsSubject'].next([mockFont]);
|
||||
httpClientMock.delete.mockReturnValue(of(void 0));
|
||||
service.deleteFont(mockFont.id).subscribe(() => {
|
||||
const fontsArr = Array.from((globalThis as any).document.fonts);
|
||||
const fontsArr = Array.from(document.fonts);
|
||||
expect(fontsArr.some((f: any) => f.family === mockFont.fontName)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -62,32 +62,14 @@ describe('FileDownloadService', () => {
|
||||
];
|
||||
httpClientMock.get.mockReturnValue(of(...events));
|
||||
// Mock DOM for download
|
||||
const appendChild = vi.fn();
|
||||
const removeChild = vi.fn();
|
||||
const link = {
|
||||
setAttribute: vi.fn(),
|
||||
click: vi.fn(),
|
||||
style: {},
|
||||
href: '',
|
||||
download: '',
|
||||
parentNode: {
|
||||
removeChild: removeChild
|
||||
}
|
||||
};
|
||||
(globalThis as any).document = {
|
||||
createElement: vi.fn().mockReturnValue(link),
|
||||
body: {
|
||||
appendChild: appendChild,
|
||||
removeChild: removeChild,
|
||||
contains: vi.fn().mockReturnValue(true)
|
||||
}
|
||||
};
|
||||
(globalThis as any).window = {
|
||||
URL: {
|
||||
createObjectURL: vi.fn().mockReturnValue('blob:url'),
|
||||
revokeObjectURL: vi.fn()
|
||||
}
|
||||
};
|
||||
const link = document.createElement('a');
|
||||
vi.spyOn(link, 'click').mockImplementation(() => {});
|
||||
vi.spyOn(document, 'createElement').mockReturnValue(link);
|
||||
vi.spyOn(document.body, 'appendChild').mockImplementation(() => link);
|
||||
vi.spyOn(document.body, 'removeChild').mockImplementation(() => link);
|
||||
vi.spyOn(document.body, 'contains').mockReturnValue(true);
|
||||
vi.spyOn(URL, 'createObjectURL').mockReturnValue('blob:url');
|
||||
vi.spyOn(URL, 'revokeObjectURL').mockImplementation(() => {});
|
||||
|
||||
service.downloadFile('/api/file', 'file.txt');
|
||||
expect(httpClientMock.get).toHaveBeenCalledWith('/api/file', expect.objectContaining({observe: 'events'}));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {Title} from '@angular/platform-browser';
|
||||
import {PageTitleService} from './page-title.service';
|
||||
|
||||
@@ -135,7 +135,7 @@ describe('ReadingSessionApiService', () => {
|
||||
|
||||
it('should send beacon successfully', () => {
|
||||
const sendBeaconMock = vi.fn().mockReturnValue(true);
|
||||
(globalThis.navigator as any) = {sendBeacon: sendBeaconMock};
|
||||
vi.stubGlobal('navigator', {sendBeacon: sendBeaconMock});
|
||||
const result = service.sendSessionBeacon(mockSessionDto);
|
||||
expect(sendBeaconMock).toHaveBeenCalledWith(
|
||||
expect.stringContaining(BASE_URL),
|
||||
@@ -145,11 +145,11 @@ describe('ReadingSessionApiService', () => {
|
||||
});
|
||||
|
||||
it('should return false if sendBeacon throws', () => {
|
||||
(globalThis.navigator as any) = {
|
||||
vi.stubGlobal('navigator', {
|
||||
sendBeacon: vi.fn().mockImplementation(() => {
|
||||
throw new Error('fail');
|
||||
})
|
||||
};
|
||||
});
|
||||
const result = service.sendSessionBeacon(mockSessionDto);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
@@ -204,7 +204,7 @@ describe('ReadingSessionApiService - API Contract Tests', () => {
|
||||
|
||||
it('should send beacon to correct endpoint', () => {
|
||||
const sendBeaconMock = vi.fn().mockReturnValue(true);
|
||||
(globalThis.navigator as any) = {sendBeacon: sendBeaconMock};
|
||||
vi.stubGlobal('navigator', {sendBeacon: sendBeaconMock});
|
||||
const dto: CreateReadingSessionDto = {
|
||||
bookId: 1,
|
||||
bookType: 'PDF',
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {EnvironmentInjector, runInInjectionContext} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {of, throwError} from 'rxjs';
|
||||
import {AppVersion, ReleaseNote, VersionService} from './version.service';
|
||||
@@ -31,13 +30,11 @@ describe('VersionService', () => {
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
VersionService,
|
||||
{provide: HttpClient, useValue: httpClientMock}
|
||||
]
|
||||
});
|
||||
|
||||
const injector = TestBed.inject(EnvironmentInjector);
|
||||
service = runInInjectionContext(injector, () => TestBed.inject(VersionService));
|
||||
service = TestBed.inject(VersionService);
|
||||
});
|
||||
|
||||
it('should get version', () => {
|
||||
@@ -88,13 +85,11 @@ describe('VersionService - API Contract Tests', () => {
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
VersionService,
|
||||
{provide: HttpClient, useValue: httpClientMock}
|
||||
]
|
||||
});
|
||||
|
||||
const injector = TestBed.inject(EnvironmentInjector);
|
||||
service = runInInjectionContext(injector, () => TestBed.inject(VersionService));
|
||||
service = TestBed.inject(VersionService);
|
||||
});
|
||||
|
||||
it('should expect AppVersion from getVersion', () => {
|
||||
|
||||
Reference in New Issue
Block a user