mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
2.2 KiB
53 lines
2.2 KiB
3 months ago
|
export const tests = []
|
||
|
|
||
|
tests.push(async ({ eq, page }) => {
|
||
|
// Check if the button with id 'arm-color' exists
|
||
|
const buttonExists = await page.$('button#arm-color')
|
||
|
eq(!!buttonExists, true)
|
||
|
})
|
||
|
|
||
|
tests.push(async ({ eq, page }) => {
|
||
|
// Check if the left and right arms exist
|
||
|
const leftArmExists = await page.$('#arm-left')
|
||
|
const rightArmExists = await page.$('#arm-right')
|
||
|
eq(!!leftArmExists && !!rightArmExists, true)
|
||
|
})
|
||
|
|
||
|
tests.push(async ({ eq, page }) => {
|
||
|
// Get the initial background colors of the arms
|
||
|
const initialLeftArmColor = await page.$eval('#arm-left', node => getComputedStyle(node).backgroundColor)
|
||
|
const initialRightArmColor = await page.$eval('#arm-right', node => getComputedStyle(node).backgroundColor)
|
||
|
|
||
|
// Click the 'arm-color' button
|
||
|
const button = await page.$('button#arm-color')
|
||
|
await button.click()
|
||
|
|
||
|
// Get the new background colors of the arms after clicking the button
|
||
|
const newLeftArmColor = await page.$eval('#arm-left', node => getComputedStyle(node).backgroundColor)
|
||
|
const newRightArmColor = await page.$eval('#arm-right', node => getComputedStyle(node).backgroundColor)
|
||
|
|
||
|
// Check if the colors have changed and are now different from the initial colors
|
||
|
eq(initialLeftArmColor !== newLeftArmColor, true)
|
||
|
eq(initialRightArmColor !== newRightArmColor, true)
|
||
|
eq(newLeftArmColor, newRightArmColor) // Check if both arms have the same color
|
||
|
})
|
||
|
|
||
|
tests.push(async ({ eq, page }) => {
|
||
|
// Click the 'arm-color' button multiple times to ensure the colors keep changing
|
||
|
const button = await page.$('button#arm-color')
|
||
|
|
||
|
const armColors = []
|
||
|
for (let i = 0; i < 3; i++) {
|
||
|
await button.click()
|
||
|
const leftArmColor = await page.$eval('#arm-left', node => getComputedStyle(node).backgroundColor)
|
||
|
const rightArmColor = await page.$eval('#arm-right', node => getComputedStyle(node).backgroundColor)
|
||
|
armColors.push({ leftArmColor, rightArmColor })
|
||
|
}
|
||
|
|
||
|
// Check if the colors are different in each click
|
||
|
eq(new Set(armColors.map(c => c.leftArmColor)).size, armColors.length)
|
||
|
eq(new Set(armColors.map(c => c.rightArmColor)).size, armColors.length)
|
||
|
// Check if the arms always have the same color after each click
|
||
|
armColors.forEach(colorPair => eq(colorPair.leftArmColor, colorPair.rightArmColor))
|
||
|
})
|