feat(html): render warning message when served off file:// (#9908)

This commit is contained in:
Pavel Feldman 2021-10-31 16:36:05 -08:00 коммит произвёл GitHub
Родитель d6adff7792
Коммит 1f907f0cfc
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 45 добавлений и 7 удалений

Просмотреть файл

@ -248,13 +248,25 @@ if (!process.env.PW_CLI_TARGET_LANG) {
require(playwrightTestPackagePath).addTestCommand(program);
require(playwrightTestPackagePath).addShowReportCommand(program);
} else {
const command = program.command('test').allowUnknownOption(true);
command.description('Run tests with Playwright Test. Available in @playwright/test package.');
command.action(async () => {
console.error('Please install @playwright/test package to use Playwright Test.');
console.error(' npm install -D @playwright/test');
process.exit(1);
});
{
const command = program.command('test').allowUnknownOption(true);
command.description('Run tests with Playwright Test. Available in @playwright/test package.');
command.action(async () => {
console.error('Please install @playwright/test package to use Playwright Test.');
console.error(' npm install -D @playwright/test');
process.exit(1);
});
}
{
const command = program.command('show-report').allowUnknownOption(true);
command.description('Show Playwright Test HTML report. Available in @playwright/test package.');
command.action(async () => {
console.error('Please install @playwright/test package to use Playwright Test.');
console.error(' npm install -D @playwright/test');
process.exit(1);
});
}
}
}

Просмотреть файл

@ -446,6 +446,24 @@ a.no-decorations {
}
}
.needs-server-message {
max-width: 500px;
margin: auto;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
}
.bash-snippet {
margin-top: 10px;
font-family: monospace;
background: var(--color-fg-default);
color: var(--color-canvas-default);
border-radius: 6px;
padding: 20px;
}
.d-flex {
display: flex !important;
}

Просмотреть файл

@ -49,6 +49,14 @@ export const Report: React.FC = () => {
const filter = React.useMemo(() => Filter.parse(filterText), [filterText]);
if (window.location.protocol === 'file:') {
return <div className='needs-server-message'>
Playwright report needs to be served as a web page. Consider the following options to view it locally:
<div className='bash-snippet'>npx node-static playwright-report</div>
<div className='bash-snippet'>cd playwright-report &amp;&amp; python -m SimpleHTTPServer</div>
</div>;
}
return <div className='vbox columns'>
{!fetchError && <div className='flow-container'>
<Route params=''>