mirror of
https://github.com/heyman/heynote.git
synced 2024-11-28 10:54:22 +01:00
Add tests for custom fonts
This commit is contained in:
parent
f0927add74
commit
090b6fc1dd
66
tests/custom-font.spec.js
Normal file
66
tests/custom-font.spec.js
Normal file
@ -0,0 +1,66 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { HeynotePage } from "./test-utils.js";
|
||||
|
||||
let heynotePage
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
heynotePage = new HeynotePage(page)
|
||||
await heynotePage.goto()
|
||||
});
|
||||
|
||||
test("test default font is Hack", async ({ page }) => {
|
||||
await page.locator("body").pressSequentially("hey")
|
||||
const line = await page.locator("css=.cm-activeLine")
|
||||
expect(await line.evaluate((el) => {
|
||||
return window.getComputedStyle(el).getPropertyValue("font-family")
|
||||
})).toBe("Hack")
|
||||
expect(await line.evaluate((el) => {
|
||||
return window.getComputedStyle(el).getPropertyValue("font-size")
|
||||
})).toBe("12px")
|
||||
expect(await line.evaluate((el) => {
|
||||
return el.clientHeight
|
||||
})).toBeLessThan(20)
|
||||
})
|
||||
|
||||
test("test custom font", async ({ page, browserName }) => {
|
||||
// monkey patch window.queryLocalFonts because it's not available in Playwright
|
||||
await page.evaluate(() => {
|
||||
window.queryLocalFonts = async () => {
|
||||
return [
|
||||
{
|
||||
family: "Arial",
|
||||
style: "Regular",
|
||||
},
|
||||
{
|
||||
family: "Hack",
|
||||
fullName: "Hack Regular",
|
||||
style: "Regular",
|
||||
postscriptName: "Hack-Regular",
|
||||
},
|
||||
{
|
||||
family: "Hack",
|
||||
fullName: "Hack Italic",
|
||||
style: "Italic",
|
||||
postscriptName: "Hack-Italic",
|
||||
},
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
await page.locator("css=.status-block.settings").click()
|
||||
await page.locator("css=li.tab-appearance").click()
|
||||
await page.locator("css=select.font-family").selectOption("Arial")
|
||||
await page.locator("css=select.font-size").selectOption("20")
|
||||
await page.locator("body").press("Escape")
|
||||
await page.locator("body").pressSequentially("hey")
|
||||
const line = await page.locator("css=.cm-activeLine")
|
||||
expect(await line.evaluate((el) => {
|
||||
return window.getComputedStyle(el).getPropertyValue("font-family")
|
||||
})).toBe("Arial")
|
||||
expect(await line.evaluate((el) => {
|
||||
return window.getComputedStyle(el).getPropertyValue("font-size")
|
||||
})).toBe("20px")
|
||||
expect(await line.evaluate((el) => {
|
||||
return el.clientHeight
|
||||
})).toBeGreaterThan(20)
|
||||
})
|
Loading…
Reference in New Issue
Block a user