@trevordsouzabrite/test-package 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/playwright-test-generator.md +85 -0
- package/.claude/agents/playwright-test-healer.md +45 -0
- package/.claude/agents/playwright-test-planner.md +52 -0
- package/.claude/prompts/playwright-test-coverage.md +31 -0
- package/.claude/prompts/playwright-test-generate.md +12 -0
- package/.claude/prompts/playwright-test-heal.md +6 -0
- package/.claude/prompts/playwright-test-plan.md +12 -0
- package/.claude/settings.local.json +31 -0
- package/.github/agents/playwright-test-generator.agent.md +113 -0
- package/.github/agents/playwright-test-healer.agent.md +70 -0
- package/.github/agents/playwright-test-planner.agent.md +82 -0
- package/.github/prompts/playwright-test-coverage.prompt.md +31 -0
- package/.github/prompts/playwright-test-generate.prompt.md +12 -0
- package/.github/prompts/playwright-test-heal.prompt.md +6 -0
- package/.github/prompts/playwright-test-plan.prompt.md +9 -0
- package/.github/workflows/copilot-setup-steps.yml +34 -0
- package/.github/workflows/playwright-healer-agent.yml +140 -0
- package/.github/workflows/playwright.yml +40 -0
- package/.mcp.json +13 -0
- package/.vscode/extensions.json +6 -0
- package/.vscode/mcp.json +13 -0
- package/.vscode/settings.example.json +15 -0
- package/bitbucket-pipelines.yml +86 -0
- package/lib/WebActions.ts +107 -0
- package/package.json +33 -0
- package/pageRepository/ApplicantPage.ts +1171 -0
- package/pageRepository/CreateApplicationPage.ts +1736 -0
- package/playwright/.auth/user.json +0 -0
- package/specs/Applicant Create Application Page Test Plan.md +440 -0
- package/specs/Applicant Dashboard Page Test Plan.md +74 -0
- package/specs/Applicant Forgot Password Page Test Plan.md +112 -0
- package/specs/Applicant Help Page Test Plan.md +369 -0
- package/specs/Applicant Landing Page Test Plan.md +42 -0
- package/specs/Applicant Login Page Test Plan.md +116 -0
- package/specs/Applicant My Applications Page Test Plan.md +558 -0
- package/specs/Applicant My Medical Coverage Page Test Plan.md +689 -0
- package/specs/Applicant Privacy Policy Page Test Plan.md +196 -0
- package/specs/Applicant Resources Page Test Plan.md +107 -0
- package/specs/Applicant Self Register Page Test Plan.md +190 -0
- package/specs/README.md +3 -0
- package/test-data/Sample.png +0 -0
- package/test-data/createApplication/formData.json +42 -0
- package/test-data/createApplication/textMessages.json +52 -0
- package/test-data/forgotPassword/email.json +5 -0
- package/test-data/forgotPassword/textMessages.json +5 -0
- package/test-data/help/textContent.json +48 -0
- package/test-data/login/invalidUsernamePassword.json +4 -0
- package/test-data/login/textMessages.json +5 -0
- package/test-data/privacyPolicy/textContent.json +25 -0
- package/test-data/selfRegister/mailingAddressStates.json +21 -0
- package/test-data/selfRegister/registrationFieldData.json +13 -0
- package/test-data/selfRegister/suffix.json +3 -0
- package/test-data/selfRegister/textMessages.json +13 -0
- package/test-data/test-data.zip +0 -0
- package/tests/ApplicantCreateApplicationPageTest.spec.ts +1452 -0
- package/tests/ApplicantDashboardPageTest.spec.ts +74 -0
- package/tests/ApplicantForgotPasswordPageTest.spec.ts +88 -0
- package/tests/ApplicantHelpPageTest.spec.ts +468 -0
- package/tests/ApplicantLandingPageTest.spec.ts +33 -0
- package/tests/ApplicantLoginPageTest.spec.ts +117 -0
- package/tests/ApplicantMyApplicationsPageTest.spec.ts +516 -0
- package/tests/ApplicantMyMedicalCoveragePageTest.spec.ts +470 -0
- package/tests/ApplicantPrivacyPolicyPageTest.spec.ts +188 -0
- package/tests/ApplicantResourcesPageTest.spec.ts +117 -0
- package/tests/ApplicantSelfRegisterPageTest.spec.ts +254 -0
- package/tests/auth.setup.ts +42 -0
- package/tests/authState.ts +15 -0
- package/tests/example.spec.ts +18 -0
- package/tests/seed.spec.ts +7 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
name: Playwright Test Healer Agent
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_run:
|
|
5
|
+
workflows: [Playwright Tests]
|
|
6
|
+
types: [completed]
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
inputs:
|
|
9
|
+
workflow_run_id:
|
|
10
|
+
description: Playwright Tests workflow run ID (defaults to latest failed run)
|
|
11
|
+
required: false
|
|
12
|
+
type: string
|
|
13
|
+
|
|
14
|
+
permissions:
|
|
15
|
+
actions: read
|
|
16
|
+
contents: read
|
|
17
|
+
issues: write
|
|
18
|
+
|
|
19
|
+
concurrency:
|
|
20
|
+
group: playwright-healer-${{ github.event.workflow_run.id || github.run_id }}
|
|
21
|
+
cancel-in-progress: true
|
|
22
|
+
|
|
23
|
+
jobs:
|
|
24
|
+
healer:
|
|
25
|
+
if: >-
|
|
26
|
+
${{
|
|
27
|
+
(github.event_name == 'workflow_dispatch') ||
|
|
28
|
+
(
|
|
29
|
+
github.event.workflow_run.conclusion == 'failure' &&
|
|
30
|
+
github.event.workflow_run.repository.id == github.repository_id &&
|
|
31
|
+
!startsWith(github.event.workflow_run.head_branch, 'copilot/') &&
|
|
32
|
+
!startsWith(github.event.workflow_run.head_branch, 'autofix/') &&
|
|
33
|
+
!startsWith(github.event.workflow_run.head_branch, 'healer/')
|
|
34
|
+
)
|
|
35
|
+
}}
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
steps:
|
|
38
|
+
- name: Resolve workflow run
|
|
39
|
+
id: run
|
|
40
|
+
env:
|
|
41
|
+
GH_TOKEN: ${{ github.token }}
|
|
42
|
+
run: |
|
|
43
|
+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
44
|
+
if [ -n "${{ inputs.workflow_run_id }}" ]; then
|
|
45
|
+
RUN_ID="${{ inputs.workflow_run_id }}"
|
|
46
|
+
else
|
|
47
|
+
RUN_ID=$(gh run list --workflow=playwright.yml --json databaseId,conclusion --jq '.[] | select(.conclusion=="failure") | .databaseId' | head -1)
|
|
48
|
+
if [ -z "$RUN_ID" ]; then
|
|
49
|
+
echo "::error::No failed Playwright Tests run found. Pass workflow_run_id manually."
|
|
50
|
+
exit 1
|
|
51
|
+
fi
|
|
52
|
+
fi
|
|
53
|
+
RUN_JSON=$(gh run view "$RUN_ID" --json headBranch,headSha,htmlUrl,conclusion,event)
|
|
54
|
+
echo "run_id=$RUN_ID" >> "$GITHUB_OUTPUT"
|
|
55
|
+
echo "head_branch=$(echo "$RUN_JSON" | jq -r '.headBranch')" >> "$GITHUB_OUTPUT"
|
|
56
|
+
echo "head_sha=$(echo "$RUN_JSON" | jq -r '.headSha')" >> "$GITHUB_OUTPUT"
|
|
57
|
+
echo "html_url=$(echo "$RUN_JSON" | jq -r '.htmlUrl')" >> "$GITHUB_OUTPUT"
|
|
58
|
+
else
|
|
59
|
+
echo "run_id=${{ github.event.workflow_run.id }}" >> "$GITHUB_OUTPUT"
|
|
60
|
+
echo "head_branch=${{ github.event.workflow_run.head_branch }}" >> "$GITHUB_OUTPUT"
|
|
61
|
+
echo "head_sha=${{ github.event.workflow_run.head_sha }}" >> "$GITHUB_OUTPUT"
|
|
62
|
+
echo "html_url=${{ github.event.workflow_run.html_url }}" >> "$GITHUB_OUTPUT"
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
- uses: actions/checkout@v4
|
|
66
|
+
with:
|
|
67
|
+
ref: ${{ steps.run.outputs.head_sha }}
|
|
68
|
+
|
|
69
|
+
- name: Collect CI failure context
|
|
70
|
+
env:
|
|
71
|
+
GH_TOKEN: ${{ github.token }}
|
|
72
|
+
run: |
|
|
73
|
+
mkdir -p ci-failure-context
|
|
74
|
+
RUN_ID="${{ steps.run.outputs.run_id }}"
|
|
75
|
+
gh run view "$RUN_ID" --log-failed > ci-failure-context/failed-logs.txt 2>&1 || true
|
|
76
|
+
gh run download "$RUN_ID" -n playwright-report -D ci-failure-context/playwright-report 2>/dev/null || true
|
|
77
|
+
gh run download "$RUN_ID" -n playwright-test-results -D ci-failure-context/test-results 2>/dev/null || true
|
|
78
|
+
{
|
|
79
|
+
echo "Workflow run: ${{ steps.run.outputs.html_url }}"
|
|
80
|
+
echo "Branch: ${{ steps.run.outputs.head_branch }}"
|
|
81
|
+
echo "Commit: ${{ steps.run.outputs.head_sha }}"
|
|
82
|
+
} > ci-failure-context/summary.txt
|
|
83
|
+
|
|
84
|
+
- name: Start Playwright Test Healer (Copilot cloud agent)
|
|
85
|
+
env:
|
|
86
|
+
GH_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}
|
|
87
|
+
run: |
|
|
88
|
+
if [ -z "$GH_TOKEN" ]; then
|
|
89
|
+
echo "::warning::Secret COPILOT_GITHUB_TOKEN is not set. Cannot start the healer agent."
|
|
90
|
+
echo "::warning::Add repo secret COPILOT_GITHUB_TOKEN (PAT with Agent tasks read/write)."
|
|
91
|
+
exit 0
|
|
92
|
+
fi
|
|
93
|
+
|
|
94
|
+
PROMPT=$(cat <<EOF
|
|
95
|
+
Playwright tests failed in CI.
|
|
96
|
+
|
|
97
|
+
- Workflow run: ${{ steps.run.outputs.html_url }}
|
|
98
|
+
- Branch: ${{ steps.run.outputs.head_branch }}
|
|
99
|
+
- Commit: ${{ steps.run.outputs.head_sha }}
|
|
100
|
+
- Failure context directory: ci-failure-context/
|
|
101
|
+
|
|
102
|
+
Act as the playwright-test-healer custom agent (.github/agents/playwright-test-healer.agent.md).
|
|
103
|
+
|
|
104
|
+
1. Read ci-failure-context/ for logs and the HTML report.
|
|
105
|
+
2. Run the full suite with Playwright MCP test_run.
|
|
106
|
+
3. Debug failures with test_debug and browser tools; fix tests/ and related page objects.
|
|
107
|
+
4. Re-run until green, or use test.fixme() with a comment when the app is broken.
|
|
108
|
+
5. Open a pull request with fixes.
|
|
109
|
+
|
|
110
|
+
Same intent as the /playwright-test-heal repository prompt.
|
|
111
|
+
EOF
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
BODY=$(jq -n \
|
|
115
|
+
--arg prompt "$PROMPT" \
|
|
116
|
+
--arg base_ref "${{ steps.run.outputs.head_branch }}" \
|
|
117
|
+
'{
|
|
118
|
+
prompt: $prompt,
|
|
119
|
+
create_pull_request: true,
|
|
120
|
+
base_ref: $base_ref,
|
|
121
|
+
custom_agent: "playwright-test-healer"
|
|
122
|
+
}')
|
|
123
|
+
|
|
124
|
+
if ! gh api \
|
|
125
|
+
--method POST \
|
|
126
|
+
-H "Accept: application/vnd.github+json" \
|
|
127
|
+
-H "X-GitHub-Api-Version: 2026-03-10" \
|
|
128
|
+
"/agents/repos/${GITHUB_REPOSITORY}/tasks" \
|
|
129
|
+
--input - <<<"$BODY"; then
|
|
130
|
+
echo "::notice::Retrying without custom_agent field..."
|
|
131
|
+
BODY=$(echo "$BODY" | jq 'del(.custom_agent)')
|
|
132
|
+
gh api \
|
|
133
|
+
--method POST \
|
|
134
|
+
-H "Accept: application/vnd.github+json" \
|
|
135
|
+
-H "X-GitHub-Api-Version: 2026-03-10" \
|
|
136
|
+
"/agents/repos/${GITHUB_REPOSITORY}/tasks" \
|
|
137
|
+
--input - <<<"$BODY"
|
|
138
|
+
fi
|
|
139
|
+
|
|
140
|
+
echo "::notice::Playwright Test Healer started — track at https://github.com/copilot/agents"
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: Playwright Tests
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [ main, master ]
|
|
5
|
+
pull_request:
|
|
6
|
+
branches: [ main, master ]
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
timeout-minutes: 60
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
env:
|
|
12
|
+
ENV: qa
|
|
13
|
+
LOGIN: ${{ secrets.LOGIN }}
|
|
14
|
+
PASSWORD: ${{ secrets.PASSWORD }}
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-node@v4
|
|
18
|
+
with:
|
|
19
|
+
node-version: lts/*
|
|
20
|
+
- name: Install dependencies
|
|
21
|
+
run: npm ci
|
|
22
|
+
- name: Install Playwright Browsers
|
|
23
|
+
run: npx playwright install --with-deps
|
|
24
|
+
- name: Run Playwright tests (no-auth)
|
|
25
|
+
run: npm run test:ci:no-auth
|
|
26
|
+
- name: Run Playwright tests (auth)
|
|
27
|
+
run: npm run test:ci:auth
|
|
28
|
+
- uses: actions/upload-artifact@v4
|
|
29
|
+
if: ${{ !cancelled() }}
|
|
30
|
+
with:
|
|
31
|
+
name: playwright-report
|
|
32
|
+
path: playwright-report/
|
|
33
|
+
retention-days: 30
|
|
34
|
+
- uses: actions/upload-artifact@v4
|
|
35
|
+
if: failure()
|
|
36
|
+
with:
|
|
37
|
+
name: playwright-test-results
|
|
38
|
+
path: test-results/
|
|
39
|
+
retention-days: 14
|
|
40
|
+
if-no-files-found: ignore
|
package/.mcp.json
ADDED
package/.vscode/mcp.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"//": "Copy these keys into your USER settings.json (not this file).",
|
|
3
|
+
"//": "VS Code: Ctrl+Shift+P → Preferences: Open User Settings (JSON)",
|
|
4
|
+
"claudeCode.environmentVariables": [
|
|
5
|
+
{
|
|
6
|
+
"name": "ANTHROPIC_API_KEY",
|
|
7
|
+
"value": "sk-ant-api03-REPLACE-WITH-YOUR-KEY"
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"claudeCode.disableLoginPrompt": true,
|
|
11
|
+
"terminal.integrated.env.windows": {
|
|
12
|
+
"OPENAI_API_KEY": "sk-proj-REPLACE-WITH-YOUR-KEY",
|
|
13
|
+
"OPENAI_MODEL": "gpt-5.4-mini"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Pin to the Playwright version that matches @playwright/test in package.json.
|
|
2
|
+
image: mcr.microsoft.com/playwright:v1.58.2-jammy
|
|
3
|
+
|
|
4
|
+
options:
|
|
5
|
+
max-time: 60
|
|
6
|
+
|
|
7
|
+
definitions:
|
|
8
|
+
caches:
|
|
9
|
+
npmcache: ~/.npm
|
|
10
|
+
steps:
|
|
11
|
+
- step: &playwright-tests
|
|
12
|
+
name: Playwright tests
|
|
13
|
+
size: 2x
|
|
14
|
+
caches:
|
|
15
|
+
- node
|
|
16
|
+
- npmcache
|
|
17
|
+
script:
|
|
18
|
+
- node -v && npm -v
|
|
19
|
+
- npm ci
|
|
20
|
+
- bash scripts/bitbucket/run-pipeline-tests.sh
|
|
21
|
+
artifacts:
|
|
22
|
+
- playwright-report/**
|
|
23
|
+
- test-results/**
|
|
24
|
+
- ci-failure-context/**
|
|
25
|
+
after-script:
|
|
26
|
+
- bash scripts/bitbucket/after-test-healer.sh
|
|
27
|
+
- step: &playwright-smoke-tests
|
|
28
|
+
name: Playwright smoke tests
|
|
29
|
+
size: 2x
|
|
30
|
+
caches:
|
|
31
|
+
- node
|
|
32
|
+
- npmcache
|
|
33
|
+
script:
|
|
34
|
+
- node -v && npm -v
|
|
35
|
+
- npm ci
|
|
36
|
+
- PLAYWRIGHT_SUITE_TAG="@smoke" bash scripts/bitbucket/run-pipeline-tests.sh
|
|
37
|
+
artifacts:
|
|
38
|
+
- playwright-report/**
|
|
39
|
+
- test-results/**
|
|
40
|
+
- ci-failure-context/**
|
|
41
|
+
after-script:
|
|
42
|
+
- export HEALER_VERIFY_COMMAND='PLAYWRIGHT_SUITE_TAG="@smoke" npm run test:bitbucket'
|
|
43
|
+
- bash scripts/bitbucket/after-test-healer.sh
|
|
44
|
+
- step: &playwright-tagged-tests
|
|
45
|
+
name: Playwright tagged tests
|
|
46
|
+
size: 2x
|
|
47
|
+
caches:
|
|
48
|
+
- node
|
|
49
|
+
- npmcache
|
|
50
|
+
script:
|
|
51
|
+
- node -v && npm -v
|
|
52
|
+
- npm ci
|
|
53
|
+
- |
|
|
54
|
+
if [ -z "$TEST_TAGS" ]; then
|
|
55
|
+
echo "TEST_TAGS is required. Example: @smoke or (?=.*@smoke)(?=.*@auth)";
|
|
56
|
+
exit 1;
|
|
57
|
+
fi
|
|
58
|
+
- PLAYWRIGHT_SUITE_TAG="$TEST_TAGS" bash scripts/bitbucket/run-pipeline-tests.sh
|
|
59
|
+
artifacts:
|
|
60
|
+
- playwright-report/**
|
|
61
|
+
- test-results/**
|
|
62
|
+
- ci-failure-context/**
|
|
63
|
+
after-script:
|
|
64
|
+
- export HEALER_VERIFY_COMMAND="PLAYWRIGHT_SUITE_TAG=\"$TEST_TAGS\" npm run test:bitbucket"
|
|
65
|
+
- bash scripts/bitbucket/after-test-healer.sh
|
|
66
|
+
|
|
67
|
+
pipelines:
|
|
68
|
+
default:
|
|
69
|
+
- step: *playwright-tests
|
|
70
|
+
branches:
|
|
71
|
+
main:
|
|
72
|
+
- step: *playwright-tests
|
|
73
|
+
master:
|
|
74
|
+
- step: *playwright-tests
|
|
75
|
+
|
|
76
|
+
custom:
|
|
77
|
+
regression-tests:
|
|
78
|
+
- step: *playwright-tests
|
|
79
|
+
smoke-tests:
|
|
80
|
+
- step: *playwright-smoke-tests
|
|
81
|
+
tagged-tests:
|
|
82
|
+
- variables:
|
|
83
|
+
- name: TEST_TAGS
|
|
84
|
+
default: "@smoke"
|
|
85
|
+
description: "Tag to combine with @no-auth and @auth, for example @smoke or @sprint15052026"
|
|
86
|
+
- step: *playwright-tagged-tests
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import * as CryptoJS from 'crypto-js';
|
|
3
|
+
import type { Locator, Page } from '@playwright/test';
|
|
4
|
+
import { BrowserContext, expect } from '@playwright/test';
|
|
5
|
+
import { Workbook } from 'exceljs';
|
|
6
|
+
import { testConfig } from '../testConfig';
|
|
7
|
+
import * as pdfjslib from 'pdfjs-dist-es5';
|
|
8
|
+
|
|
9
|
+
export class WebActions {
|
|
10
|
+
readonly page: Page;
|
|
11
|
+
readonly context: BrowserContext;
|
|
12
|
+
|
|
13
|
+
constructor(page: Page, context: BrowserContext) {
|
|
14
|
+
this.page = page;
|
|
15
|
+
this.context = context;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async decipherPassword(): Promise<string> {
|
|
19
|
+
const key = `SECRET`;
|
|
20
|
+
//ENCRYPT
|
|
21
|
+
// const cipher = CryptoJS.AES.encrypt('Demouat@09',key);
|
|
22
|
+
// console.log(cipher.toString());
|
|
23
|
+
return CryptoJS.AES.decrypt(testConfig.password, key).toString(CryptoJS.enc.Utf8);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async delay(time: number): Promise<void> {
|
|
27
|
+
return new Promise(function (resolve) {
|
|
28
|
+
setTimeout(resolve, time);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async clickByText(text: string): Promise<void> {
|
|
33
|
+
await this.page.getByText(text, { exact: true }).click(); //Matches locator with exact text and clicks
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async clickElementJS(locator: string): Promise<void> {
|
|
37
|
+
await this.page.$eval(locator, (element: HTMLElement) => element.click());
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async readDataFromExcel(fileName: string, sheetName: string, rowNum: number, cellNum: number): Promise<string> {
|
|
41
|
+
const workbook = new Workbook();
|
|
42
|
+
return workbook.xlsx.readFile(`./Downloads/${fileName}`).then(function () {
|
|
43
|
+
const sheet = workbook.getWorksheet(sheetName);
|
|
44
|
+
return sheet.getRow(rowNum).getCell(cellNum).toString();
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async readValuesFromTextFile(filePath: string): Promise<string> {
|
|
49
|
+
return fs.readFileSync(`${filePath}`, `utf-8`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async writeDataIntoTextFile(filePath: number | fs.PathLike, data: string | NodeJS.ArrayBufferView): Promise<void> {
|
|
53
|
+
fs.writeFile(filePath, data, (error) => {
|
|
54
|
+
if (error)
|
|
55
|
+
throw error;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async getPdfPageText(pdf: any, pageNo: number) {
|
|
60
|
+
const page = await pdf.getPage(pageNo);
|
|
61
|
+
const tokenizedText = await page.getTextContent();
|
|
62
|
+
const pageText = tokenizedText.items.map((token: any) => token.str).join('');
|
|
63
|
+
return pageText;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async getPDFText(filePath: any): Promise<string> {
|
|
67
|
+
const dataBuffer = fs.readFileSync(filePath);
|
|
68
|
+
const pdf = await pdfjslib.getDocument(dataBuffer).promise;
|
|
69
|
+
const maxPages = pdf.numPages;
|
|
70
|
+
const pageTextPromises = [];
|
|
71
|
+
for (let pageNo = 1; pageNo <= maxPages; pageNo += 1) {
|
|
72
|
+
pageTextPromises.push(this.getPdfPageText(pdf, pageNo));
|
|
73
|
+
}
|
|
74
|
+
const pageTexts = await Promise.all(pageTextPromises);
|
|
75
|
+
return pageTexts.join(' ');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async waitForElementAttached(locator: Locator)
|
|
79
|
+
{
|
|
80
|
+
console.log(`Waiting for the element ${locator} to be attached to the DOM...`);
|
|
81
|
+
await locator.waitFor( { state: 'attached' });
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Returns true if the element has no meaningful value/text (after trim). */
|
|
85
|
+
async checkIfFieldIsEmptyOrNot(locator: Locator): Promise<boolean> {
|
|
86
|
+
return locator.evaluate((el) => {
|
|
87
|
+
if (
|
|
88
|
+
el instanceof HTMLInputElement ||
|
|
89
|
+
el instanceof HTMLTextAreaElement ||
|
|
90
|
+
el instanceof HTMLSelectElement
|
|
91
|
+
) {
|
|
92
|
+
return el.value.trim().length === 0;
|
|
93
|
+
}
|
|
94
|
+
if (el instanceof HTMLElement && el.isContentEditable) {
|
|
95
|
+
return (el.innerText ?? '').trim().length === 0;
|
|
96
|
+
}
|
|
97
|
+
return (el.textContent ?? '').trim().length === 0;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async getErrorMessage(locator: Locator): Promise<string>
|
|
102
|
+
{
|
|
103
|
+
const message = await locator.evaluate(
|
|
104
|
+
(el) => (el as HTMLInputElement).validationMessage);
|
|
105
|
+
return message;
|
|
106
|
+
}
|
|
107
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@trevordsouzabrite/test-package",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "test description",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@axe-core/playwright": "^4.10.2",
|
|
10
|
+
"@playwright/test": "^1.58.2",
|
|
11
|
+
"crypto-js": "^4.2.0",
|
|
12
|
+
"dotenv": "^16.4.7",
|
|
13
|
+
"exceljs": "^4.4.0",
|
|
14
|
+
"pdfjs-dist-es5": "^2.13.216",
|
|
15
|
+
"settings": "^0.1.1"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
".claude/",
|
|
19
|
+
".github/",
|
|
20
|
+
".vscode/",
|
|
21
|
+
"lib/",
|
|
22
|
+
"pageRepository/",
|
|
23
|
+
"playwright/",
|
|
24
|
+
"specs/",
|
|
25
|
+
"test-data/",
|
|
26
|
+
"tests/",
|
|
27
|
+
".mcp.json",
|
|
28
|
+
"bitbucket-pipelines.yml"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
32
|
+
}
|
|
33
|
+
}
|