mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 01:55:40 +00:00
levels tests
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import getNumLevels from './levels/getNumLevels';
|
||||
import {Level} from './levels/index';
|
||||
import CONST from './const';
|
||||
import addLevelButtonAddEventListener from './addLevelButton';
|
||||
|
||||
@@ -89,8 +90,17 @@ export const getAddForm = () => `
|
||||
</form>
|
||||
`;
|
||||
|
||||
/** add level to DOM by filling add level form */
|
||||
/** add level to DOM by filling add level form and clicking "Add" button */
|
||||
export const addLevel = (visitor: number, diff: number) => {
|
||||
fillAddLevel(visitor, diff);
|
||||
const addLevelButton = <HTMLElement>(
|
||||
document.querySelector(`.${CONST.ADD_LEVEL_BUTTON}`)
|
||||
);
|
||||
addLevelButton.click();
|
||||
};
|
||||
|
||||
/** Fill add level form without clicking add button */
|
||||
export const fillAddLevel = (visitor: number, diff: number) => {
|
||||
addLevelButtonAddEventListener();
|
||||
|
||||
const level = getNumLevels();
|
||||
@@ -103,10 +113,41 @@ export const addLevel = (visitor: number, diff: number) => {
|
||||
document.getElementById(`${CONST.DIFFICULTY_WITHOUT_LEVEL}${level}`)
|
||||
);
|
||||
diffField.value = diff.toString();
|
||||
|
||||
const addLevelButton = <HTMLElement>(
|
||||
document.querySelector(`.${CONST.ADD_LEVEL_BUTTON}`)
|
||||
);
|
||||
|
||||
addLevelButton.click();
|
||||
};
|
||||
|
||||
/** Fill add level form without clicking add button */
|
||||
export const editLevel = (level: number, visitor?: number, diff?: number) => {
|
||||
if (visitor !== undefined) {
|
||||
const visitorField = <HTMLInputElement>(
|
||||
document.getElementById(`${CONST.VISITOR_WITHOUT_LEVEL}${level}`)
|
||||
);
|
||||
visitorField.value = visitor.toString();
|
||||
}
|
||||
|
||||
if (diff !== undefined) {
|
||||
const diffField = <HTMLInputElement>(
|
||||
document.getElementById(`${CONST.DIFFICULTY_WITHOUT_LEVEL}${level}`)
|
||||
);
|
||||
diffField.value = diff.toString();
|
||||
}
|
||||
};
|
||||
|
||||
export const level1: Level = {
|
||||
difficulty_factor: 200,
|
||||
visitor_threshold: 500,
|
||||
};
|
||||
|
||||
export const level1diffErr: Level = {
|
||||
difficulty_factor: 100,
|
||||
visitor_threshold: 600,
|
||||
};
|
||||
|
||||
export const level1visErr: Level = {
|
||||
difficulty_factor: 600,
|
||||
visitor_threshold: 400,
|
||||
};
|
||||
|
||||
export const level2: Level = {
|
||||
difficulty_factor: 400,
|
||||
visitor_threshold: 700,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user