2021-12-13 18:30:48 -08:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2022-05-06 11:02:07 -08:00
|
|
|
import { test, expect } from '@playwright/experimental-ct-react';
|
2021-12-14 19:25:07 -08:00
|
|
|
import { HeaderView } from './headerView';
|
2021-12-13 18:30:48 -08:00
|
|
|
|
2021-12-14 19:25:07 -08:00
|
|
|
test.use({ viewport: { width: 720, height: 200 } });
|
2021-12-13 18:30:48 -08:00
|
|
|
|
2022-02-16 15:45:35 -08:00
|
|
|
test('should render counters', async ({ mount }) => {
|
|
|
|
const component = await mount(<HeaderView stats={{
|
2021-12-13 18:30:48 -08:00
|
|
|
total: 100,
|
|
|
|
expected: 42,
|
|
|
|
unexpected: 31,
|
|
|
|
flaky: 17,
|
|
|
|
skipped: 10,
|
|
|
|
ok: false,
|
|
|
|
duration: 100000
|
2021-12-14 19:25:07 -08:00
|
|
|
}} filterText='' setFilterText={() => {}}></HeaderView>);
|
2021-12-14 15:37:31 -08:00
|
|
|
await expect(component.locator('a', { hasText: 'All' }).locator('.counter')).toHaveText('100');
|
|
|
|
await expect(component.locator('a', { hasText: 'Passed' }).locator('.counter')).toHaveText('42');
|
|
|
|
await expect(component.locator('a', { hasText: 'Failed' }).locator('.counter')).toHaveText('31');
|
|
|
|
await expect(component.locator('a', { hasText: 'Flaky' }).locator('.counter')).toHaveText('17');
|
|
|
|
await expect(component.locator('a', { hasText: 'Skipped' }).locator('.counter')).toHaveText('10');
|
2021-12-13 18:30:48 -08:00
|
|
|
});
|
|
|
|
|
2022-02-16 15:45:35 -08:00
|
|
|
test('should toggle filters', async ({ page, mount: mount }) => {
|
2021-12-13 18:30:48 -08:00
|
|
|
const filters: string[] = [];
|
2022-02-16 15:45:35 -08:00
|
|
|
const component = await mount(<HeaderView
|
2021-12-14 19:25:07 -08:00
|
|
|
stats={{
|
|
|
|
total: 100,
|
|
|
|
expected: 42,
|
|
|
|
unexpected: 31,
|
|
|
|
flaky: 17,
|
|
|
|
skipped: 10,
|
|
|
|
ok: false,
|
|
|
|
duration: 100000
|
|
|
|
}}
|
|
|
|
filterText=''
|
|
|
|
setFilterText={(filterText: string) => filters.push(filterText)}>
|
|
|
|
</HeaderView>);
|
2021-12-14 15:37:31 -08:00
|
|
|
await component.locator('a', { hasText: 'All' }).click();
|
|
|
|
await component.locator('a', { hasText: 'Passed' }).click();
|
2021-12-13 18:30:48 -08:00
|
|
|
await expect(page).toHaveURL(/#\?q=s:passed/);
|
2021-12-14 15:37:31 -08:00
|
|
|
await component.locator('a', { hasText: 'Failed' }).click();
|
2021-12-13 18:30:48 -08:00
|
|
|
await expect(page).toHaveURL(/#\?q=s:failed/);
|
2021-12-14 15:37:31 -08:00
|
|
|
await component.locator('a', { hasText: 'Flaky' }).click();
|
2021-12-13 18:30:48 -08:00
|
|
|
await expect(page).toHaveURL(/#\?q=s:flaky/);
|
2021-12-14 15:37:31 -08:00
|
|
|
await component.locator('a', { hasText: 'Skipped' }).click();
|
2021-12-13 18:30:48 -08:00
|
|
|
await expect(page).toHaveURL(/#\?q=s:skipped/);
|
|
|
|
expect(filters).toEqual(['', 's:passed', 's:failed', 's:flaky', 's:skipped']);
|
|
|
|
});
|