Compare commits

...

3 Commits

View File

@ -1,5 +1,6 @@
import { test, expect } from '@playwright/test' import { test, expect } from '@playwright/test'
import * as fsp from 'fs/promises' import * as fsp from 'fs/promises'
import * as fs from 'fs'
import { join } from 'path' import { join } from 'path'
import { import {
getUtils, getUtils,
@ -304,6 +305,21 @@ test.describe('Testing settings', () => {
const projectLink = page.getByText('bracket') const projectLink = page.getByText('bracket')
const logoLink = page.getByTestId('app-logo') const logoLink = page.getByTestId('app-logo')
async function confirmThemeWasWritten(filePath: string, value: string) {
return expect
.poll(
async () => {
const fileExists = await fs.existsSync(filePath)
return fileExists ? fsp.readFile(filePath, 'utf-8') : ''
},
{
message: 'Setting should now be written to the file',
timeout: 5_000,
}
)
.toContain(`themeColor = "${value}"`)
}
await test.step('Set user theme color on home', async () => { await test.step('Set user theme color on home', async () => {
await expect(settingsOpenButton).toBeVisible() await expect(settingsOpenButton).toBeVisible()
await settingsOpenButton.click() await settingsOpenButton.click()
@ -311,13 +327,8 @@ test.describe('Testing settings', () => {
await expect(userSettingsTab).toBeChecked() await expect(userSettingsTab).toBeChecked()
await themeColorSetting.fill(userThemeColor) await themeColorSetting.fill(userThemeColor)
await expect(logoLink).toHaveCSS('--primary-hue', userThemeColor) await expect(logoLink).toHaveCSS('--primary-hue', userThemeColor)
await confirmThemeWasWritten(tempUserSettingsFilePath, userThemeColor)
await settingsCloseButton.click() await settingsCloseButton.click()
await expect
.poll(async () => fsp.readFile(tempUserSettingsFilePath, 'utf-8'), {
message: 'Setting should now be written to the file',
timeout: 5_000,
})
.toContain(`themeColor = "${userThemeColor}"`)
}) })
await test.step('Set project theme color', async () => { await test.step('Set project theme color', async () => {
@ -328,17 +339,12 @@ test.describe('Testing settings', () => {
await expect(projectSettingsTab).toBeChecked() await expect(projectSettingsTab).toBeChecked()
await themeColorSetting.fill(projectThemeColor) await themeColorSetting.fill(projectThemeColor)
await expect(logoLink).toHaveCSS('--primary-hue', projectThemeColor) await expect(logoLink).toHaveCSS('--primary-hue', projectThemeColor)
await settingsCloseButton.click()
// Make sure that the project settings file has been written to before continuing // Make sure that the project settings file has been written to before continuing
await expect await confirmThemeWasWritten(
.poll( tempProjectSettingsFilePath,
async () => fsp.readFile(tempProjectSettingsFilePath, 'utf-8'), projectThemeColor
{ )
message: 'Setting should now be written to the file', await settingsCloseButton.click()
timeout: 5_000,
}
)
.toContain(`themeColor = "${projectThemeColor}"`)
}) })
await test.step('Refresh the application and see project setting applied', async () => { await test.step('Refresh the application and see project setting applied', async () => {