generated from prokawsar/dashboard-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
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
10 changed files
with
182 additions
and
44 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Playwright Tests | ||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Install Playwright Browsers | ||
run: npx playwright install --with-deps | ||
- name: Run Playwright tests | ||
run: npx playwright test | ||
- uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 10 |
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// dotenv.config({ path: path.resolve(__dirname, '.env.development') }) | ||
|
||
export default defineConfig({ | ||
testDir: './tests', | ||
timeout: 5000, | ||
fullyParallel: true, | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 1, | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: 'html', | ||
use: { | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
baseURL: 'http://localhost:4173', | ||
/* 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'] } | ||
// }, | ||
|
||
/* Test against mobile viewports. */ | ||
{ | ||
name: 'Mobile Chrome', | ||
use: { ...devices['Pixel 7'] } | ||
}, | ||
{ | ||
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: 'npm run build:dev && npm run preview', | ||
url: 'http://localhost:4173', | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { expect, test } from '@playwright/test' | ||
|
||
test('index page has loaded fine', async ({ page }) => { | ||
await page.goto('/') | ||
await expect(page.getByText('Paper Cost')).toBeVisible() | ||
}) | ||
|
||
test('test calculate paper cost works', async ({ page }) => { | ||
await page.goto('/') | ||
|
||
await page.getByPlaceholder('Product name').click() | ||
await page.getByPlaceholder('Product name').fill('Test product') | ||
await page.getByPlaceholder('L').fill('23') | ||
await page.getByPlaceholder('W').fill('23') | ||
await page.getByPlaceholder('GSM').fill('23') | ||
await page.getByPlaceholder('R', { exact: true }).fill('100') | ||
await page.getByRole('button', { name: 'Calculate' }).click() | ||
await page.getByRole('button', { name: 'Save cost' }).click() | ||
await expect(page.getByText('Total with (40%):')).toBeVisible() | ||
await expect(page.getByText('1.10')).toBeVisible() | ||
await page.getByRole('button', { name: 'Clear' }).click() | ||
await expect(page.getByText('= total')).toBeVisible() | ||
}) | ||
|
||
test('test cost history saved in history', async ({ page }) => { | ||
await page.goto('/') | ||
await page.getByPlaceholder('L').fill('34') | ||
await page.getByPlaceholder('L').press('Enter') | ||
await page.getByPlaceholder('W').fill('34') | ||
await page.getByPlaceholder('W').press('Enter') | ||
await page.getByPlaceholder('GSM').fill('34') | ||
await page.getByPlaceholder('GSM').press('Enter') | ||
await page.getByPlaceholder('R', { exact: true }).fill('100') | ||
await page.getByPlaceholder('R', { exact: true }).press('Enter') | ||
await expect(page.getByText('Total with (40%):')).toBeVisible() | ||
await expect(page.getByText('3.55')).toBeVisible() | ||
await page.getByRole('button', { name: 'Save cost' }).click() | ||
await expect(page.getByText('Cost details saved')).toBeVisible() | ||
await page.getByRole('link', { name: 'Cost History' }).click() | ||
await expect(page.getByRole('heading', { name: 'History' })).toBeVisible() | ||
}) | ||
|
||
test('test multiple paper calcuation', async ({ page }) => { | ||
await page.goto('/') | ||
|
||
await page.getByTestId('product_name').click() | ||
await page.getByTestId('product_name').fill('Snaks') | ||
await page.getByRole('button', { name: 'Add paper' }).click() | ||
|
||
await page.getByTestId('length').first().click() | ||
await page.getByTestId('length').first().fill('34') | ||
await page.getByTestId('length').first().press('Enter') | ||
await page.getByTestId('width').first().fill('43') | ||
await page.getByTestId('width').first().press('Enter') | ||
await page.getByTestId('thickness').first().fill('33') | ||
await page.getByTestId('thickness').first().press('Enter') | ||
await page.getByTestId('rate').first().fill('100') | ||
await page.getByTestId('rate').first().press('Enter') | ||
|
||
await page.getByTestId('length').nth(1).fill('43') | ||
await page.getByTestId('length').nth(1).press('Enter') | ||
await page.getByTestId('width').nth(1).fill('32') | ||
await page.getByTestId('width').nth(1).press('Enter') | ||
await page.getByTestId('thickness').nth(1).fill('54') | ||
await page.getByTestId('thickness').nth(1).press('Enter') | ||
await page.getByTestId('rate').nth(1).fill('120') | ||
await page.getByTestId('rate').nth(1).press('Enter') | ||
|
||
await expect(page.getByTestId('total40-text')).toBeVisible() | ||
await expect(page.getByTestId('total40-value')).toBeVisible() | ||
await expect(page.getByTestId('total-text')).toBeVisible() | ||
await expect(page.getByTestId('total-value')).toBeVisible() | ||
await page.getByRole('button', { name: 'Clear' }).click() | ||
|
||
await expect(page.getByTestId('total40-value')).not.toBeVisible() | ||
await expect(page.getByTestId('total-text')).not.toBeVisible() | ||
}) |
This file was deleted.
Oops, something went wrong.