Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
release: SnapCAD Studio 1.0.10 (desktop menuler, macOS kisayollari, YakNet SSO)
Build and Push Docker Images / build (push) Canceled after 0s
Desktop Release / Build linux desktop (push) Canceled after 0s
Desktop Release / Build windows desktop (push) Canceled after 0s
Desktop Release / Attach packages to release (push) Canceled after 0s
Desktop Release / Build macos desktop (push) Canceled after 0s
CI / Typecheck and unit tests (push) Canceled after 0s
Build and Push Docker Images / build (push) Canceled after 0s
Desktop Release / Build linux desktop (push) Canceled after 0s
Desktop Release / Build windows desktop (push) Canceled after 0s
Desktop Release / Attach packages to release (push) Canceled after 0s
Desktop Release / Build macos desktop (push) Canceled after 0s
CI / Typecheck and unit tests (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { cloudApiFetch } from "../../apps/web/src/lib/cloudApi";
|
||||
import type { SnapCadDesktopBridge } from "../../apps/web/src/types/desktop";
|
||||
|
||||
describe("cloudApiFetch", () => {
|
||||
const globalAny = globalThis as unknown as {
|
||||
window?: Partial<Window>;
|
||||
fetch?: typeof fetch;
|
||||
};
|
||||
const originalWindow = globalAny.window;
|
||||
const originalFetch = globalAny.fetch;
|
||||
|
||||
afterEach(() => {
|
||||
globalAny.window = originalWindow;
|
||||
globalAny.fetch = originalFetch;
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it("rejects non-cloud-api paths before attempting network or IPC", async () => {
|
||||
await expect(cloudApiFetch("https://evil.example/api")).rejects.toThrow(/Geçersiz bulut API yolu/);
|
||||
await expect(cloudApiFetch("/login.php")).rejects.toThrow(/Geçersiz bulut API yolu/);
|
||||
});
|
||||
|
||||
it("routes /cloud-api.php requests through Electron IPC bridge in desktop runtime", async () => {
|
||||
const cloudRequest = vi.fn(async () => ({
|
||||
ok: true,
|
||||
status: 200,
|
||||
bodyText: JSON.stringify({ ok: true, authenticated: true, user: { id: 7, name: "Mimar", email: "[email protected]" } }),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
}));
|
||||
|
||||
const webFetch = vi.fn();
|
||||
globalAny.fetch = webFetch as unknown as typeof fetch;
|
||||
globalAny.window = {
|
||||
snapcadDesktop: {
|
||||
isDesktop: true,
|
||||
getVersion: async () => "1.0.10",
|
||||
checkForUpdates: async () => ({
|
||||
currentVersion: "1.0.10",
|
||||
latestVersion: null,
|
||||
updateAvailable: false,
|
||||
downloaded: false,
|
||||
checkedAt: "2026-01-01T00:00:00.000Z",
|
||||
}),
|
||||
installUpdate: async () => ({
|
||||
currentVersion: "1.0.10",
|
||||
latestVersion: null,
|
||||
updateAvailable: false,
|
||||
downloaded: false,
|
||||
checkedAt: "2026-01-01T00:00:00.000Z",
|
||||
}),
|
||||
cloudRequest,
|
||||
} satisfies SnapCadDesktopBridge,
|
||||
};
|
||||
|
||||
const res = await cloudApiFetch("/cloud-api.php?action=session", { cache: "no-store" });
|
||||
expect(res.ok).toBe(true);
|
||||
expect(res.status).toBe(200);
|
||||
expect(cloudRequest).toHaveBeenCalledWith({
|
||||
path: "/cloud-api.php?action=session",
|
||||
method: "GET",
|
||||
headers: undefined,
|
||||
body: undefined,
|
||||
});
|
||||
expect(webFetch).not.toHaveBeenCalled();
|
||||
|
||||
const json = (await res.json()) as { ok: boolean; user?: { name: string } };
|
||||
expect(json.ok).toBe(true);
|
||||
expect(json.user?.name).toBe("Mimar");
|
||||
});
|
||||
|
||||
it("throws when Electron IPC cloud proxy encounters a transport error (status 0)", async () => {
|
||||
globalAny.window = {
|
||||
snapcadDesktop: {
|
||||
isDesktop: true,
|
||||
getVersion: async () => "1.0.10",
|
||||
checkForUpdates: async () => ({
|
||||
currentVersion: "1.0.10",
|
||||
latestVersion: null,
|
||||
updateAvailable: false,
|
||||
downloaded: false,
|
||||
checkedAt: "2026-01-01T00:00:00.000Z",
|
||||
}),
|
||||
installUpdate: async () => ({
|
||||
currentVersion: "1.0.10",
|
||||
latestVersion: null,
|
||||
updateAvailable: false,
|
||||
downloaded: false,
|
||||
checkedAt: "2026-01-01T00:00:00.000Z",
|
||||
}),
|
||||
cloudRequest: async () => ({
|
||||
ok: false,
|
||||
status: 0,
|
||||
bodyText: "",
|
||||
error: "Ağ bağlantısı kesildi.",
|
||||
}),
|
||||
} satisfies SnapCadDesktopBridge,
|
||||
};
|
||||
|
||||
await expect(cloudApiFetch("/cloud-api.php?action=session")).rejects.toThrow("Ağ bağlantısı kesildi.");
|
||||
});
|
||||
|
||||
it("falls back to standard fetch in browser builds", async () => {
|
||||
const mockResponse = new Response(JSON.stringify({ ok: true, authenticated: false }), {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
const webFetch = vi.fn(async () => mockResponse);
|
||||
globalAny.window = {};
|
||||
globalAny.fetch = webFetch as unknown as typeof fetch;
|
||||
|
||||
const res = await cloudApiFetch("/cloud-api.php?action=sync_all", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ action: "sync_all", projects: [] }),
|
||||
});
|
||||
|
||||
expect(webFetch).toHaveBeenCalledTimes(1);
|
||||
expect(res.ok).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user