Skip to content

Commit 30d31ac

Browse files
committed
Also check border wdith customization
1 parent 66df087 commit 30d31ac

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

tests/docs/playwright/revealjs/callouts/custom.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ $callout-color-tip: rgb(255, 255, 0);
55
$callout-color-important: rgb(128, 128, 128);
66
$callout-color-caution: rgb(0, 128, 0);
77
$callout-color-warning: rgb(173, 216, 230);
8+
9+
$callout-border-width: 10px;

tests/integration/playwright/src/utils.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,17 @@ export const checkClick = async (page: any, locator: any) => {
121121
return !error;
122122
};
123123

124-
export async function checkColor(element, cssProperty, rgbColors) {
124+
export type RGBColor = {
125+
red: number;
126+
green: number;
127+
blue: number;
128+
};
129+
130+
export async function checkColor(element, cssProperty, rgbColors: RGBColor) {
125131
await expect(element).toHaveCSS(cssProperty, `rgb(${rgbColors.red}, ${rgbColors.green}, ${rgbColors.blue})`);
126132
}
127133

128-
export function asRGB(red, green, blue) {
134+
export function asRGB(red: number, green: number, blue: number): RGBColor {
129135
return { red, green, blue };
130136
}
131137

tests/integration/playwright/tests/revealjs-themes.spec.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test, expect, Locator } from '@playwright/test';
2-
import { asRGB, checkColor, checkFontSizeIdentical, getCSSProperty } from '../src/utils';
2+
import { asRGB, checkColor, checkFontSizeIdentical, getCSSProperty, RGBColor } from '../src/utils';
33

44
async function getRevealMainFontSize(page: any): Promise<number> {
55
return await getCSSProperty(page.locator('body'), "--r-main-font-size", true) as number;
@@ -103,11 +103,15 @@ test('Code font size is correctly set', async ({ page }) => {
103103
).toBeCloseTo(codeBlockFontSize);
104104
});
105105

106-
test('Callouts colors can be customized', async ({ page }) => {
106+
test('Callouts can be customized using SCSS variables', async ({ page }) => {
107107
await page.goto('./revealjs/callouts/custom-colors.html');
108-
await checkColor(page.locator('div.callout-note'), 'border-left-color', asRGB(128, 0, 128));
109-
await checkColor(page.locator('div.callout-tip'), 'border-left-color', asRGB(255, 255, 0));
110-
await checkColor(page.locator('div.callout-warning'), 'border-left-color', asRGB(173, 216, 230));
111-
await checkColor(page.locator('div.callout-important'), 'border-left-color', asRGB(128, 128, 128));
112-
await checkColor(page.locator('div.callout-caution'), 'border-left-color', asRGB(0, 128, 0));
108+
async function checkCustom(loc: Locator, width: string, color: RGBColor) {
109+
await expect(loc).toHaveCSS('border-left-width', width);
110+
await checkColor(loc, 'border-left-color', color);
111+
}
112+
await checkCustom(page.locator('div.callout-note'), '10px', asRGB(128, 0, 128));
113+
await checkCustom(page.locator('div.callout-tip'), '10px', asRGB(255, 255, 0));
114+
await checkCustom(page.locator('div.callout-warning'), '10px', asRGB(173, 216, 230));
115+
await checkCustom(page.locator('div.callout-important'), '10px', asRGB(128, 128, 128));
116+
await checkCustom(page.locator('div.callout-caution'), '10px', asRGB(0, 128, 0));
113117
});

0 commit comments

Comments
 (0)