Skip to content

Commit 723ea5a

Browse files
Clarify tests and comment re: hidden action input
1 parent 1af2d3f commit 723ea5a

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/review-form.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export class ReviewForm extends LitElement {
146146
name="g-recaptcha-response"
147147
.value=${this.recaptchaToken}
148148
/>
149+
<!-- Indicates to backend that form submission is intended -->
149150
<input type="hidden" name="action" value="1" />
150151
${this.identifier
151152
? html`<input

test/review-form.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('ReviewForm', () => {
3434
);
3535

3636
const form = el.shadowRoot?.querySelector('form');
37-
expect(form?.action).to.contain('/write-review.php');
37+
expect(form?.getAttribute('action')).to.contain('/write-review.php');
3838
});
3939

4040
it('uses a custom endpoint path for form submission if desired', async () => {
@@ -46,7 +46,7 @@ describe('ReviewForm', () => {
4646
);
4747

4848
const form = el.shadowRoot?.querySelector('form');
49-
expect(form?.action).to.equal('https://archive.org/foo');
49+
expect(form?.getAttribute('action')).to.equal('https://archive.org/foo');
5050
});
5151

5252
it('defaults to the prod base host for form submission', async () => {
@@ -55,7 +55,9 @@ describe('ReviewForm', () => {
5555
);
5656

5757
const form = el.shadowRoot?.querySelector('form');
58-
expect(form?.action).to.equal('https://archive.org/write-review.php');
58+
expect(form?.getAttribute('action')).to.equal(
59+
'https://archive.org/write-review.php',
60+
);
5961

6062
const cancelBtn = el.shadowRoot?.querySelector(
6163
'a[data-testid=cancel-btn]',
@@ -72,7 +74,9 @@ describe('ReviewForm', () => {
7274
);
7375

7476
const form = el.shadowRoot?.querySelector('form');
75-
expect(form?.action).to.equal('https://foo.archive.org/write-review.php');
77+
expect(form?.getAttribute('action')).to.equal(
78+
'https://foo.archive.org/write-review.php',
79+
);
7680

7781
const cancelBtn = el.shadowRoot?.querySelector(
7882
'a[data-testid=cancel-btn]',

0 commit comments

Comments
 (0)