feat: 前端集成 Prettier 代码格式化
This commit is contained in:
@@ -27,9 +27,7 @@ export interface SeedStatsInput {
|
||||
date: string
|
||||
}
|
||||
|
||||
export async function clearDatabase(
|
||||
request: import('@playwright/test').APIRequestContext,
|
||||
) {
|
||||
export async function clearDatabase(request: import('@playwright/test').APIRequestContext) {
|
||||
const providers = await request.get(`${API_BASE}/api/providers`)
|
||||
if (providers.ok()) {
|
||||
const data = await providers.json()
|
||||
@@ -39,10 +37,7 @@ export async function clearDatabase(
|
||||
}
|
||||
}
|
||||
|
||||
export async function seedProvider(
|
||||
request: import('@playwright/test').APIRequestContext,
|
||||
data: SeedProviderInput,
|
||||
) {
|
||||
export async function seedProvider(request: import('@playwright/test').APIRequestContext, data: SeedProviderInput) {
|
||||
const resp = await request.post(`${API_BASE}/api/providers`, {
|
||||
data: {
|
||||
id: data.id,
|
||||
@@ -59,10 +54,7 @@ export async function seedProvider(
|
||||
return resp.json()
|
||||
}
|
||||
|
||||
export async function seedModel(
|
||||
request: import('@playwright/test').APIRequestContext,
|
||||
data: SeedModelInput,
|
||||
) {
|
||||
export async function seedModel(request: import('@playwright/test').APIRequestContext, data: SeedModelInput) {
|
||||
const resp = await request.post(`${API_BASE}/api/models`, {
|
||||
data: {
|
||||
provider_id: data.providerId,
|
||||
@@ -80,20 +72,22 @@ export async function seedUsageStats(statsData: SeedStatsInput[]) {
|
||||
const tempDir = path.join(os.tmpdir(), 'nex-e2e')
|
||||
|
||||
const dbPath = path.join(tempDir, 'test.db')
|
||||
|
||||
|
||||
if (!fs.existsSync(dbPath)) {
|
||||
throw new Error(`Database file not found at ${dbPath}. Backend may not have created it yet.`)
|
||||
}
|
||||
|
||||
|
||||
const SQL = await initSqlite()
|
||||
const buf = fs.readFileSync(dbPath)
|
||||
const db = new SQL.Database(buf)
|
||||
|
||||
for (const row of statsData) {
|
||||
db.run(
|
||||
'INSERT OR REPLACE INTO usage_stats (provider_id, model_name, request_count, date) VALUES (?, ?, ?, ?)',
|
||||
[row.providerId, row.modelName, row.requestCount, row.date],
|
||||
)
|
||||
db.run('INSERT OR REPLACE INTO usage_stats (provider_id, model_name, request_count, date) VALUES (?, ?, ?, ?)', [
|
||||
row.providerId,
|
||||
row.modelName,
|
||||
row.requestCount,
|
||||
row.date,
|
||||
])
|
||||
}
|
||||
|
||||
const data = db.export()
|
||||
|
||||
Reference in New Issue
Block a user