|
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | 16 |
|
| 17 | +import fs from 'fs/promises'; |
| 18 | +import path from 'path'; |
| 19 | + |
17 | 20 | import { test, expect } from './cli-fixtures'; |
18 | 21 |
|
| 22 | +test('downloads with the same suggested filename', { |
| 23 | + annotation: { type: 'issue', description: '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/microsoft/playwright-cli/issues/514' }, |
| 24 | +}, async ({ cli, server }, testInfo) => { |
| 25 | + server.setContent('/', ` |
| 26 | + <a href="/v1" download="same.txt">V1</a> |
| 27 | + <a href="/v2" download="same.txt">V2</a> |
| 28 | + `, 'text/html'); |
| 29 | + server.setContent('/v1', 'v1', 'text/plain'); |
| 30 | + server.setContent('/v2', 'v2', 'text/plain'); |
| 31 | + |
| 32 | + await cli('open', server.PREFIX); |
| 33 | + for (const [ref, filename] of [['e2', 'same.txt'], ['e3', 'same-1.txt']]) { |
| 34 | + let { output } = await cli('click', ref); |
| 35 | + await expect.poll(async () => { |
| 36 | + output += '\n' + (await cli('snapshot')).output; |
| 37 | + return output; |
| 38 | + }).toContain(`Downloaded file same.txt to "${path.join('.playwright-cli', filename)}"`); |
| 39 | + } |
| 40 | + expect(await fs.readFile(testInfo.outputPath('.playwright-cli', 'same.txt'), 'utf8')).toBe('v1'); |
| 41 | + expect(await fs.readFile(testInfo.outputPath('.playwright-cli', 'same-1.txt'), 'utf8')).toBe('v2'); |
| 42 | +}); |
| 43 | + |
19 | 44 | test('screenshot', async ({ cli, server, mcpBrowser }) => { |
20 | 45 | await cli('open', server.HELLO_WORLD); |
21 | 46 | const { attachments } = await cli('screenshot'); |
|
0 commit comments