-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
47 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { loginViaApi } from '../utils/login'; | ||
|
||
test.describe('Site Sittings', () => { | ||
test('Basic Settings', async ({ page, browser, baseURL }) => { | ||
const homePage = await test.step('Visit Settings Page', async () => { | ||
await loginViaApi(page); | ||
await page.goto('/site-settings'); | ||
const homePage = await browser.newPage({ | ||
baseURL, | ||
}); | ||
await homePage.goto('/'); | ||
return homePage; | ||
}); | ||
|
||
await test.step('Title and Description', async () => { | ||
await page.getByLabel('Title', { exact: true }).fill('FooBar.AI'); | ||
await submitAndWaitSavedByLabel('Title'); | ||
|
||
await page.getByLabel('Description', { exact: true }).fill('FooBar AI Description'); | ||
await submitAndWaitSavedByLabel('Description'); | ||
|
||
await page.getByLabel('Homepage Title', { exact: true }).fill('Ask anything about FooBar'); | ||
await submitAndWaitSavedByLabel('Homepage Title'); | ||
|
||
await page.reload(); | ||
|
||
await homePage.waitForTimeout(11000); // wait for settings cache | ||
await homePage.reload(); | ||
expect(await homePage.title()).toBe('FooBar.AI'); | ||
await expect(homePage.locator('h1')).toHaveText('Ask anything about FooBar'); | ||
await expect(homePage.locator('h1 + p')).toHaveText('FooBar AI Description'); | ||
await expect(homePage.locator('meta[name=description]')).toHaveAttribute('content', 'FooBar AI Description'); | ||
}); | ||
|
||
async function submitAndWaitSavedByLabel (label: string) { | ||
const button = page.getByText(label, { exact: true }).locator('..').locator('..').getByRole('button', { name: 'Save', exact: true }); | ||
|
||
// Click the save button in the field form | ||
await button.click(); | ||
|
||
// Wait the save button to be vanished. (Saved) | ||
await button.waitFor({ state: 'hidden' }); | ||
} | ||
}); | ||
}); |