Skip to content

Commit

Permalink
Refactor folder structure for improved organization
Browse files Browse the repository at this point in the history
Reorganize project folder structure to enhance clarity and
maintainability:
- Moved Playwright configuration to `config/playwright.config.ts`.
- Relocated URL constants to `constants/urls.ts`.
- Moved selectors to `page-objects/selectors.ts`.
- Reorganized test files under `tests/e2e`:
  - `inventory-functionality.test.ts`
  - `login-functionality.test.ts`.
- Moved credentials to `tests/fixtures/credentials.ts`.
- Updated utilities in `tests/utils/inventory.ts` and
`tests/utils/login.ts`.

This refactor adheres to project standards and improves modularity.
  • Loading branch information
matttechwell committed Jan 14, 2025
1 parent 2ed473f commit 63dd2a0
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 14 deletions.
Empty file.
8 changes: 7 additions & 1 deletion playwright.config.ts → config/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ export default defineConfig({
forbidOnly: !!process.env.CI,
retries: 2,
workers: process.env.CI ? 1 : 4,
reporter: 'html',
reporter: [
['html',
{
outputFolder: 'reports/html-report', open: 'never'
}
]
],
use: {
trace: 'on-first-retry',
},
Expand Down
2 changes: 1 addition & 1 deletion tests/variables/urls.ts → constants/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export const urls = {
loginPage: 'https://www.saucedemo.com/v1/',
inventoryPage: /inventory.html/,
};

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { test, expect } from '@playwright/test';
import { credentials } from './variables/credentials';
import { urls } from './variables/urls';
import { selectors } from './variables/selectors';
import { login } from './utils/login';
import { addItemToCart, getCartItemCount, sortProducts, logout } from './utils/inventory';
import { credentials } from '../fixtures/credentials';
import { urls } from '../../constants/urls';
import { selectors } from '../../page-objects/selectors';
import { login } from '../utils/login';
import { addItemToCart, getCartItemCount, sortProducts, logout } from '../utils/inventory';

test.describe('Inventory functionality tests', () => {
test.beforeEach(async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test, expect } from '@playwright/test';
import { credentials, errorMessages } from './variables/credentials';
import { urls } from './variables/urls';
import { selectors } from './variables/selectors';
import { login } from './utils/login';
import { credentials, errorMessages } from '../fixtures/credentials';
import { urls } from '../../constants/urls';
import { selectors } from '../../page-objects/selectors';
import { login } from '../utils/login';

test.describe('Login functionality tests', () => {
test('Successful login with standard user', async ({ page }) => {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/utils/inventory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Page } from '@playwright/test';
import { selectors } from '../variables/selectors';
import { selectors } from '../../page-objects/selectors';

export const addItemToCart = async (page: Page, itemIndex: number): Promise<void> => {
const productAddToCartButton = page.locator(selectors.inventoryPage.productAddToCartButton).nth(itemIndex);
Expand Down
4 changes: 2 additions & 2 deletions tests/utils/login.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Page } from '@playwright/test';
import { selectors } from '../variables/selectors';
import { credentials } from '../variables/credentials';
import { selectors } from '../../page-objects/selectors';
import { credentials } from '../fixtures/credentials';

export const login = async (
page: Page,
Expand Down

0 comments on commit 63dd2a0

Please sign in to comment.