From 9a46fae1f11a09e0c411cd5d121e366856e29528 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Thu, 12 Sep 2024 16:42:21 +0200 Subject: [PATCH] Skip instead of comment test --- test/system/scratchpad_test.rb | 88 +++++++++++++++++----------------- 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/test/system/scratchpad_test.rb b/test/system/scratchpad_test.rb index 9e87b19602..4a75271dc4 100644 --- a/test/system/scratchpad_test.rb +++ b/test/system/scratchpad_test.rb @@ -37,47 +37,49 @@ def run_code(code) codemirror_send_keys(find_by_id('scratchpad-editor-wrapper'), code) find_button('__papyros-run-code-btn', disabled: false, wait: 20).click end - # - # test 'Scratchpad can run code' do - # ## Hello World! - # code = "print(\"Hello World!\")\n" - # run_code code - # output_area = find_by_id('scratchpad-output-wrapper') - # # First run, so wait longer for output to appear - # output_area.find('span', text: 'Hello World!', wait: 20) - # - # # Scratchpad can process user input in interactive mode - # scratchpad_input = 'Echo' - # code = "print(input())\n" - # run_code code - # # Enter the input during the run - # find_field('__papyros-code-input-area', disabled: false).send_keys scratchpad_input - # find_button('__papyros-send-input-btn', disabled: false).click - # - # output_area.find('span', text: scratchpad_input) - # - # # Scratchpad can process user input in batch mode - # scratchpad_input = 'Batch' - # # Set the input before the run - # find_by_id('__papyros-switch-input-mode').click - # # input area should be re-rendered - # codemirror_send_keys(find_by_id('scratchpad-input-wrapper'), "#{scratchpad_input}\n") - # run_code '' - # - # output_area.find('span', text: scratchpad_input) - # - # # Scratchpad can sleep and be interrupted - # code = "import time\nprint(\"Start\")\ntime.sleep(3)\nprint(\"Stop\")\n" - # run_code code - # - # output_area.find('span', text: 'Start') - # output_area.find('span', text: 'Stop') - # run_code '' - # sleep(1) - # find_button('__papyros-stop-btn', disabled: false).click - # - # output_area.find('span', text: 'Start') - # - # assert output_area.has_no_xpath?('.//span', text: 'Stop') - # end + + test 'Scratchpad can run code' do + skip("This test fails infrequently, but i haven't figured out why yet") + + ## Hello World! + code = "print(\"Hello World!\")\n" + run_code code + output_area = find_by_id('scratchpad-output-wrapper') + # First run, so wait longer for output to appear + output_area.find('span', text: 'Hello World!', wait: 20) + + # Scratchpad can process user input in interactive mode + scratchpad_input = 'Echo' + code = "print(input())\n" + run_code code + # Enter the input during the run + find_field('__papyros-code-input-area', disabled: false).send_keys scratchpad_input + find_button('__papyros-send-input-btn', disabled: false).click + + output_area.find('span', text: scratchpad_input) + + # Scratchpad can process user input in batch mode + scratchpad_input = 'Batch' + # Set the input before the run + find_by_id('__papyros-switch-input-mode').click + # input area should be re-rendered + codemirror_send_keys(find_by_id('scratchpad-input-wrapper'), "#{scratchpad_input}\n") + run_code '' + + output_area.find('span', text: scratchpad_input) + + # Scratchpad can sleep and be interrupted + code = "import time\nprint(\"Start\")\ntime.sleep(3)\nprint(\"Stop\")\n" + run_code code + + output_area.find('span', text: 'Start') + output_area.find('span', text: 'Stop') + run_code '' + sleep(1) + find_button('__papyros-stop-btn', disabled: false).click + + output_area.find('span', text: 'Start') + + assert output_area.has_no_xpath?('.//span', text: 'Stop') + end end