Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report form index #106

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ jobs:
uses: actions/setup-node@v4

- name: Install dependencies
run: yarn install
run: |
yarn install
yarn playwright install
yarn playwright install-deps

- name: Lint
run: yarn lint
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ All notable changes to this add-on will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased

### Changed
- Report index of the forms.

## 0.0.9 - 2024-11-28

### Added
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@
"json-server": "^0.17.3",
"mini-css-extract-plugin": "^1.6.0",
"optimize-css-assets-webpack-plugin": "^6.0.1",
"playwright": "^1.33.0",
"playwright-webextext": "^0.0.3",
"playwright": "^1.49.0",
"playwright-webextext": "^0.0.4",
"postcss": "^8.4.31",
"postcss-loader": "^4.3.0",
"prettier": "^2.3.0",
Expand Down
2 changes: 2 additions & 0 deletions source/types/ReportedModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class ReportedElement extends ReportedObject {
// This gets the full URL rather than a relative one
const a: HTMLAnchorElement = element as HTMLAnchorElement;
this.href = a.toString();
} else if (element.tagName === 'FORM') {
this.formId = Array.prototype.slice.call(document.forms).indexOf(element);
} else if (element.tagName === 'INPUT') {
// Capture extra useful info for input elements
const input: HTMLInputElement = element as HTMLInputElement;
Expand Down
6 changes: 3 additions & 3 deletions test/ContentScript/unitTests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ test('Report page forms', () => {
// Then
expect(mockFn.mock.calls.length).toBe(2);
expect(mockFn.mock.calls[0][0].toNonTimestampString()).toBe(
'{"type":"nodeAdded","tagName":"FORM","id":"form1","nodeName":"FORM","url":"http://localhost/","text":"Content1"}'
'{"type":"nodeAdded","tagName":"FORM","id":"form1","nodeName":"FORM","url":"http://localhost/","text":"Content1","formId":-1}'
);
expect(mockFn.mock.calls[1][0].toNonTimestampString()).toBe(
'{"type":"nodeAdded","tagName":"FORM","id":"form2","nodeName":"FORM","url":"http://localhost/","text":"Content2"}'
'{"type":"nodeAdded","tagName":"FORM","id":"form2","nodeName":"FORM","url":"http://localhost/","text":"Content2","formId":-1}'
);
});

Expand Down Expand Up @@ -263,7 +263,7 @@ test('Reported page loaded', () => {
'{"type":"nodeAdded","tagName":"AREA","id":"","nodeName":"AREA","url":"http://localhost/","href":"https://www.example.com/1","text":""}'
);
expect(mockFn.mock.calls[2][0].toNonTimestampString()).toBe(
'{"type":"nodeAdded","tagName":"FORM","id":"form1","nodeName":"FORM","url":"http://localhost/","text":"FormContent"}'
'{"type":"nodeAdded","tagName":"FORM","id":"form1","nodeName":"FORM","url":"http://localhost/","text":"FormContent","formId":-1}'
);
expect(mockFn.mock.calls[3][0].toNonTimestampString()).toBe(
'{"type":"nodeAdded","tagName":"INPUT","id":"input1","nodeName":"INPUT","url":"http://localhost/","text":"default","tagType":"text"}'
Expand Down
29 changes: 18 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6741,17 +6741,24 @@ [email protected]:
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.33.0.tgz#269efe29a927cd6d144d05f3c2d2f72bd72447a1"
integrity sha512-aizyPE1Cj62vAECdph1iaMILpT0WUDCq3E6rW6I+dleSbBoGbktvJtzS6VHkZ4DKNEOG9qJpiom/ZxO+S15LAw==

playwright-webextext@^0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/playwright-webextext/-/playwright-webextext-0.0.3.tgz#8f809a439c976dd71a7a4d2f711b01a10d910a8a"
integrity sha512-qcnMZES3vbnEfCrOobsaFrT+BBlRgCmKBCzhoRxPkdC9C5KSOYdROikuTHRoe/ez5v1Eh02szQjwRBStOkDF6g==

playwright@^1.33.0:
version "1.33.0"
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.33.0.tgz#88df1cffe97718ab8a02303e12c9133681ec7fab"
integrity sha512-+zzU3V2TslRX2ETBRgQKsKytYBkJeLZ2xzUj4JohnZnxQnivoUvOvNbRBYWSYykQTO0Y4zb8NwZTYFUO+EpPBQ==
dependencies:
playwright-core "1.33.0"
[email protected]:
version "1.49.1"
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.49.1.tgz#32c62f046e950f586ff9e35ed490a424f2248015"
integrity sha512-BzmpVcs4kE2CH15rWfzpjzVGhWERJfmnXmniSyKeRZUs9Ws65m+RGIi7mjJK/euCegfn3i7jvqWeWyHe9y3Vgg==

playwright-webextext@^0.0.4:
version "0.0.4"
resolved "https://registry.yarnpkg.com/playwright-webextext/-/playwright-webextext-0.0.4.tgz#84ec8b7999aac758a5dccc34c01353bad2d9c5d8"
integrity sha512-B5uIZSRtH6wi5HPhEwbEkZxEoAY5bUKCjqVW2qCsAYWQTQZ4ULOfsyglI+gfiohxrAzHT+mtkZMXZvHTtunsDg==

playwright@^1.49.0:
version "1.49.1"
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.49.1.tgz#830266dbca3008022afa7b4783565db9944ded7c"
integrity sha512-VYL8zLoNTBxVOrJBbDuRgDWa3i+mfQgDTrL8Ah9QXZ7ax4Dsj0MSq5bYgytRnDVVe+njoKnfsYkH3HzqVj5UZA==
dependencies:
playwright-core "1.49.1"
optionalDependencies:
fsevents "2.3.2"

please-upgrade-node@^3.2.0:
version "3.2.0"
Expand Down
Loading