From 9ef77d057a80eee3d999953e2d3e28bec5a9fdc0 Mon Sep 17 00:00:00 2001 From: Dzmitry Hramyka Date: Wed, 20 Sep 2023 15:32:07 +0200 Subject: [PATCH] add sodar-pr-btn-submit-once class and usage (#1233) --- .../templates/filesfolders/file_form.html | 2 +- .../templates/filesfolders/folder_form.html | 2 +- .../filesfolders/hyperlink_form.html | 2 +- .../static/projectroles/js/projectroles.js | 15 ++++++++ .../templates/projectroles/project_form.html | 2 +- .../projectroles/projectinvite_form.html | 2 +- .../projectroles/remotesite_form.html | 2 +- .../projectroles/roleassignment_form.html | 2 +- .../templates/projectroles/user_form.html | 2 +- projectroles/tests/test_ui.py | 35 ++++++++++++++++++- tokens/templates/tokens/token_create.html | 2 +- 11 files changed, 58 insertions(+), 10 deletions(-) diff --git a/filesfolders/templates/filesfolders/file_form.html b/filesfolders/templates/filesfolders/file_form.html index ba595751..da8526dc 100644 --- a/filesfolders/templates/filesfolders/file_form.html +++ b/filesfolders/templates/filesfolders/file_form.html @@ -73,7 +73,7 @@

> Cancel - diff --git a/filesfolders/templates/filesfolders/hyperlink_form.html b/filesfolders/templates/filesfolders/hyperlink_form.html index 980c5286..fae41126 100644 --- a/filesfolders/templates/filesfolders/hyperlink_form.html +++ b/filesfolders/templates/filesfolders/hyperlink_form.html @@ -61,7 +61,7 @@

> Cancel - diff --git a/projectroles/templates/projectroles/remotesite_form.html b/projectroles/templates/projectroles/remotesite_form.html index 82636da6..4576fde6 100644 --- a/projectroles/templates/projectroles/remotesite_form.html +++ b/projectroles/templates/projectroles/remotesite_form.html @@ -25,7 +25,7 @@

{% if object.pk %}Update{% else %}Add{% endif %} {% if site_mode == 'TARGET' href="{{ request.session.real_referer }}"> Cancel - diff --git a/projectroles/templates/projectroles/roleassignment_form.html b/projectroles/templates/projectroles/roleassignment_form.html index 28988df2..172ab9c2 100644 --- a/projectroles/templates/projectroles/roleassignment_form.html +++ b/projectroles/templates/projectroles/roleassignment_form.html @@ -44,7 +44,7 @@

Add Member

data-toggle="modal" data-target="#sodar-modal"> Preview - diff --git a/projectroles/tests/test_ui.py b/projectroles/tests/test_ui.py index 72f0166c..c262fe58 100644 --- a/projectroles/tests/test_ui.py +++ b/projectroles/tests/test_ui.py @@ -1,6 +1,8 @@ """UI tests for the projectroles app""" import socket +import time + from urllib.parse import urlencode from django.conf import settings @@ -15,7 +17,10 @@ from django.urls import reverse from selenium import webdriver -from selenium.common.exceptions import NoSuchElementException +from selenium.common.exceptions import ( + NoSuchElementException, + StaleElementReferenceException, +) from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as ec from selenium.webdriver.support.ui import WebDriverWait, Select @@ -1688,6 +1693,34 @@ def test_settings_label_icon(self): ).find_element(By.TAG_NAME, 'svg') self.assertTrue(logo.is_displayed()) + def test_submit_button(self): + """Test rendering of submit button""" + url = reverse( + 'projectroles:create', kwargs={'project': self.category.sodar_uuid} + ) + self.login_and_redirect( + self.superuser, url, wait_elem=None, wait_loc='ID' + ) + element = self.selenium.find_element( + By.CLASS_NAME, 'sodar-pr-btn-submit-once' + ) + self.assertEqual(element.text, 'Create') + self.assertTrue(element.is_enabled()) + # Define maximum number of retries and retry interval + max_retries = 50 + retry_interval = 0.2 + element.click() + for i in range(max_retries): + try: + if element.is_enabled() and i < max_retries - 1: + time.sleep(retry_interval) + else: + self.fail( + 'Element did not become enabled within the timeout' + ) + except StaleElementReferenceException: + break + class TestProjectUpdateView(TestUIBase): """Tests for ProjectUpdateView UI""" diff --git a/tokens/templates/tokens/token_create.html b/tokens/templates/tokens/token_create.html index 58a6679b..26f130f9 100644 --- a/tokens/templates/tokens/token_create.html +++ b/tokens/templates/tokens/token_create.html @@ -20,7 +20,7 @@

Create API Token

href="{% url 'tokens:list' %}"> Cancel -