From c34a1c15b9ce048cdb20e04da7a2387fc37fcc38 Mon Sep 17 00:00:00 2001 From: VirajP1002 Date: Thu, 16 May 2024 19:19:29 +0100 Subject: [PATCH 01/10] Update design system version --- .design-system-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.design-system-version b/.design-system-version index 1f5c54aff3..14a228fe9a 100644 --- a/.design-system-version +++ b/.design-system-version @@ -1 +1 @@ -70.0.2 +70.0.5 From 601fe50b087903ce14d98d94cf027dd6a7ce6e53 Mon Sep 17 00:00:00 2001 From: VirajP1002 Date: Thu, 16 May 2024 19:20:23 +0100 Subject: [PATCH 02/10] Update jinja filters to include iconVisuallyHiddenText in row item --- app/jinja_filters.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/jinja_filters.py b/app/jinja_filters.py index d910df59a0..1ebd696725 100644 --- a/app/jinja_filters.py +++ b/app/jinja_filters.py @@ -711,6 +711,7 @@ def map_list_collector_config( row_item = { "iconType": icon, + "iconVisuallyHiddenText": "Section complete", "actions": actions, "id": list_item.get("list_item_id"), "rowTitleAttributes": { From 662f6c86010387a6eebb8aeaa0f03043d5ec5b62 Mon Sep 17 00:00:00 2001 From: VirajP1002 Date: Fri, 17 May 2024 17:21:58 +0100 Subject: [PATCH 03/10] Update jinja_filters to ensure there is no iconVisuallyHiddenText when render_icon is None --- app/jinja_filters.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/jinja_filters.py b/app/jinja_filters.py index 1ebd696725..38629c00d2 100644 --- a/app/jinja_filters.py +++ b/app/jinja_filters.py @@ -709,9 +709,15 @@ def map_list_collector_config( else None ) + iconVisuallyHiddenText = ( + "Section complete" + if icon == "check" + else None + ) + row_item = { "iconType": icon, - "iconVisuallyHiddenText": "Section complete", + "iconVisuallyHiddenText": iconVisuallyHiddenText, "actions": actions, "id": list_item.get("list_item_id"), "rowTitleAttributes": { From 4ac308cf13fb392b8caae9c8fbd4ded4406c3cdf Mon Sep 17 00:00:00 2001 From: VirajP1002 Date: Fri, 17 May 2024 17:22:55 +0100 Subject: [PATCH 04/10] Fix tests by including iconVisuallyHiddenText and create test case where a checkmark is present --- tests/app/test_jinja_filters.py | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/app/test_jinja_filters.py b/tests/app/test_jinja_filters.py index 5824a91831..7fe3933b64 100644 --- a/tests/app/test_jinja_filters.py +++ b/tests/app/test_jinja_filters.py @@ -534,6 +534,7 @@ def test_map_list_collector_config_no_actions(): "rowItems": [ { "actions": [], + "iconVisuallyHiddenText": None, "iconType": None, "id": "one", "rowTitleAttributes": { @@ -548,6 +549,7 @@ def test_map_list_collector_config_no_actions(): "rowItems": [ { "actions": [], + "iconVisuallyHiddenText": None, "iconType": None, "id": "two", "rowTitleAttributes": { @@ -605,6 +607,7 @@ def test_map_list_collector_config(): "url": "/primary/change", } ], + "iconVisuallyHiddenText": None, "iconType": None, "id": "primary", "rowTitleAttributes": { @@ -633,6 +636,7 @@ def test_map_list_collector_config(): }, ], "iconType": None, + "iconVisuallyHiddenText": None, "id": "nonprimary", "rowTitleAttributes": { "data-list-item-id": "nonprimary", @@ -727,6 +731,7 @@ def test_map_list_collector_config_with_related_answers_and_answer_title(): "url": "/nonprimary/remove", }, ], + "iconVisuallyHiddenText": None, "iconType": None, "id": "VHoiow", "rowTitle": "Name of UK company or branch", @@ -1022,6 +1027,7 @@ def test_summary_item_config_with_list_collector(): "url": "remove_link_url", }, ], + "iconVisuallyHiddenText": None, "iconType": None, "id": "vmmPmD", "rowTitle": "Company A", @@ -1181,6 +1187,7 @@ def test_summary_item_config_with_list_collector_and_one_related_answer(): "url": "remove_link_url", }, ], + "iconVisuallyHiddenText": None, "iconType": None, "id": "vmmPmD", "rowTitle": "Company A", @@ -1281,6 +1288,48 @@ def test_summary_item_config_with_list_collector_and_one_related_answer(): assert to_dict(expected) == to_dict(result) +def test_map_list_collector_config_set_icon_type(): + list_items = [ + {"item_title": "Mark Bloggs", "list_item_id": "one", "repeating_blocks": True, "is_complete": True}, + {"item_title": "Joe Bloggs", "list_item_id": "two", "repeating_block": True, "is_complete": False}, + ] + + output = map_list_collector_config(list_items, True, True) + + expected = [ + { + "rowItems": [ + { + "actions": [], + "iconVisuallyHiddenText": "Section complete", + "iconType": "check", + "id": "one", + "rowTitleAttributes": { + "data-list-item-id": "one", + "data-qa": "list-item-1-label", + }, + "rowTitle": "Mark Bloggs", + } + ] + }, + { + "rowItems": [ + { + "actions": [], + "iconVisuallyHiddenText": None, + "iconType": None, + "id": "two", + "rowTitleAttributes": { + "data-list-item-id": "two", + "data-qa": "list-item-2-label", + }, + "rowTitle": "Joe Bloggs", + } + ] + }, + ] + + assert output == expected def to_dict(obj): return json.loads(json.dumps(obj, default=lambda o: o.__dict__)) From 05dab5b993d5fede46120f8450ca674e683c062b Mon Sep 17 00:00:00 2001 From: VirajP1002 Date: Fri, 17 May 2024 17:23:53 +0100 Subject: [PATCH 05/10] Update test name --- tests/app/test_jinja_filters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/app/test_jinja_filters.py b/tests/app/test_jinja_filters.py index 7fe3933b64..159e4be763 100644 --- a/tests/app/test_jinja_filters.py +++ b/tests/app/test_jinja_filters.py @@ -1288,7 +1288,7 @@ def test_summary_item_config_with_list_collector_and_one_related_answer(): assert to_dict(expected) == to_dict(result) -def test_map_list_collector_config_set_icon_type(): +def test_map_list_collector_config_render_icon_set(): list_items = [ {"item_title": "Mark Bloggs", "list_item_id": "one", "repeating_blocks": True, "is_complete": True}, {"item_title": "Joe Bloggs", "list_item_id": "two", "repeating_block": True, "is_complete": False}, From 620d6ee1b1ed7aea7f22d45429a8dc3fe0c29a7a Mon Sep 17 00:00:00 2001 From: VirajP1002 Date: Fri, 17 May 2024 17:29:02 +0100 Subject: [PATCH 06/10] Format code --- app/jinja_filters.py | 6 +----- tests/app/test_jinja_filters.py | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/jinja_filters.py b/app/jinja_filters.py index 38629c00d2..6ea6ffd2d7 100644 --- a/app/jinja_filters.py +++ b/app/jinja_filters.py @@ -709,11 +709,7 @@ def map_list_collector_config( else None ) - iconVisuallyHiddenText = ( - "Section complete" - if icon == "check" - else None - ) + iconVisuallyHiddenText = "Section complete" if icon == "check" else None row_item = { "iconType": icon, diff --git a/tests/app/test_jinja_filters.py b/tests/app/test_jinja_filters.py index 159e4be763..cd797dc875 100644 --- a/tests/app/test_jinja_filters.py +++ b/tests/app/test_jinja_filters.py @@ -1288,10 +1288,21 @@ def test_summary_item_config_with_list_collector_and_one_related_answer(): assert to_dict(expected) == to_dict(result) + def test_map_list_collector_config_render_icon_set(): list_items = [ - {"item_title": "Mark Bloggs", "list_item_id": "one", "repeating_blocks": True, "is_complete": True}, - {"item_title": "Joe Bloggs", "list_item_id": "two", "repeating_block": True, "is_complete": False}, + { + "item_title": "Mark Bloggs", + "list_item_id": "one", + "repeating_blocks": True, + "is_complete": True, + }, + { + "item_title": "Joe Bloggs", + "list_item_id": "two", + "repeating_block": True, + "is_complete": False, + }, ] output = map_list_collector_config(list_items, True, True) @@ -1331,5 +1342,6 @@ def test_map_list_collector_config_render_icon_set(): assert output == expected + def to_dict(obj): return json.loads(json.dumps(obj, default=lambda o: o.__dict__)) From f38dc36c11c110acba204b612111904a5fb73941 Mon Sep 17 00:00:00 2001 From: VirajP1002 Date: Mon, 20 May 2024 15:13:25 +0100 Subject: [PATCH 07/10] Fix functional tests --- tests/functional/helpers.js | 6 +++++- .../list_collector_repeating_blocks.spec.js | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/functional/helpers.js b/tests/functional/helpers.js index 213369f7f8..0bbaca1562 100644 --- a/tests/functional/helpers.js +++ b/tests/functional/helpers.js @@ -2,7 +2,11 @@ export const checkItemsInList = async (itemsExpected, listLabel) => { await $(listLabel(1)).waitForDisplayed(); for (let i = 1; i <= itemsExpected.length; i++) { - await expect(await $(listLabel(i)).getText()).toEqual(itemsExpected[i - 1]); + let text = await $(listLabel(i)).getText(); + if (text.includes("Section complete")) { + text = text.replace("Section complete\n", ""); + } + $(text).isEqual(itemsExpected[i - 1]); } }; diff --git a/tests/functional/spec/features/repeating_blocks/list_collector_repeating_blocks.spec.js b/tests/functional/spec/features/repeating_blocks/list_collector_repeating_blocks.spec.js index 62340d9f5f..7d988db8a0 100644 --- a/tests/functional/spec/features/repeating_blocks/list_collector_repeating_blocks.spec.js +++ b/tests/functional/spec/features/repeating_blocks/list_collector_repeating_blocks.spec.js @@ -96,7 +96,7 @@ describe("List Collector Repeating Blocks", () => { await $(AnyOtherCompaniesOrBranchesPage.listEditLink(2)).click(); await $(EditCompanyPage.companyOrBranchName()).setValue("Government"); await click(EditCompanyPage.submit()); - await expect(await $(AnyOtherCompaniesOrBranchesPage.listLabel(2)).getText()).toBe("Government"); + await checkItemsInList(["ONS", "GOV", "Government"], AnyOtherCompaniesOrBranchesPage.listLabel); }); it("When the user clicks the remove link, Then the item selected is removed", async () => { @@ -105,7 +105,6 @@ describe("List Collector Repeating Blocks", () => { await click(RemoveCompanyPage.submit()); await checkItemsInList(["ONS", "MOD"], AnyOtherCompaniesOrBranchesPage.listLabel); await expect(await $(AnyOtherCompaniesOrBranchesPage.listLabel(2)).getText()).not.toContain("Government"); - await expect(await $(AnyOtherCompaniesOrBranchesPage.listLabel(2)).getText()).toBe("MOD"); }); it("When a user has finished editing or removing from the list, Then they are still able to add additional companies", async () => { From ba41d1d259a0773ed0be89c139f1543426caddfc Mon Sep 17 00:00:00 2001 From: VirajP1002 Date: Tue, 21 May 2024 13:34:48 +0100 Subject: [PATCH 08/10] Refactor jinja_filters, change the text read out by the screenreader and fix tests --- app/jinja_filters.py | 4 +--- tests/app/test_jinja_filters.py | 2 +- tests/functional/helpers.js | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/jinja_filters.py b/app/jinja_filters.py index 6ea6ffd2d7..1c65af0dad 100644 --- a/app/jinja_filters.py +++ b/app/jinja_filters.py @@ -709,11 +709,9 @@ def map_list_collector_config( else None ) - iconVisuallyHiddenText = "Section complete" if icon == "check" else None - row_item = { "iconType": icon, - "iconVisuallyHiddenText": iconVisuallyHiddenText, + "iconVisuallyHiddenText": "Completed" if icon else None, "actions": actions, "id": list_item.get("list_item_id"), "rowTitleAttributes": { diff --git a/tests/app/test_jinja_filters.py b/tests/app/test_jinja_filters.py index cd797dc875..f25aae9593 100644 --- a/tests/app/test_jinja_filters.py +++ b/tests/app/test_jinja_filters.py @@ -1312,7 +1312,7 @@ def test_map_list_collector_config_render_icon_set(): "rowItems": [ { "actions": [], - "iconVisuallyHiddenText": "Section complete", + "iconVisuallyHiddenText": "Completed", "iconType": "check", "id": "one", "rowTitleAttributes": { diff --git a/tests/functional/helpers.js b/tests/functional/helpers.js index 0bbaca1562..5bc258601f 100644 --- a/tests/functional/helpers.js +++ b/tests/functional/helpers.js @@ -3,8 +3,8 @@ export const checkItemsInList = async (itemsExpected, listLabel) => { for (let i = 1; i <= itemsExpected.length; i++) { let text = await $(listLabel(i)).getText(); - if (text.includes("Section complete")) { - text = text.replace("Section complete\n", ""); + if (text.includes("Completed")) { + text = text.replace("Completed\n", ""); } $(text).isEqual(itemsExpected[i - 1]); } From 5b5f869e64dcfd9dffdeb8e204e1c59f2275675f Mon Sep 17 00:00:00 2001 From: VirajP1002 Date: Thu, 23 May 2024 13:21:33 +0100 Subject: [PATCH 09/10] Add params to method for clarity --- tests/app/test_jinja_filters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/app/test_jinja_filters.py b/tests/app/test_jinja_filters.py index f25aae9593..8d76e96c56 100644 --- a/tests/app/test_jinja_filters.py +++ b/tests/app/test_jinja_filters.py @@ -1305,7 +1305,7 @@ def test_map_list_collector_config_render_icon_set(): }, ] - output = map_list_collector_config(list_items, True, True) + output = map_list_collector_config(list_items, editable=True, render_icon=True) expected = [ { From 65cdafe9abaeb270c91933e57dff303350b99542 Mon Sep 17 00:00:00 2001 From: VirajP1002 Date: Fri, 24 May 2024 15:51:37 +0100 Subject: [PATCH 10/10] Update helpers and fix tests --- tests/functional/helpers.js | 6 +----- .../list_collector_repeating_blocks.spec.js | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/functional/helpers.js b/tests/functional/helpers.js index 5bc258601f..c0fa90daae 100644 --- a/tests/functional/helpers.js +++ b/tests/functional/helpers.js @@ -2,11 +2,7 @@ export const checkItemsInList = async (itemsExpected, listLabel) => { await $(listLabel(1)).waitForDisplayed(); for (let i = 1; i <= itemsExpected.length; i++) { - let text = await $(listLabel(i)).getText(); - if (text.includes("Completed")) { - text = text.replace("Completed\n", ""); - } - $(text).isEqual(itemsExpected[i - 1]); + await expect(await $(listLabel(i)).getText()).toContain(itemsExpected[i - 1]); } }; diff --git a/tests/functional/spec/features/repeating_blocks/list_collector_repeating_blocks.spec.js b/tests/functional/spec/features/repeating_blocks/list_collector_repeating_blocks.spec.js index 7d988db8a0..4e2fcd403c 100644 --- a/tests/functional/spec/features/repeating_blocks/list_collector_repeating_blocks.spec.js +++ b/tests/functional/spec/features/repeating_blocks/list_collector_repeating_blocks.spec.js @@ -96,7 +96,7 @@ describe("List Collector Repeating Blocks", () => { await $(AnyOtherCompaniesOrBranchesPage.listEditLink(2)).click(); await $(EditCompanyPage.companyOrBranchName()).setValue("Government"); await click(EditCompanyPage.submit()); - await checkItemsInList(["ONS", "GOV", "Government"], AnyOtherCompaniesOrBranchesPage.listLabel); + await checkItemsInList(["ONS", "Government", "MOD"], AnyOtherCompaniesOrBranchesPage.listLabel); }); it("When the user clicks the remove link, Then the item selected is removed", async () => {