Update hardcover sync information text
This commit is contained in:
+3
-2
@@ -29,7 +29,8 @@
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Sync Reading Progress to Hardcover</label>
|
||||
<label class="setting-label">
|
||||
Sync KOReader Reading Progress to Hardcover</label>
|
||||
<p-toggle-switch
|
||||
id="hardcoverSyncEnabled"
|
||||
name="hardcoverSyncEnabled"
|
||||
@@ -38,7 +39,7 @@
|
||||
</p-toggle-switch>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
When enabled, your reading progress will be automatically synced to your Hardcover account.
|
||||
When enabled, your KOReader reading progress will be automatically synced to your Hardcover account.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@
|
||||
margin-right: 1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2rem;
|
||||
gap: 1.25rem;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
padding: 1rem;
|
||||
|
||||
+22
-21
@@ -1,5 +1,5 @@
|
||||
import {beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {BehaviorSubject, of, throwError} from 'rxjs';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {NO_ERRORS_SCHEMA} from '@angular/core';
|
||||
@@ -8,8 +8,6 @@ import {HardcoverSyncSettingsService} from './hardcover-sync-settings.service';
|
||||
import {UserService, UserState} from '../../../user-management/user.service';
|
||||
|
||||
describe('HardcoverSettingsComponent', () => {
|
||||
let fixture: ComponentFixture<HardcoverSettingsComponent>;
|
||||
let component: HardcoverSettingsComponent;
|
||||
let settingsServiceMock: any;
|
||||
let messageServiceMock: any;
|
||||
let userState$: BehaviorSubject<UserState>;
|
||||
@@ -56,7 +54,7 @@ describe('HardcoverSettingsComponent', () => {
|
||||
}
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
beforeEach(() => {
|
||||
settingsServiceMock = {
|
||||
getSettings: vi.fn(),
|
||||
updateSettings: vi.fn()
|
||||
@@ -66,7 +64,7 @@ describe('HardcoverSettingsComponent', () => {
|
||||
};
|
||||
userState$ = new BehaviorSubject<UserState>(makeState());
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HardcoverSettingsComponent],
|
||||
providers: [
|
||||
{provide: HardcoverSyncSettingsService, useValue: settingsServiceMock},
|
||||
@@ -74,13 +72,10 @@ describe('HardcoverSettingsComponent', () => {
|
||||
{provide: UserService, useValue: {userState$: userState$}}
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(HardcoverSettingsComponent);
|
||||
component = fixture.componentInstance;
|
||||
});
|
||||
});
|
||||
|
||||
it('should load settings when user has permission', () => {
|
||||
it('should load settings when user has permission', async () => {
|
||||
settingsServiceMock.getSettings.mockReturnValue(of({hardcoverSyncEnabled: true, hardcoverApiKey: 'key'}));
|
||||
userState$.next(makeState({
|
||||
permissions: {
|
||||
@@ -89,48 +84,55 @@ describe('HardcoverSettingsComponent', () => {
|
||||
}
|
||||
}) as UserState);
|
||||
|
||||
const fixture = TestBed.createComponent(HardcoverSettingsComponent);
|
||||
const component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(settingsServiceMock.getSettings).toHaveBeenCalled();
|
||||
expect(component.hardcoverSyncEnabled).toBe(true);
|
||||
expect(component.hardcoverApiKey).toBe('key');
|
||||
});
|
||||
|
||||
it('should not load settings without permission', () => {
|
||||
it('should not load settings without permission', async () => {
|
||||
settingsServiceMock.getSettings.mockReturnValue(of({}));
|
||||
userState$.next(makeState());
|
||||
const fixture = TestBed.createComponent(HardcoverSettingsComponent);
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
expect(settingsServiceMock.getSettings).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should update settings on toggle', () => {
|
||||
it('should update settings on toggle', async () => {
|
||||
settingsServiceMock.updateSettings.mockReturnValue(of({hardcoverSyncEnabled: false, hardcoverApiKey: 'k'}));
|
||||
const fixture = TestBed.createComponent(HardcoverSettingsComponent);
|
||||
const component = fixture.componentInstance;
|
||||
component.hardcoverSyncEnabled = false;
|
||||
component.hardcoverApiKey = 'k';
|
||||
|
||||
component.onHardcoverSyncToggle();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(settingsServiceMock.updateSettings).toHaveBeenCalledWith({
|
||||
hardcoverSyncEnabled: false,
|
||||
hardcoverApiKey: 'k'
|
||||
});
|
||||
expect(messageServiceMock.add).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should handle update error', () => {
|
||||
it('should handle update error', async () => {
|
||||
settingsServiceMock.updateSettings.mockReturnValue(throwError(() => new Error('fail')));
|
||||
const fixture = TestBed.createComponent(HardcoverSettingsComponent);
|
||||
const component = fixture.componentInstance;
|
||||
component.hardcoverSyncEnabled = true;
|
||||
component.hardcoverApiKey = 'k';
|
||||
|
||||
component.onHardcoverApiKeyChange();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(settingsServiceMock.updateSettings).toHaveBeenCalled();
|
||||
expect(messageServiceMock.add).toHaveBeenCalledWith(expect.objectContaining({
|
||||
severity: 'error'
|
||||
}));
|
||||
});
|
||||
|
||||
it('should handle load error', () => {
|
||||
it('should handle load error', async () => {
|
||||
settingsServiceMock.getSettings.mockReturnValue(throwError(() => new Error('fail')));
|
||||
userState$.next(makeState({
|
||||
permissions: {
|
||||
@@ -139,11 +141,10 @@ describe('HardcoverSettingsComponent', () => {
|
||||
}
|
||||
}) as UserState);
|
||||
|
||||
const fixture = TestBed.createComponent(HardcoverSettingsComponent);
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(settingsServiceMock.getSettings).toHaveBeenCalled();
|
||||
expect(messageServiceMock.add).toHaveBeenCalledWith(expect.objectContaining({
|
||||
severity: 'error'
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user