Skip to content

Commit

Permalink
test(webapp): Add playwright tests
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinepouille committed Oct 31, 2024
1 parent bafaeb8 commit ed90e8f
Show file tree
Hide file tree
Showing 141 changed files with 3,134 additions and 34 deletions.
44 changes: 42 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,48 @@ jobs:
name: windows
path: KappappWin.zip

webapp-playwright-test:
needs: [cli-and-doc, webapp-ubuntu]
# if: github.ref == 'refs/heads/master'
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: |
npm ci
sudo apt-get update
sudo apt-get install lighttpd
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Download online-ui
uses: actions/download-artifact@v4
with:
name: online-ui
- name: Setup webapp server
run: |
> echo '
include_shell "/usr/share/lighttpd/create-mime.conf.pl"
server.document-root = "./site"
server.port = 12345
server.username = "root"
server.groupname = "root"
' > lighttpd.conf
lighttpd -f lighttpd.conf -D
- name: Run Playwright tests
run: DEBUG=pw:webserver npx playwright test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30

deploy:
needs: [cli-and-doc, webapp-ubuntu, webapp-macos, webapp-windows]
needs: [cli-and-doc, webapp-ubuntu, webapp-macos, webapp-windows, webapp-playwright-test]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-22.04
strategy:
Expand All @@ -201,7 +241,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download doc artifact
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{matrix.deploy-name}}
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,8 @@ man/KaSim_manual.ilg
man/KaSim_manual.ind
man/scripts/inputs~0.ka
man/scripts/ode.m
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
13 changes: 9 additions & 4 deletions dev/publish-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ Create a new release draft

- Title:
```
Kappa Software Suite version 4.1.3
Kappa Software Suite version v4.1.3
```

- Text:
```
v4.1.3
Kappa Software Suite version 4.1.3
Kappa Software Suite version v4.1.3
```

Set last release as previous tag, then click _Generate release notes_ and edit results to keep what's relevant
Expand All @@ -74,12 +74,17 @@ Add files for:
Kappapp_for_linux.tar.gz
Kappapp_for_mac_os_10.15.zip
Kappapp_for_windows.zip
```
taken from nightly builds: https://tools.kappalanguage.org/nightly-builds/

Source code from release tag https://github.com/Kappa-Dev/KappaTools/releases/tag/v4.1.3 should appear automatically

```
Source code (zip)
Source code (tar.gz)
```

electron are from nightly builds: https://tools.kappalanguage.org/nightly-builds/
Source code from release tag https://github.com/Kappa-Dev/KappaTools/releases/tag/v4.1.3


### Pip

Expand Down
8 changes: 6 additions & 2 deletions gui/state/runtime_web_workers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ class runtime_kasim_as_web_worker () : Api.concrete_manager =
without_kasim#terminate;
kasim_worker##terminate

method is_computing = without_kasim#is_computing || self#sim_is_computing
method is_computing =
without_kasim#is_computing || self#sim_is_computing
|| self#story_is_computing

method project_parse ~patternSharing overwrites =
let simulation_load (patternSharing : Pattern.sharing_level)
Expand All @@ -236,6 +238,7 @@ class runtime_kasim_as_web_worker () : Api.concrete_manager =
overwrites
end

(* TODO: deprecate this? *)
class runtime_kasim_embedded_in_main_thread () : Api.concrete_manager =
let system_process : Kappa_facade.system_process =
object
Expand All @@ -262,7 +265,8 @@ class runtime_kasim_embedded_in_main_thread () : Api.concrete_manager =
without_kasim#terminate;
() (*TODO*)

method is_computing = true (*TODO*)
method is_computing =
without_kasim#is_computing || self#is_computing || self#story_is_computing

method project_parse ~patternSharing overwrites =
let simulation_load patternSharing parsing_compil overwrites =
Expand Down
19 changes: 10 additions & 9 deletions gui/state/state_project.ml
Original file line number Diff line number Diff line change
Expand Up @@ -210,22 +210,23 @@ let set_show_non_weakly_reversible_transitions
update_parameters (fun param ->
{ param with show_non_weakly_reversible_transitions })

let update_state me project_catalog default_parameters project_parameters =
me.project_manager#project_parse ~patternSharing:Pattern.Compatible_patterns
[]
let update_state project project_catalog default_parameters project_parameters =
project.project_manager#project_parse
~patternSharing:Pattern.Compatible_patterns []
>>= fun (out : unit Api.result) ->
set_state
{
project_current = Some me;
project_current = Some project;
project_catalog;
default_parameters;
project_parameters;
project_version = 1;
};
Lwt.return out

let computing_watcher manager setter =
let computing_watcher (manager : Api.concrete_manager) (setter : bool -> unit) =
let delay = 1. in
(* Note: cancel logic seems not to be implemented? *)
let cancelled = ref false in
let rec loop () =
setter manager#is_computing;
Expand Down Expand Up @@ -254,7 +255,7 @@ let add_project is_new project_id : unit Api.lwt_result =
let project_watcher_cancel =
computing_watcher project_manager (set_computes ?step:None)
in
let me =
let project : a_project =
{
project_id;
project_manager;
Expand All @@ -267,9 +268,9 @@ let add_project is_new project_id : unit Api.lwt_result =
Mods.StringMap.add project_id default_parameters
state_va.project_parameters
in
Lwt.return (Result_util.ok (me, me :: catalog, params))))
>>= Api_common.result_bind_with_lwt ~ok:(fun (me, catalog, params) ->
update_state me catalog state_va.default_parameters params)
Lwt.return (Result_util.ok (project, project :: catalog, params))))
>>= Api_common.result_bind_with_lwt ~ok:(fun (project, catalog, params) ->
update_state project catalog state_va.default_parameters params)

let create_project project_id = add_project true project_id
let set_project project_id = add_project false project_id
Expand Down
10 changes: 7 additions & 3 deletions gui/ui/panel_preferences.ml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ module InputPlotPeriod : Ui_common.Div = struct
end

module DivErrorMessage : Ui_common.Div = struct
let id = "configuration_error_div"
let id_error = "configuration_error_div"
let id_alert = "configuration_alert_div"
let id = id_error
(* TODO: clean this id matter *)

let message_nav_inc_id = "panel_preferences_message_nav_inc_id"
let message_nav_dec_id = "panel_preferences_message_nav_dec_id"
let message_file_label_id = "panel_preferences_message_file_label"
Expand Down Expand Up @@ -276,14 +280,14 @@ module DivErrorMessage : Ui_common.Div = struct

let error_message =
Html.span
~a:[ Html.a_id id; Html.a_class [ "error-span" ] ]
~a:[ Html.a_id id_error; Html.a_class [ "error-span" ] ]
[ Tyxml_js.R.Html.txt error_message_text ]

let alert_messages =
Html.div
~a:
[
Html.a_id id;
Html.a_id id_alert;
Tyxml_js.R.Html.a_class
(React.S.bind (Hooked.S.to_react_signal State_error.errors)
(fun error ->
Expand Down
7 changes: 6 additions & 1 deletion gui/ui/panel_projects.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
module Html = Tyxml_js.Html5

let project_id_modal_id = "menu-editor-project-id-modal"
let projects_tabs_id = "projects_tabs"

let project_id_input =
Html.input
Expand All @@ -29,7 +30,11 @@ let content () =
Html.div
[
Tyxml_js.R.Html5.ul
~a:[ Html.a_class [ "nav"; "nav-tabs"; "nav-justified" ] ]
~a:
[
Html.a_id projects_tabs_id;
Html.a_class [ "nav"; "nav-tabs"; "nav-justified" ];
]
(ReactiveData.RList.from_signal
(React.S.map
(fun model ->
Expand Down
13 changes: 8 additions & 5 deletions gui/ui/panel_projects_controller.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@

open Lwt.Infix

let refresh r =
let r' = State_file.sync ~reset:true () in
let r'' = State_simulation.refresh () in
r' >>= fun r' ->
r'' >>= fun r'' -> Lwt.return (Api_common.result_combine [ r; r'; r'' ])
let refresh result_before =
let lwt_result_state_file_sync = State_file.sync ~reset:true () in
let lwt_result_simulation_refresh = State_simulation.refresh () in
lwt_result_state_file_sync >>= fun result_state_file_sync ->
lwt_result_simulation_refresh >>= fun result_simulation_refresh ->
Lwt.return
(Api_common.result_combine
[ result_before; result_state_file_sync; result_simulation_refresh ])

let create_project (project_id : string) : unit =
Common.async __LOC__ (fun () ->
Expand Down
5 changes: 3 additions & 2 deletions gui/ui/panel_tabs/tab_editor/editor.ml
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,10 @@ let onload () : unit =
let delay : float =
if (Js.str_array change##.text)##.length > 1 || State_error.has_errors ()
then
1.0 *. 1000.0
(* Not sure why this logic for errors *)
0.9 *. 1000.0
else
5.0 *. 1000.0
1.0 *. 1000.0
in
let handle_timeout () =
let () = State_file.out_of_sync false in
Expand Down
6 changes: 1 addition & 5 deletions gui/ui/panel_tabs/tab_editor/subtab_influences.ml
Original file line number Diff line number Diff line change
Expand Up @@ -611,11 +611,7 @@ let content () =
Html.div ~a:[ Html.a_id display_id; Html.a_class [ "flex-content" ] ] [];
];
Tyxml_js.R.Html5.div
~a:
[
Html.a_id "TODOTODOTODOTODOTODOTODOTODOTODOTODOTODOTODOTODOTODO";
Html.a_class [ "panel-scroll" ];
]
~a:[ Html.a_id "influences-table"; Html.a_class [ "panel-scroll" ] ]
(ReactiveData.RList.from_signal
(React.S.l3
(fun { rendering; origin_label; _ } sphere _ ->
Expand Down
2 changes: 1 addition & 1 deletion gui/ui/panel_tabs/tab_stories.ml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ let rec inspect_stories () =
>>= Result_util.fold
~ok:(fun is_computing ->
if is_computing && React.S.value tab_is_active then
Js_of_ocaml_lwt.Lwt_js.sleep 3. >>= inspect_stories
Js_of_ocaml_lwt.Lwt_js.sleep 1. >>= inspect_stories
else
Lwt.return_unit)
~error:(fun _ -> Lwt.return_unit)
Expand Down
Loading

0 comments on commit ed90e8f

Please sign in to comment.