Skip to content

`Folder/`

Folder/

Folder / File Purpose
.env.* Environment-specific config (API URLs, credentials)
package.json Defines dependencies, scripts, and test runner setup
playwright.config.ts Core Playwright configuration (testDir, timeout, reporter, etc.)
controllers/ Contains API controller functions for reusable HTTP logic
pages/ Page Object Models (POM) for UI interaction
tests/ Spec files for both UI and API validations
utils/ Helper utilities (auth, context, data formatting, token parsing, etc.)
downloads/ Stores downloaded reports (e.g., Excel validations)
test-data/ Static data files for test use (optional)
test-results/ Output of test executions (e.g. HTML, JSON, traces)
reports/ Manual reports or screenshots

🧭 Folder by Folder

✅ controllers/

Handles API request logic.

  • getDocument.ts — GET /documents/:id
  • documentLifecycle.ts — POST, PUT, DELETE document
  • spellChecks.ts — Spell check executions and retry
  • uploadDocument.ts — Handles upload requests

How to add a new controller:

export async function newApiCall() {
  const apiContext = await getSharedApiContext();
  return apiContext.post('/api/new-endpoint', { data: {} });
}

✅ pages/

Contains UI Page Object Models.

  • uploadManualPage.ts — Upload file and trigger Excel report download
  • Use getByText, getByRole, or locators to bind actions to UI elements

How to create a Page Object:

export class ExamplePage {
  readonly page: Page;
  readonly button: Locator;

  constructor(page: Page) {
    this.page = page;
    this.button = page.getByRole("button", { name: "Click Me" });
  }

  async clickButton() {
    await this.button.click();
  }
}

✅ tests/

Spec files organized by:

  • tests/ui/ — UI validation (e.g., upload, download)
  • tests/api/ — Direct API tests (document, spell check, etc.)

Test example:

test("Verify user receives document info @api", async () => {
  const response = await getDocument();
  expect(response.status()).toBe(200);
});

✅ utils/

Reusable helpers for:

  • API context creation (getSharedApiContext)
  • Excel parsing
  • File path resolution
  • Token parsing from storageState

🛠 How Utils Work Together

  1. getAccessToken fetches a bearer token and stores it in process.env.
  2. getSharedApiContext uses that token to authorize all API requests.
  3. getFilePath standardizes local file references.
  4. Excel utilities (if present) validate Excel report contents.
Back to top