浏览代码

Add GUI specific tests (#767)

* Use composite action

* increase test scope for e2e test

* make a changes on gui.py

* update path

* add shell default param

* add default shell

* use mypy for pyi generation

* only run pyi test on ubuntu

* Update action.yml

* only run pyi test on ubuntu

* filter prefix test to only run on ubuntu
dinhlongnguyen 1 年之前
父节点
当前提交
a7c41ab681

+ 16 - 0
.github/actions/gui-test/action.yml

@@ -0,0 +1,16 @@
+name: GUI test
+description: Run specific test cases for Taipy GUI
+inputs:
+  os:
+    required: true
+runs:
+  using: "composite"
+  steps:
+    - name: end-to-end tests
+      uses: ./.github/actions/gui-test/e2e
+    - name: prefix tests
+      if: inputs.os == 'ubuntu-latest'
+      uses: ./.github/actions/gui-test/prefix
+    - name: verify pyi
+      if: inputs.os == 'ubuntu-latest'
+      uses: ./.github/actions/gui-test/pyi

+ 10 - 0
.github/actions/gui-test/e2e/action.yml

@@ -0,0 +1,10 @@
+name: end-to-end test
+runs:
+  using: "composite"
+  steps:
+    - name: install kernel
+      shell: bash
+      run: pipenv run ipython kernel install --name "python3" --user
+    - name: run tests
+      shell: bash
+      run: pipenv run pytest -m "teste2e" tests/gui

+ 14 - 0
.github/actions/gui-test/prefix/action.yml

@@ -0,0 +1,14 @@
+name: Prefix (baseURL) Test
+runs:
+  using: "composite"
+  steps:
+    - name: Build the Docker image
+      shell: bash
+      working-directory: ./tools/gui/docker/nginx-prefix
+      run: docker build . --file Dockerfile --tag taipy-nginx-proxy
+    - name: run nginx reverse proxy docker container
+      shell: bash
+      run: docker run -d -p 4000:4000 taipy-nginx-proxy
+    - name: run pytest with prefix configuration
+      shell: bash
+      run: pipenv run pytest -m "teste2e" tests/gui/e2e --e2e-base-url="/prefix/" --e2e-port="4000"

+ 14 - 0
.github/actions/gui-test/pyi/action.yml

@@ -0,0 +1,14 @@
+name: Verify pyi
+description: Verify automatic pyi file generation process
+runs:
+  using: "composite"
+  steps:
+    - name: install dependency
+      shell: bash
+      run: pipenv run pip install mypy black isort
+    - name: Generate pyi
+      shell: bash
+      run: cp tools/gui/generate_pyi.py pyi_temp.py && pipenv run python pyi_temp.py && rm pyi_temp.py
+    - name: Cleanup any untracked files
+      shell: bash
+      run: git clean -f

+ 5 - 2
.github/workflows/partial-tests.yml

@@ -43,6 +43,7 @@ jobs:
               - 'taipy/core/**'
               - 'taipy/core/**'
             gui:
             gui:
               - 'taipy/gui/**'
               - 'taipy/gui/**'
+              - 'frontend/taipy-gui/**'
             gui-core:
             gui-core:
               - 'taipy/gui_core/**'
               - 'taipy/gui_core/**'
             logger:
             logger:
@@ -91,9 +92,11 @@ jobs:
         if: steps.changes.outputs.core == 'true'
         if: steps.changes.outputs.core == 'true'
         run: pipenv run pytest -m "not orchestrator_dispatcher and not standalone" tests/core
         run: pipenv run pytest -m "not orchestrator_dispatcher and not standalone" tests/core
 
 
-      - name: Pytest GUI
+      - name: Run GUI Test Action
         if: steps.changes.outputs.gui == 'true'
         if: steps.changes.outputs.gui == 'true'
-        run: pipenv run pytest tests/gui
+        uses: ./.github/actions/gui-test
+        with:
+          os: ${{ matrix.os }}
 
 
       - name: Pytest GUI Core
       - name: Pytest GUI Core
         if: steps.changes.outputs.gui-core == 'true'
         if: steps.changes.outputs.gui-core == 'true'

+ 2 - 1
taipy/gui/gui.py

@@ -212,6 +212,7 @@ class Gui:
     __DO_NOT_UPDATE_VALUE = _DoNotUpdate()
     __DO_NOT_UPDATE_VALUE = _DoNotUpdate()
     _HTML_CONTENT_KEY = "__taipy_html_content"
     _HTML_CONTENT_KEY = "__taipy_html_content"
     __USER_CONTENT_CB = "custom_user_content_cb"
     __USER_CONTENT_CB = "custom_user_content_cb"
+    __ROBOTO_FONT = "https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
 
 
     __RE_HTML = re.compile(r"(.*?)\.html$")
     __RE_HTML = re.compile(r"(.*?)\.html$")
     __RE_MD = re.compile(r"(.*?)\.md$")
     __RE_MD = re.compile(r"(.*?)\.md$")
@@ -2208,7 +2209,7 @@ class Gui:
         if self._get_config("stylekit", True):
         if self._get_config("stylekit", True):
             styles.append("stylekit/stylekit.css")
             styles.append("stylekit/stylekit.css")
         else:
         else:
-            styles.append("https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap")
+            styles.append(Gui.__ROBOTO_FONT)
         if self.__css_file:
         if self.__css_file:
             styles.append(f"/{self.__css_file}")
             styles.append(f"/{self.__css_file}")
 
 

+ 2 - 2
tools/gui/generate_pyi.py

@@ -53,9 +53,9 @@ builder_py_file = "./taipy/gui/builder/__init__.py"
 builder_pyi_file = builder_py_file + "i"
 builder_pyi_file = builder_py_file + "i"
 with open("./taipy/gui/viselements.json", "r") as file:
 with open("./taipy/gui/viselements.json", "r") as file:
     viselements = json.load(file)
     viselements = json.load(file)
-with open("./tools/builder/block.txt", "r") as file:
+with open("./tools/gui/builder/block.txt", "r") as file:
     block_template = file.read()
     block_template = file.read()
-with open("./tools/builder/control.txt", "r") as file:
+with open("./tools/gui/builder/control.txt", "r") as file:
     control_template = file.read()
     control_template = file.read()
 
 
 os.system(f"pipenv run stubgen {builder_py_file} --no-import --parse-only --export-less -o ./")
 os.system(f"pipenv run stubgen {builder_py_file} --no-import --parse-only --export-less -o ./")