super-productivity/debug-headers.spec.ts
Johannes Millan b3158b008d refactor(e2e): use bundled hacdias/webdav instead of mock server
- Replace custom mock server with real hacdias/webdav:latest
- Use existing webdav.yaml configuration and alice/bob users
- Remove unnecessary mock server code following KISS principle
- WebDAV server now matches production setup exactly
- Persistent data storage in ./e2e-webdav-data

This provides more realistic e2e testing with the actual WebDAV
server used in production deployments.
2025-07-18 12:11:05 +02:00

46 lines
1.3 KiB
TypeScript

import { WebdavApi } from './src/app/pfapi/api/sync/providers/webdav/webdav-api';
import { WebdavPrivateCfg } from './src/app/pfapi/api/sync/providers/webdav/webdav';
import { createMockResponse } from './src/app/pfapi/api/sync/providers/webdav/webdav-api-test-utils';
describe('Debug Headers', () => {
let mockFetch: jasmine.Spy;
let api: WebdavApi;
const mockConfig: WebdavPrivateCfg = {
baseUrl: 'https://webdav.example.com',
userName: 'testuser',
password: 'testpass',
syncFolderPath: '/sync',
serverCapabilities: {
supportsETags: true,
supportsLastModified: false,
supportsIfHeader: true,
supportsLocking: false,
},
};
beforeEach(() => {
mockFetch = spyOn(globalThis, 'fetch');
api = new WebdavApi(async () => mockConfig);
});
it('should set If-None-Match for new file creation', async () => {
const uploadResponse = createMockResponse(201, {
etag: '"v1"',
});
mockFetch.and.callFake((url, options) => {
console.log('Called with:', url, JSON.stringify(options));
return Promise.resolve(uploadResponse);
});
const result = await api.upload({
path: '/test.txt',
data: 'content',
isOverwrite: false,
});
expect(result).toBe('v1');
expect(mockFetch).toHaveBeenCalled();
});
});