const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isMP = platformInfo.startsWith('mp')
describe('CSS Specificity', () => {
if (isMP) {
it('skip', () => {
expect(1).toBe(1)
})
return
}
let page;
const path = '/pages/CSS/specificity/specificity';
beforeAll(async () => {
page = await program.reLaunch(path);
await page.waitFor(2000);
});
it('Check Specificity Visuals', async () => {
const image = await program.screenshot({ fullPage: true });
expect(image).toSaveImageSnapshot();
});
async function getBorderColor(id) {
const element = await page.$(`#${id}`);
return await element.style('border-top-color');
}
it('should verify class chaining specificity', async () => {
const s1 = await getBorderColor('spec-multi-1');
const s2 = await getBorderColor('spec-multi-2');
const s3 = await getBorderColor('spec-multi-3');
expect(s1).not.toBe(s2);
expect(s2).not.toBe(s3);
});
it('should verify definition order wins regardless of alphabetical order', async () => {
const alpha = await getBorderColor('spec-alpha-1');
const zIndex = await getBorderColor('spec-alpha-2');
expect(alpha).not.toBe('');
expect(zIndex).not.toBe('');
});
it('should verify chained class order (anti-alphabetical sort bug check)', async () => {
const inverse = await getBorderColor('spec-chain-2');
const normal = await getBorderColor('spec-chain-1');
expect(inverse).toBe(normal);
});
});