Skip to content

Commit dab9757

Browse files
committed
test(tab-bar): add more layouts
1 parent a90a769 commit dab9757

28 files changed

Lines changed: 47 additions & 20 deletions

File tree

core/src/components/tab-button/test/badge/badge.e2e.ts

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { configs, test } from '@utils/test/playwright';
44
configs({ directions: ['ltr'], modes: ['md', 'ios', 'ionic-md'] }).forEach(({ config, screenshot, title }) => {
55
test.describe(title('tab-button: badge'), () => {
66
const positions = ['top', 'bottom'];
7-
const layouts = ['icon-top', 'icon-bottom'];
7+
const layouts = ['icon-top', 'icon-bottom', 'icon-start', 'icon-end', 'icon-hide', 'label-hide'];
88
const icons = ['star', 'globe', 'logo-facebook', 'chatbox'];
99
const colors = ['danger', 'primary', 'warning', 'success'];
1010
const contents = ['', '1', '999+', '<ion-icon icon="star"></ion-icon>'];
@@ -18,42 +18,69 @@ configs({ directions: ['ltr'], modes: ['md', 'ios', 'ionic-md'] }).forEach(({ co
1818
['small', 'medium', 'large'].forEach((badgeSize) => {
1919
test(`should not have visual regressions with ${badgeSize} badges`, async ({ page }) => {
2020
const tabBars = positions
21-
.flatMap((position) =>
22-
slotVariants.flatMap((variant) =>
23-
layouts.map((layout) => {
24-
const tabs = contents
25-
.map((html, i) => {
26-
const label = variant.hasLabel ? `<ion-label>Tab ${i + 1}</ion-label>` : '';
27-
const icon = variant.hasIcon ? `<ion-icon name="${icons[i]}"></ion-icon>` : '';
21+
.map((position) => {
22+
const variantGroups = slotVariants
23+
.map((variant) => {
24+
const layoutRows = layouts
25+
.map((layout) => {
26+
const tabs = contents
27+
.map((html, i) => {
28+
const label = variant.hasLabel ? `<ion-label>Tab ${i + 1}</ion-label>` : '';
29+
const icon = variant.hasIcon ? `<ion-icon name="${icons[i]}"></ion-icon>` : '';
30+
31+
return `
32+
<ion-tab-button tab="tab-${position}-${variant.label}-${layout}-${i}" layout="${layout}">
33+
${label}
34+
${icon}
35+
<ion-badge hue="bold" shape="round" color="${colors[i]}" size="${badgeSize}" vertical="${position}">${html}</ion-badge>
36+
</ion-tab-button>
37+
`;
38+
})
39+
.join('\n');
2840

2941
return `
30-
<ion-tab-button tab="tab-${position}-${variant.label}-${layout}-${i}" layout="${layout}">
31-
${label}
32-
${icon}
33-
<ion-badge hue="bold" shape="round" color="${colors[i]}" size="${badgeSize}" vertical="${position}">${html}</ion-badge>
34-
</ion-tab-button>
35-
`;
42+
<h4>${layout}</h4>
43+
<ion-tab-bar>${tabs}</ion-tab-bar>
44+
`;
3645
})
3746
.join('\n');
3847

3948
return `
40-
<h2>badge position: ${position} / icon layout: ${layout}</h2>
41-
<ion-tab-bar>${tabs}</ion-tab-bar>
49+
<h3>${variant.label}</h3>
50+
${layoutRows}
4251
`;
4352
})
44-
)
45-
)
53+
.join('\n');
54+
55+
return `
56+
<h2>badge position: ${position}</h2>
57+
${variantGroups}
58+
`;
59+
})
4660
.join('\n');
4761

4862
await page.setContent(
4963
`
5064
<style>
5165
h2 {
66+
font-size: 12px;
67+
font-weight: 600;
68+
color: #3c3f44;
69+
margin: 14px 0 4px 0;
70+
}
71+
72+
h3 {
5273
font-size: 12px;
5374
font-weight: normal;
5475
color: #6f7378;
55-
margin-top: 10px;
56-
margin-left: 5px;
76+
margin: 8px 0 2px 8px;
77+
}
78+
79+
h4 {
80+
font-size: 11px;
81+
font-weight: normal;
82+
color: #9ba0a6;
83+
margin: 4px 0 2px 16px;
5784
}
5885
</style>
5986
<div id="container">
Loading
Loading
Loading
93.9 KB
Loading
137 KB
Loading
122 KB
Loading
91.7 KB
Loading
127 KB
Loading
107 KB
Loading

0 commit comments

Comments
 (0)