feat: expand admin companies and users modules
This commit is contained in:
parent
a043b1203c
commit
2e3b46a7b5
31 changed files with 5626 additions and 2003 deletions
61
tests/machines/remote-access.test.ts
Normal file
61
tests/machines/remote-access.test.ts
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
import { describe, expect, it } from "vitest"
|
||||
|
||||
import { normalizeMachineRemoteAccess } from "@/components/admin/machines/admin-machines-overview"
|
||||
|
||||
describe("normalizeMachineRemoteAccess", () => {
|
||||
it("returns null when value is empty", () => {
|
||||
expect(normalizeMachineRemoteAccess(undefined)).toBeNull()
|
||||
expect(normalizeMachineRemoteAccess(" ")).toBeNull()
|
||||
})
|
||||
|
||||
it("parses plain identifier strings", () => {
|
||||
const result = normalizeMachineRemoteAccess("PC-001")
|
||||
expect(result).toEqual({
|
||||
provider: null,
|
||||
identifier: "PC-001",
|
||||
url: null,
|
||||
notes: null,
|
||||
lastVerifiedAt: null,
|
||||
metadata: null,
|
||||
})
|
||||
})
|
||||
|
||||
it("detects URLs in string input", () => {
|
||||
const result = normalizeMachineRemoteAccess("https://remote.example.com/session/123")
|
||||
expect(result).toEqual({
|
||||
provider: null,
|
||||
identifier: null,
|
||||
url: "https://remote.example.com/session/123",
|
||||
notes: null,
|
||||
lastVerifiedAt: null,
|
||||
metadata: null,
|
||||
})
|
||||
})
|
||||
|
||||
it("normalizes object payload with aliases", () => {
|
||||
const timestamp = 1_701_234_567_890
|
||||
const result = normalizeMachineRemoteAccess({
|
||||
provider: "AnyDesk",
|
||||
code: "123-456-789",
|
||||
remoteUrl: "https://anydesk.com/session/123",
|
||||
note: "Suporte avançado",
|
||||
verifiedAt: timestamp,
|
||||
extraTag: "vip",
|
||||
})
|
||||
expect(result).toEqual({
|
||||
provider: "AnyDesk",
|
||||
identifier: "123-456-789",
|
||||
url: "https://anydesk.com/session/123",
|
||||
notes: "Suporte avançado",
|
||||
lastVerifiedAt: timestamp,
|
||||
metadata: {
|
||||
provider: "AnyDesk",
|
||||
code: "123-456-789",
|
||||
remoteUrl: "https://anydesk.com/session/123",
|
||||
note: "Suporte avançado",
|
||||
verifiedAt: timestamp,
|
||||
extraTag: "vip",
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue