mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-09 08:40:32 -06:00
* chore: use import type across repo * chore: use import type across repo * chore: use import type across repo * chore: use import type across repo * update exports * update test * update import type * update types * use import type in driver * correctly export function * revert test * remove unrelated code * revert code * improve type imports * override for reporter
34 lines
638 B
TypeScript
34 lines
638 B
TypeScript
import type { CyCookie } from './browsers/cdp_automation'
|
|
|
|
interface SessionData {
|
|
cookies: CyCookie[]
|
|
id: string
|
|
localStorage: object
|
|
sessionStorage: object
|
|
}
|
|
const state = {
|
|
sessions: {},
|
|
}
|
|
|
|
export function saveSession (data: SessionData) {
|
|
if (!data.id) throw new Error('session data had no id')
|
|
|
|
state.sessions[data.id] = data
|
|
}
|
|
|
|
export function getSession (id: string): SessionData {
|
|
const session = state.sessions[id]
|
|
|
|
if (!session) throw new Error(`session with id "${id}" not found`)
|
|
|
|
return session
|
|
}
|
|
|
|
export function getState () {
|
|
return state
|
|
}
|
|
|
|
export function clearSessions () {
|
|
state.sessions = {}
|
|
}
|