R7E 无人工操作自动化证据回填
这个提交包含在:
@@ -157,6 +157,48 @@ export async function createAuthenticatedApiClient(user: E2EUser, baseURL = E2E_
|
||||
};
|
||||
}
|
||||
|
||||
export async function createAuthenticatedBrowserStorageState(user: E2EUser, baseURL = E2E_BASE_URL) {
|
||||
const deviceFingerprint = buildDeviceFingerprint(user);
|
||||
const loginContext = await playwrightRequest.newContext({
|
||||
baseURL,
|
||||
extraHTTPHeaders: {
|
||||
"x-device-fingerprint": deviceFingerprint,
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
const loginResponse = await loginContext.post("/api/auth/login", {
|
||||
data: {
|
||||
identifier: user.identifier,
|
||||
password: user.password,
|
||||
},
|
||||
});
|
||||
|
||||
await readJson<{ accessToken: string }>(loginResponse);
|
||||
const state = await loginContext.storageState();
|
||||
const origin = new URL(baseURL).origin;
|
||||
const originState = state.origins.find((item) => item.origin === origin);
|
||||
const deviceFingerprintEntry = {
|
||||
name: "hyb_oa_device_fingerprint",
|
||||
value: deviceFingerprint,
|
||||
};
|
||||
|
||||
if (originState) {
|
||||
originState.localStorage = originState.localStorage.filter((item) => item.name !== deviceFingerprintEntry.name);
|
||||
originState.localStorage.push(deviceFingerprintEntry);
|
||||
} else {
|
||||
state.origins.push({
|
||||
origin,
|
||||
localStorage: [deviceFingerprintEntry],
|
||||
});
|
||||
}
|
||||
|
||||
return state;
|
||||
} finally {
|
||||
await loginContext.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
export async function apiGetData<T>(api: APIRequestContext, path: string) {
|
||||
const response = await api.get(path);
|
||||
return readJson<T>(response);
|
||||
|
||||
在新工单中引用
屏蔽一个用户