diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f787797..5995408 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -111,7 +111,7 @@ jobs: run: yarn - name: Install Playwright browsers - run: poetry run playwright install --with-deps chromium + run: poetry run playwright install chromium - name: Build frontend run: yarn build diff --git a/src/components/ParamSection/CommitDialog/ComparisonList.tsx b/src/components/ParamSection/CommitDialog/ComparisonList.tsx index ae98812..b881f0f 100644 --- a/src/components/ParamSection/CommitDialog/ComparisonList.tsx +++ b/src/components/ParamSection/CommitDialog/ComparisonList.tsx @@ -129,7 +129,12 @@ function DataDiffListItem({ name: nameOrUndefined, dataDiff }: DataDiffListItemP )} ) : ( - + None: expect(commit_message_input).to_have_value("") -# pylint: disable-next=too-many-locals def test_make_commit(page: Page) -> None: - """Can edit data and make a commit.""" + """ + Can edit data and make a commit, which also updates Param last updated timestamps. + """ commit_select_combobox = page.get_by_test_id("commit-select-combobox") commit_select_combobox_input = commit_select_combobox.get_by_role("combobox") commit_message = page.get_by_test_id("commit-message-text-field") commit_message_input = commit_message.get_by_role("textbox") - - int_item = page.get_by_test_id("parameter-list-item-int") - int_item_input = int_item.get_by_test_id("leaf-input").get_by_role("textbox") - int_old_item = page.get_by_test_id("comparison-list-item-old-int") - int_new_item = page.get_by_test_id("comparison-list-item-new-int") - float_item = page.get_by_test_id("parameter-list-item-float") float_item_input = float_item.get_by_test_id("leaf-input").get_by_role("textbox") - float_old_item = page.get_by_test_id("comparison-list-item-old-float") - float_new_item = page.get_by_test_id("comparison-list-item-new-float") - - str_item = page.get_by_test_id("parameter-list-item-str") - str_item_input = str_item.get_by_test_id("leaf-input").get_by_role("textbox") - str_old_item = page.get_by_test_id("comparison-list-item-old-str") - str_new_item = page.get_by_test_id("comparison-list-item-new-str") + param_item = page.get_by_test_id("parameter-list-item-param") + param_str_item = param_item.get_by_test_id("parameter-list-item-str") + param_str_item_input = param_str_item.get_by_test_id("leaf-input").get_by_role( + "textbox" + ) # Initial values - expect(int_item_input).to_have_value("123") expect(float_item_input).to_have_value("1.2345") - expect(str_item_input).to_have_value("test") + expect(param_item).to_contain_text(FIRST_COMMIT.date) + param_item.get_by_role("button").click() + expect(param_str_item_input).to_have_value("test") # Edit parameter values - int_item_input.fill("456") float_item_input.fill("5.6789") + param_str_item_input.fill("hello") - # Opem commit dialog + # Open commit dialog page.get_by_test_id("open-commit-dialog-button").click() # Commit list reflects what was changed expect(page.get_by_test_id("commit-changes-message")).to_have_text( f"Changes from latest commit ({FIRST_COMMIT.message})" ) - expect(int_old_item).to_have_text("int123") - expect(int_new_item).to_have_text("int456") - expect(float_old_item).to_have_text("float1.2345") - expect(float_new_item).to_have_text("float5.6789") - expect(str_old_item).not_to_be_attached() - expect(str_new_item).not_to_be_attached() + expect(page.get_by_test_id("comparison-list-item-old-int")).not_to_be_attached() + expect(page.get_by_test_id("comparison-list-item-new-int")).not_to_be_attached() + expect(page.get_by_test_id("comparison-list-item-old-float")).to_have_text( + "float1.2345" + ) + expect(page.get_by_test_id("comparison-list-item-new-float")).to_have_text( + "float5.6789" + ) + expect(page.get_by_test_id("comparison-list-item-param")).not_to_contain_text( + FIRST_COMMIT.date + ) + expect(page.get_by_test_id("comparison-list-item-old-str")).to_have_text("strtest") + expect(page.get_by_test_id("comparison-list-item-new-str")).to_have_text("strhello") # Enter message and make commit commit_message_input.fill(NEW_COMMIT_MESSAGE) @@ -106,9 +107,9 @@ def test_make_commit(page: Page) -> None: expect(commit_select_combobox_input).to_have_value(NEW_COMMIT.message) # Values were updated - expect(int_item).to_have_text("int456") expect(float_item).to_have_text("float5.679") - expect(str_item).to_have_text("strtest") + expect(param_item).not_to_contain_text(FIRST_COMMIT.date) + expect(param_str_item).to_have_text("strhello") def test_commit_backend_format(page: Page) -> None: @@ -118,7 +119,6 @@ def test_commit_backend_format(page: Page) -> None: """ commit_message = page.get_by_test_id("commit-message-text-field") commit_message_input = commit_message.get_by_role("textbox") - datetime_item = page.get_by_test_id("parameter-list-item-datetime") datetime_item_input = datetime_item.get_by_test_id("leaf-input").locator( "input[type=datetime-local]" @@ -143,3 +143,53 @@ def test_commit_backend_format(page: Page) -> None: # Load classes in the backend (test fails if this fails) load_classes_from_db() + + +def test_comparison_list_collapse(page: Page) -> None: + """Can collapse and expand items within the commit comparison list.""" + float_item = page.get_by_test_id("parameter-list-item-float") + float_item_input = float_item.get_by_test_id("leaf-input").get_by_role("textbox") + list_item = page.get_by_test_id("parameter-list-item-list") + list_second_item = list_item.get_by_test_id("parameter-list-item-1") + list_second_item_input = list_second_item.get_by_test_id("leaf-input").get_by_role( + "textbox" + ) + comparison_root_item = page.get_by_test_id("comparison-list-item-root") + comparison_root_item_button = comparison_root_item.get_by_role("button").first + comparison_list_item = page.get_by_test_id("comparison-list-item-list") + comparison_list_item_button = comparison_list_item.get_by_role("button").first + comparison_float_item = page.get_by_test_id("comparison-list-item-new-float") + comparison_list_second_item = comparison_list_item.get_by_test_id( + "comparison-list-item-new-1" + ) + + # Edit parameter values and open commit dialog + float_item_input.fill("5.6789") + list_item.get_by_role("button").click() + list_second_item_input.fill("hello") + page.get_by_test_id("open-commit-dialog-button").click() + + # Comparison list group items are initially expanded + expect(comparison_float_item).to_be_attached() + expect(comparison_list_item).to_be_attached() + expect(comparison_list_second_item).to_be_attached() + + # Can collapse the root item + comparison_root_item_button.click() + expect(comparison_float_item).not_to_be_attached() + expect(comparison_list_item).not_to_be_attached() + expect(comparison_list_second_item).not_to_be_attached() + + # Can expand the root item + comparison_root_item_button.click() + expect(comparison_float_item).to_be_attached() + expect(comparison_list_item).to_be_attached() + expect(comparison_list_second_item).to_be_attached() + + # Can collapse the list item + comparison_list_item_button.click() + expect(comparison_list_second_item).not_to_be_attached() + + # Can expand the list item + comparison_list_item_button.click() + expect(comparison_list_second_item).to_be_attached()