-
Notifications
You must be signed in to change notification settings - Fork 985
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2fa disabling ask password -- Take 2 (#6527)
* Extract modal close to its own controller Remove unused `index` parameter * Add `confirm_password_modal` macro * Add confirm_password_controller and hook up to confirm_password modal * Have DeleteTOTPForm check user's password * Pass username and password to form as expected by PasswordMixin Allow `username` to be set as an instance variable * Fix tests and set password visibility on connect * Add test for username set as instance variable in form * Rename form field for consistency * Amend copy on incorrect credentials * Pass parameters to confirm_password_modal * Add confirm password to DeleteMacaroonForm * Fix tests * Fix linting * Add UsernameMixin to DeleteMacaroonForm and DeleteTOTPForm Avoid passing the username to constructor simplifying base class * Fix linting * Fix tests after merge * Remove `index` parameter from call to `confirm_modal` * Reinstate id and fix missing name on modal input * Require user password to delete account Add confirm_password_button macro * Fix linting * Fix sorting imports * Reinstate index kwargs to confirm_password_button * Add translation to modal text * Remove index parameter from confirm_modal macros * Fix call to gettext * Add tests for ModalClose controller Amend tests for Confirm controller
- Loading branch information
Showing
14 changed files
with
316 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* global expect, beforeEach, describe, it */ | ||
|
||
import { Application } from "stimulus"; | ||
import ModalCloseController from "../../warehouse/static/js/warehouse/controllers/modal_close_controller"; | ||
|
||
describe("Modal close controller", () => { | ||
beforeEach(() => { | ||
document.body.innerHTML = ` | ||
<div class="modal" data-controller="modal-close"> | ||
<div class="modal__content" role="dialog"> | ||
<a id="cancel" href="#modal-close" data-action="click->modal-close#cancel" title="Close" class="modal__close"> | ||
<i class="fa fa-times" aria-hidden="true"></i> | ||
<span class="sr-only">close</span> | ||
</a> | ||
<div class="modal__body"> | ||
<h3 class="modal__title">Modal Title</h3> | ||
<input id="input-target" name="package" data-target="modal-close.input" type="text" autocomplete="off" autocorrect="off" autocapitalize="off"> | ||
<div class="modal__footer"> | ||
<button id="button-target" data-target="modal-close.button" type="submit"> | ||
Confirm | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
`; | ||
|
||
const application = Application.start(); | ||
application.register("modal-close", ModalCloseController); | ||
}); | ||
|
||
describe("clicking cancel", function() { | ||
it("sets the window location, resets the input target and disables the button", function() { | ||
document.getElementById("cancel").click(); | ||
|
||
expect(window.location.href).toContain("#modal-close"); | ||
const inputTarget = document.getElementById("input-target"); | ||
expect(inputTarget.value).toEqual(""); | ||
const buttonTarget = document.getElementById("button-target"); | ||
expect(buttonTarget).toHaveAttribute("disabled"); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.