| | |
| | | |
| | | function standardFile(type, invalid = false) { |
| | | const fields = consoleImportColumns[type] |
| | | const row = { recordNo: '17', batteryNo: 'BAT-1', recordedAt: '2023-05-08 11:42:11', cycleNo: 1, stepNo: 1, stepName: '恒流放电', sequenceId: 17, capacity: 8.5122, temperature: 25, positivePotential: 1.5, negativePotential: -0.1 } |
| | | const row = { recordNo: '17', batteryNo: 'BAT-1', recordedAt: '2023-05-08 11:42:11', cycleNo: 1, stepNo: 1, stepName: '恒流放电', sequenceId: 17, capacity: 8.5122, temperature: 25, positivePotential: 1.5, negativePotential: -0.1, chargeMedianVoltage: 0, dischargeMedianVoltage: 1.1709 } |
| | | const rows = [Object.values(fields), Object.keys(fields).map(field => row[field] ?? '')] |
| | | if (invalid) { |
| | | while (rows.length < 19) rows.push([]) |
| | |
| | | source[XLSX.utils.encode_cell({ r: row + 1, c: column + 10 })]?.v ?? null)) |
| | | } |
| | | } |
| | | } |
| | | if (process.env.PARTY_EXCEL) { |
| | | const imported = JSON.parse(calls.find(call => call.dataType === 'STEP').changesSummary) |
| | | const source = XLSX.utils.sheet_to_json(XLSX.readFile(process.env.PARTY_EXCEL).Sheets.step) |
| | | assert.deepEqual(imported.map(row => [row.chargeMedianVoltage, row.dischargeMedianVoltage]), |
| | | source.map(row => [row['充电中值电压(V)'], row['放电中值电压(V)']])) |
| | | } |
| | | await page.goto(`${origin}/test-list/1/console/data/import?dataType=REALTIME`) |
| | | await page.locator('input[type=file]').setInputFiles(standardFile('REALTIME', true)) |
| | |
| | | await expect(page.locator('.table-wrap tbody')).toContainText('BAT-1') |
| | | await page.reload() |
| | | await expect(page.locator('.table-wrap tbody')).toContainText('BAT-1') |
| | | if (type === 'STEP') { |
| | | await expect(page.locator('.table-wrap thead')).toContainText('充电中值电压(V)') |
| | | await expect(page.locator('.table-wrap thead')).toContainText('放电中值电压(V)') |
| | | await expect(page.locator('.table-wrap tbody')).toContainText('0.0000') |
| | | await expect(page.locator('.table-wrap tbody')).toContainText('1.1709') |
| | | const csvEvent = page.waitForEvent('download') |
| | | await page.getByRole('button', { name: '下载', exact: true }).click() |
| | | const csv = await readFile(await (await csvEvent).path(), 'utf8') |
| | | assert.match(csv, /充电中值电压\(V\)/) |
| | | assert.match(csv, /放电中值电压\(V\)/) |
| | | assert.match(csv, /"0\.0000","1\.1709"/) |
| | | assert.doesNotMatch(csv, /峰值|谷值/) |
| | | } |
| | | } |
| | | assert.deepEqual(errors, []) |
| | | console.log('Ticket03/04 浏览器:独立模板、一键模板、三 Sheet 预览、错误下载和阻断、单次提交原因与批次、子页刷新及窄屏通过;导入未请求实时监控') |