-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: write snapshot tests - workflow test
- Loading branch information
Showing
25 changed files
with
2,031 additions
and
1,756 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,7 @@ dist-ssr | |
*.njsproj | ||
*.sln | ||
*.sw? | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ |
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 +1,5 @@ | ||
compressionLevel: mixed | ||
|
||
enableGlobalCache: false | ||
|
||
nodeLinker: node-modules |
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,77 @@ | ||
import {test, expect, Page} from '@playwright/test'; | ||
|
||
const TEST_URL = 'http://localhost:5173/chat-ai-widget/?app_id=833E2DC4-DFA2-4508-A283-6E5C7BFCF18A&bot_id=onboarding_bot&disable_timestamps=true'; | ||
|
||
export async function assertScreenshot(page: Page, screenshotName: string) { | ||
await expect(page.locator('#aichatbot-widget-window')).toHaveScreenshot( | ||
`${screenshotName}.png`, | ||
{ | ||
omitBackground: false, | ||
// threshold: 0.1, // Keep this in case you need it. It is for letting tests with little difference in pixels to pass. | ||
}); | ||
} | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto(TEST_URL); | ||
}); | ||
|
||
/** | ||
* 100 | ||
* Test workflow1 | ||
* Scenario: | ||
* 1. Trigger workflow1 | ||
* 2. Get form message response | ||
* 3. Submit without filling the form | ||
* 4. Fill form message and then submit | ||
* 5. Go back | ||
* 6. Get text message response | ||
* Verify after each step | ||
*/ | ||
test('100', async ({ page, browserName }) => { | ||
await page.click('#aichatbot-widget-button'); | ||
await page.waitForTimeout(2500); | ||
const input = page.locator('#sendbird-message-input-text-field'); | ||
|
||
// 1 | ||
await input.fill('trigger workflow1'); | ||
await assertScreenshot(page, `100-1.${browserName}`); | ||
await input.press('Enter'); | ||
await page.waitForTimeout(500); | ||
await assertScreenshot(page, `100-2.${browserName}`); | ||
|
||
// 2 | ||
let options = page.locator('.sendbird-suggested-replies__option'); | ||
await options.first().click(); | ||
await page.waitForTimeout(500); | ||
await assertScreenshot(page, `100-3.${browserName}`); | ||
|
||
// 3 | ||
let submitButton = page.locator('button.sendbird-button--primary'); | ||
await submitButton.click(); | ||
await assertScreenshot(page, `100-4.${browserName}`); | ||
|
||
// 4 | ||
const inputs = page.locator('.sendbird-input__input'); | ||
await inputs.nth(0).fill('guy ordering food'); | ||
await inputs.nth(2).fill('2'); | ||
await inputs.nth(3).fill('[email protected]'); | ||
await inputs.nth(4).fill('123-456-7890'); | ||
const chipContainer = page.locator('.sendbird-form-chip__container'); | ||
await chipContainer.locator(':scope > *').nth(5).click(); | ||
submitButton = page.locator('button.sendbird-button--primary'); | ||
await submitButton.click(); | ||
await page.waitForTimeout(100); | ||
await assertScreenshot(page, `100-5.${browserName}`); | ||
|
||
// 5 | ||
options = page.locator('.sendbird-suggested-replies__option'); | ||
await options.first().click(); | ||
await page.waitForTimeout(100); | ||
await assertScreenshot(page, `100-6.${browserName}`); | ||
|
||
// 6 | ||
options = page.locator('.sendbird-suggested-replies__option'); | ||
await options.nth(1).click(); | ||
await page.waitForTimeout(100); | ||
await assertScreenshot(page, `100-7.${browserName}`); | ||
}); |
Binary file added
BIN
+21.5 KB
__visual_tests__/workflow1.spec.ts-snapshots/100-1-chromium-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+27.9 KB
__visual_tests__/workflow1.spec.ts-snapshots/100-1-firefox-firefox-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+31.1 KB
__visual_tests__/workflow1.spec.ts-snapshots/100-2-chromium-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+38.2 KB
__visual_tests__/workflow1.spec.ts-snapshots/100-2-firefox-firefox-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29.2 KB
__visual_tests__/workflow1.spec.ts-snapshots/100-3-chromium-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+37.3 KB
__visual_tests__/workflow1.spec.ts-snapshots/100-3-firefox-firefox-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+33.6 KB
__visual_tests__/workflow1.spec.ts-snapshots/100-4-chromium-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+42.7 KB
__visual_tests__/workflow1.spec.ts-snapshots/100-4-firefox-firefox-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+33.7 KB
__visual_tests__/workflow1.spec.ts-snapshots/100-5-chromium-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+40.8 KB
__visual_tests__/workflow1.spec.ts-snapshots/100-5-firefox-firefox-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+35.1 KB
__visual_tests__/workflow1.spec.ts-snapshots/100-6-chromium-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+43 KB
__visual_tests__/workflow1.spec.ts-snapshots/100-6-firefox-firefox-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+36.8 KB
__visual_tests__/workflow1.spec.ts-snapshots/100-7-chromium-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+44.4 KB
__visual_tests__/workflow1.spec.ts-snapshots/100-7-firefox-firefox-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,79 @@ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// import dotenv from 'dotenv'; | ||
// import path from 'path'; | ||
// dotenv.config({ path: path.resolve(__dirname, '.env') }); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: './__visual_tests__', | ||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: 'html', | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
// baseURL: 'http://127.0.0.1:3000', | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
|
||
{ | ||
name: 'firefox', | ||
use: { ...devices['Desktop Firefox'] }, | ||
}, | ||
|
||
// { | ||
// name: 'webkit', | ||
// use: { ...devices['Desktop Safari'] }, | ||
// }, | ||
|
||
/* Test against mobile viewports. */ | ||
// { | ||
// name: 'Mobile Chrome', | ||
// use: { ...devices['Pixel 5'] }, | ||
// }, | ||
// { | ||
// name: 'Mobile Safari', | ||
// use: { ...devices['iPhone 12'] }, | ||
// }, | ||
|
||
/* Test against branded browsers. */ | ||
// { | ||
// name: 'Microsoft Edge', | ||
// use: { ...devices['Desktop Edge'], channel: 'msedge' }, | ||
// }, | ||
// { | ||
// name: 'Google Chrome', | ||
// use: { ...devices['Desktop Chrome'], channel: 'chrome' }, | ||
// }, | ||
], | ||
|
||
/* Run your local dev server before starting the tests */ | ||
webServer: { | ||
command: 'yarn dev', | ||
url: 'http://localhost:5173/chat-ai-widget/', | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
}); |
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
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
Oops, something went wrong.