Skip to content

Commit

Permalink
Ensure that <input type="reset"> clears values that were restored f…
Browse files Browse the repository at this point in the history
…rom cache
  • Loading branch information
entretechno-jeremiah committed Jun 1, 2022
1 parent 1abbdbc commit d82b832
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/tests/fixtures/rendering.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ <h1>Rendering</h1>
<select id="select-multiple" multiple><option value="1">1</option><option value="2">2</option></select>

<input type="password" id="password-input" />

<input type="reset" id="reset-input" />
</form>
</section>
<div id="permanent" data-turbo-permanent>Rendering</div>
Expand Down
23 changes: 23 additions & 0 deletions src/tests/functional/rendering_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,29 @@ export class RenderingTests extends TurboDriveTestCase {
this.assert.equal(await this.remote.findById("password-input").getProperty("value"), "")
}

async "test <input type='reset'> clears values when restored from cache"() {
await this.remote.findById("text-input").click().type("test")
await this.remote.findById("checkbox-input").click()
await this.remote.findById("radio-input").click()
await this.remote.findById("textarea").click().type("test")
await this.remote.findById("select").findAllByCssSelector('option[value="2"]').click()
await this.remote.findById("select-multiple").findByCssSelector('option[value="2"]').click()

this.clickSelector("#same-origin-link")
await this.nextBody
await this.goBack()
await this.nextBody

await this.remote.findById("reset-input").click()

this.assert.equal(await this.remote.findById("text-input").getProperty("value"), "")
this.assert.equal(await this.remote.findById("checkbox-input").getProperty("checked"), false)
this.assert.equal(await this.remote.findById("radio-input").getProperty("checked"), false)
this.assert.equal(await this.remote.findById("textarea").getProperty("value"), "")
this.assert.equal(await this.remote.findById("select").getProperty("value"), "1")
this.assert.equal(await this.remote.findById("select-multiple").getProperty("value"), "")
}

async "test before-cache event"() {
this.beforeCache((body) => (body.innerHTML = "Modified"))
this.clickSelector("#same-origin-link")
Expand Down

0 comments on commit d82b832

Please sign in to comment.