-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix pretty_num() raising TypeError: Cannot read properties of null (r…
…eading 'toExponential') and add test asserting no errors besides missing images on hovering all 118 elements on some actinides: Fm (100), Md, No, Lr (103)
- Loading branch information
Showing
3 changed files
with
61 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,61 @@ | ||
import { expect, test } from '@playwright/test' | ||
import { category_counts } from './element-data.test.ts' | ||
|
||
test(`periodic table in default state`, async ({ page }) => { | ||
await page.goto(`/`) | ||
|
||
expect(await page.$$(`.element-tile`)).toHaveLength(118) | ||
|
||
for (const [category, count] of Object.entries(category_counts)) { | ||
const css_cls = `.${category.replaceAll(` `, `-`)}` | ||
expect(await page.$$(css_cls)).toHaveLength(count as number) | ||
} | ||
}) | ||
|
||
test(`periodic table shows stats on hover element`, async ({ page }) => { | ||
await page.goto(`/`) | ||
|
||
await page.hover(`text=Hydrogen`) | ||
|
||
expect(await page.$(`text=1 - Hydrogen diatomic nonmetal`)).not.toBeNull() | ||
}) | ||
|
||
test(`periodic table in heatmap mode`, async ({ page }) => { | ||
test.skip( | ||
process.env.CI === `true`, | ||
`This test fails in CI at clicking click('text=Electronegativity')` | ||
// works locally, maybe due to faster CPU | ||
) | ||
|
||
await page.goto(`/`) | ||
|
||
await page.click(`[placeholder="Select a heat map"]`) | ||
|
||
// select electronegativity heatmap | ||
await page.click(`text=Electronegativity`) | ||
|
||
// make sure Fluorine electronegativity value is displayed correctly | ||
expect(await page.$(`text=9 F 3.98`)).not.toBeNull() | ||
test.describe(`Periodic Table`, async () => { | ||
test(`in default state`, async ({ page }) => { | ||
await page.goto(`/`) | ||
|
||
const element_tiles = await page.$$(`.element-tile`) | ||
expect(element_tiles).toHaveLength(118) | ||
|
||
for (const [category, count] of Object.entries(category_counts)) { | ||
const css_cls = `.${category.replaceAll(` `, `-`)}` | ||
expect(await page.$$(css_cls)).toHaveLength(count as number) | ||
} | ||
}) | ||
|
||
test(`shows stats on hover element`, async ({ page }) => { | ||
await page.goto(`/`) | ||
|
||
await page.hover(`text=Hydrogen`) | ||
|
||
expect(await page.$(`text=1 - Hydrogen diatomic nonmetal`)).not.toBeNull() | ||
}) | ||
|
||
test(`can hover every element without throwing errors`, async ({ page }) => { | ||
const logs: string[] = [] | ||
page.on(`console`, (msg) => { | ||
if ( | ||
msg.type() === `error` && | ||
!msg.text().startsWith(`Failed to load resource:`) | ||
) | ||
logs.push(msg.text()) | ||
}) | ||
await page.goto(`/`) | ||
|
||
const element_tiles = await page.$$(`.element-tile`) | ||
for (const element_tile of element_tiles) { | ||
await element_tile.hover() | ||
} | ||
|
||
expect(logs).toHaveLength(0) | ||
}) | ||
|
||
test(`in heatmap mode`, async ({ page }) => { | ||
test.skip( | ||
process.env.CI === `true`, | ||
`This test fails in CI at clicking click('text=Electronegativity')` | ||
// works locally, maybe due to faster CPU | ||
) | ||
|
||
await page.goto(`/`) | ||
|
||
await page.click(`[placeholder="Select a heat map"]`) | ||
|
||
// select electronegativity heatmap | ||
await page.click(`text=Electronegativity`) | ||
|
||
// make sure Fluorine electronegativity value is displayed correctly | ||
expect(await page.$(`text=9 F 3.98`)).not.toBeNull() | ||
}) | ||
}) |