mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00

API changes: - `test(title, details, body)` where details contain `tag` and `annotation`. - similar `details` property added to `test.skip`, `test.fail`, `test.fixme`, `test.only`, `test.describe` and other `test.describe.*` variations. - `TestProject.tagFilter`/`TestConfig.tagFilter` that supports logical tag expressions with `(`, `)`, `and`, `or` and `not`. - `--tag` CLI option to filter by tags. - New annotations are available in `TestInfo.annotations` and `TestCase.annotations`. - New tags are available in `TestCase.tags`. Reporter changes: - `json` reporter includes new tags in addition to old `@smoke`-style tags. **Breaking**: tags are now listed with the leading `@` symbol. - `html` reporter filters by old and new tags with the same `@smoke` token. Fixes #29229, fixes #23180.
77 lines
2.6 KiB
TypeScript
77 lines
2.6 KiB
TypeScript
/**
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
import React from 'react';
|
|
import { test, expect } from '@playwright/experimental-ct-react';
|
|
import { TestCaseView } from './testCaseView';
|
|
import type { TestCase, TestResult } from './types';
|
|
|
|
test.use({ viewport: { width: 800, height: 600 } });
|
|
|
|
const result: TestResult = {
|
|
retry: 0,
|
|
startTime: new Date(0).toUTCString(),
|
|
duration: 100,
|
|
errors: [],
|
|
steps: [{
|
|
title: 'Outer step',
|
|
startTime: new Date(100).toUTCString(),
|
|
duration: 10,
|
|
location: { file: 'test.spec.ts', line: 62, column: 0 },
|
|
count: 1,
|
|
steps: [{
|
|
title: 'Inner step',
|
|
startTime: new Date(200).toUTCString(),
|
|
duration: 10,
|
|
location: { file: 'test.spec.ts', line: 82, column: 0 },
|
|
steps: [],
|
|
count: 1,
|
|
}],
|
|
}],
|
|
attachments: [],
|
|
status: 'passed',
|
|
};
|
|
|
|
const testCase: TestCase = {
|
|
testId: 'testid',
|
|
title: 'My test',
|
|
path: [],
|
|
projectName: 'chromium',
|
|
location: { file: 'test.spec.ts', line: 42, column: 0 },
|
|
annotations: [
|
|
{ type: 'annotation', description: 'Annotation text' },
|
|
{ type: 'annotation', description: 'Another annotation text' },
|
|
],
|
|
tags: [],
|
|
outcome: 'expected',
|
|
duration: 10,
|
|
ok: true,
|
|
results: [result]
|
|
};
|
|
|
|
test('should render test case', async ({ mount }) => {
|
|
const component = await mount(<TestCaseView projectNames={['chromium', 'webkit']} test={testCase} run={0} anchor=''></TestCaseView>);
|
|
await expect(component.getByText('Annotation text', { exact: false }).first()).toBeVisible();
|
|
await component.getByText('Annotations').click();
|
|
await expect(component.getByText('Annotation text')).not.toBeVisible();
|
|
await expect(component.getByText('Outer step')).toBeVisible();
|
|
await expect(component.getByText('Inner step')).not.toBeVisible();
|
|
await component.getByText('Outer step').click();
|
|
await expect(component.getByText('Inner step')).toBeVisible();
|
|
await expect(component.getByText('test.spec.ts:42')).toBeVisible();
|
|
await expect(component.getByText('My test')).toBeVisible();
|
|
});
|