Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update list collector content page to use list component #1490

Merged
merged 43 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
c893eac
Update component used in listcollectorcontent templaye
VirajP1002 Aug 27, 2024
1c1976b
Refactor variables
VirajP1002 Aug 30, 2024
2fc1fbd
Update design system
VirajP1002 Aug 30, 2024
67feb7f
Update type hints and format
VirajP1002 Aug 30, 2024
94fd280
Update type hints to adhere to standards
VirajP1002 Aug 30, 2024
1a4fe6d
Merge branch 'main' into update-list-collector-content-page
VirajP1002 Aug 30, 2024
22b4fc7
Merge branch 'main' into update-list-collector-content-page
rmccar Sep 3, 2024
dbd6e78
formatting
rmccar Sep 3, 2024
42bdcfb
fix tests
rmccar Sep 4, 2024
be4c962
fix tests
rmccar Sep 4, 2024
2899761
Merge branch 'main' into update-list-collector-content-page
rmccar Sep 4, 2024
e495a56
Merge branch 'main' into update-list-collector-content-page
rmccar Sep 6, 2024
ce4164c
update ds version
rmccar Sep 6, 2024
01dc80e
Merge branch 'update-list-collector-content-page' of github.com:ONSdi…
rmccar Sep 6, 2024
11ffc9d
update to ds 70.0.14
rmccar Sep 9, 2024
d9f5b1b
Merge branch 'main' into update-list-collector-content-page
rmccar Sep 10, 2024
b30e9bb
update ds version
rmccar Sep 10, 2024
c7b8e4a
update test
rmccar Sep 10, 2024
f99e6e9
remove ds version change
rmccar Sep 10, 2024
adfc77f
typo
rmccar Sep 10, 2024
b8b4cd0
Merge branch 'main' into update-list-collector-content-page
rmccar Sep 12, 2024
9ed0a19
Merge branch 'main' into update-list-collector-content-page
rmccar Sep 16, 2024
feb8b10
fix tests
rmccar Sep 16, 2024
8a7b220
Merge branch 'update-list-collector-content-page' of github.com:ONSdi…
rmccar Sep 16, 2024
eac796a
Merge branch 'main' into update-list-collector-content-page
rmccar Sep 16, 2024
0e95e5d
add await
rmccar Sep 16, 2024
2305146
format
rmccar Sep 16, 2024
9984c53
Merge branch 'main' into update-list-collector-content-page
rmccar Sep 16, 2024
0cc2011
Merge branch 'main' into update-list-collector-content-page
rmccar Sep 17, 2024
7479c54
Merge branch 'main' into update-list-collector-content-page
rmccar Sep 17, 2024
35e6398
update test
rmccar Sep 17, 2024
7d151f5
remove incomplete versions of helpers
rmccar Sep 17, 2024
710dd93
Merge branch 'main' into update-list-collector-content-page
rmccar Sep 17, 2024
4289f98
update ds version
rmccar Sep 17, 2024
80c62ef
Merge branch 'update-list-collector-content-page' of github.com:ONSdi…
rmccar Sep 17, 2024
eaa7e73
fix test
rmccar Sep 17, 2024
4decbb6
add intergration test
rmccar Sep 17, 2024
88e3008
Merge branch 'main' into update-list-collector-content-page
rmccar Sep 17, 2024
0fe6760
run format
rmccar Sep 17, 2024
b7cd8b7
fix test type
rmccar Sep 18, 2024
294ab12
remove data-list-item-id
rmccar Sep 18, 2024
176d590
fix test
rmccar Sep 18, 2024
a57b597
Merge branch 'main' into update-list-collector-content-page
rmccar Sep 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion app/jinja_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,31 @@ def map_summary_item_config_processor() -> dict[str, Callable]:
return {"map_summary_item_config": map_summary_item_config}


@blueprint.app_context_processor
def map_list_config_processor() -> dict[str, Callable]:
return {"map_list_config": map_list_config}


@blueprint.app_template_filter()
def map_list_config(list_values: list[dict]) -> list[dict]:
items_list: list[dict] = []

for index, value in enumerate(list_values, 1):
item: dict = {"text": value["item_title"]}

if value["is_complete"]:
item["iconType"] = "check"

item["attributes"] = {
"data-qa": f"list-item-{index}-label",
"data-list-item-id": value["list_item_id"],
berroar marked this conversation as resolved.
Show resolved Hide resolved
}

items_list.append(item)

return items_list


# pylint: disable=too-many-locals
@blueprint.app_template_filter()
def map_list_collector_config(
Expand All @@ -665,7 +690,7 @@ def map_list_collector_config(
) -> list[dict[str, list] | SummaryRow]:
rows: list[dict[str, list] | SummaryRow] = []

for index, list_item in enumerate(list_items, start=1):
for index, list_item in enumerate(list_items, 1):
item_name = str(list_item.get("item_title"))

actions = []
Expand Down
17 changes: 15 additions & 2 deletions templates/listcollectorcontent.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

{% import "macros/helpers.html" as helpers %}

{% from "components/list/_macro.njk" import onsList %}

{% set save_on_signout = true %}
{% set continue_button_text = _("Continue") %}
{% set title = content.title %}
Expand All @@ -10,8 +12,19 @@
{% block form_content %}
<h1>{{ title }}</h1>
{%- if content.list and content.list.list_items -%}
{% set list = content.list %}
<div class="ons-u-mb-m">{% include "partials/summary/list-summary.html" %}</div>
{% set list = content.list.list_items %}
<div class="ons-u-mb-m">
{# djlint:off #}
{% set itemsList = map_list_config(list) %}
{{
onsList({
"variants": "summary",
"iconPosition": "before",
"itemsList": itemsList,
})
}}
{# djlint:on #}
</div>
{%- endif -%}
{% include "partials/contents.html" %}
{% endblock form_content %}
9 changes: 5 additions & 4 deletions tests/functional/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ export const checkItemsInList = async (itemsExpected, listLabel) => {
}
};

export const checkListItemComplete = async (listItemLabel) => {
await expect(await $(listItemLabel).$(`.ons-summary__item-title-icon.ons-summary__item-title-icon--check`).isExisting()).toBe(true);
export const summaryItemComplete = async (summaryItemLabel, status) => {
await expect(await $(summaryItemLabel).$(`.ons-summary__item-title-icon.ons-summary__item-title-icon--check`).isExisting()).toBe(status);
};
export const checkListItemIncomplete = async (listItemLabel) => {
await expect(await $(listItemLabel).$(`.ons-summary__item-title-icon.ons-summary__item-title-icon--check`).isExisting()).toBe(false);

export const listItemComplete = async (listItemLabel, status) => {
await expect(await $(listItemLabel).$(`.ons-list__prefix.ons-list__prefix--icon-check`).isExisting()).toBe(status);
};

const assertSummaryFunction = (selector) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import AnyOtherCompaniesOrBranchesPage from "../../../generated_pages/list_colle
import SectionCompaniesPage from "../../../generated_pages/list_collector_repeating_blocks_section_summary/section-companies-summary.page";
import AnyOtherTradingDetailsPage from "../../../generated_pages/list_collector_repeating_blocks_section_summary/any-other-trading-details.page";
import SubmitPage from "../../../generated_pages/list_collector_repeating_blocks_section_summary/submit.page";
import { repeatingAnswerChangeLink, checkItemsInList, checkListItemComplete, checkListItemIncomplete, click } from "../../../helpers";
import { repeatingAnswerChangeLink, checkItemsInList, summaryItemComplete, click } from "../../../helpers";
import HubPage from "../../../base_pages/hub.page";
import ResponsiblePartyHubPage from "../../../generated_pages/list_collector_repeating_blocks_with_hub/responsible-party-business.page";
import { expect } from "@wdio/globals";
Expand Down Expand Up @@ -159,10 +159,10 @@ describe("List Collector Repeating Blocks", () => {

// Only the ONS and NAV items should be complete
await checkItemsInList(["ONS", "GOV", "MOD", "NAV"], AnyOtherCompaniesOrBranchesPage.listLabel);
await checkListItemComplete(`dt[data-qa="list-item-1-label"]`);
await checkListItemIncomplete(`dt[data-qa="list-item-2-label"]`);
await checkListItemIncomplete(`dt[data-qa="list-item-3-label"]`);
await checkListItemComplete(`dt[data-qa="list-item-1-label"]`);
await summaryItemComplete(`dt[data-qa="list-item-1-label"]`, true);
await summaryItemComplete(`dt[data-qa="list-item-2-label"]`, false);
await summaryItemComplete(`dt[data-qa="list-item-3-label"]`, false);
await summaryItemComplete(`dt[data-qa="list-item-1-label"]`, true);
});

it("When an item has incomplete repeating blocks, Then using submit on the list collector page will navigate the user to the first incomplete repeating block.", async () => {
Expand Down Expand Up @@ -192,10 +192,10 @@ describe("List Collector Repeating Blocks", () => {
it("When the last remaining incomplete repeating block is completed, Then all items are marked as completed with the checkmark icon.", async () => {
await $(CompaniesRepeatingBlock2Page.authorisedTraderUkRadioNo()).click();
await click(CompaniesRepeatingBlock2Page.submit());
await checkListItemComplete(`dt[data-qa="list-item-1-label"]`);
await checkListItemComplete(`dt[data-qa="list-item-2-label"]`);
await checkListItemComplete(`dt[data-qa="list-item-3-label"]`);
await checkListItemComplete(`dt[data-qa="list-item-4-label"]`);
await summaryItemComplete(`dt[data-qa="list-item-1-label"]`, true);
await summaryItemComplete(`dt[data-qa="list-item-2-label"]`, true);
await summaryItemComplete(`dt[data-qa="list-item-3-label"]`, true);
await summaryItemComplete(`dt[data-qa="list-item-4-label"]`, true);
});

it("When the user clicks a change link from the section summary and submits without changing an answer, Then the user is returned to the section summary anchored to the answer they clicked on", async () => {
Expand Down Expand Up @@ -304,8 +304,8 @@ describe("List Collector Repeating Blocks", () => {
await $(CompaniesRepeatingBlock2Page.authorisedTraderUkRadioNo()).click();
await click(CompaniesRepeatingBlock2Page.submit());
await expect(browser).toHaveUrlContaining(AnyOtherCompaniesOrBranchesPage.pageName);
await checkListItemComplete(`dt[data-qa="list-item-1-label"]`);
await checkListItemComplete(`dt[data-qa="list-item-2-label"]`);
await summaryItemComplete(`dt[data-qa="list-item-1-label"]`, true);
await summaryItemComplete(`dt[data-qa="list-item-2-label"]`, true);
});

it("When another incomplete item is added via the section summary, Then navigating to the submit page of the section will redirect to the list collector page.", async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertSummaryItems, assertSummaryTitles, assertSummaryValues, checkListItemComplete, checkListItemIncomplete, click } from "../../../helpers";
import { assertSummaryItems, assertSummaryTitles, assertSummaryValues, listItemComplete, click } from "../../../helpers";
import { expect } from "@wdio/globals";
import { getRandomString } from "../../../jwt_helper";
import AddAdditionalEmployeePage from "../../../generated_pages/supplementary_data/list-collector-additional-add.page.js";
Expand Down Expand Up @@ -370,11 +370,11 @@ describe("Using supplementary data", () => {
it("Given there is now an additional product, When I resume the Product Details Section, Then I start from the list collector content block and see the new product is incomplete", async () => {
await $(HubPage.summaryRowLink("section-6")).click();
await expect(browser).toHaveUrlContaining(ListCollectorProductsPage.pageName);
await checkListItemComplete(`dt[data-qa="list-item-1-label"]`);
await checkListItemComplete(`dt[data-qa="list-item-2-label"]`);
await checkListItemIncomplete(`dt[data-qa="list-item-3-label"]`);
await listItemComplete(`li[data-qa="list-item-1-label"]`, true);
await listItemComplete(`li[data-qa="list-item-2-label"]`, true);
await listItemComplete(`li[data-qa="list-item-3-label"]`, true);
await click(ListCollectorProductsPage.submit());
await expect(browser).toHaveUrlContaining(ProductRepeatingBlock1Page.pageName);
await expect(await browser.toHaveUrlContaining(ProductRepeatingBlock1Page.pageName));
});

it("Given I complete the section and relaunch with the old data that has fewer items in the products list, When I am on the Hub, Then I see the products section and sales targets sections are now in progress", async () => {
Expand Down
12 changes: 6 additions & 6 deletions tests/functional/spec/list_collector_content.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import ListCollectorSecondRepeatingBlockPage from "../generated_pages/list_colle
import ListCollectorContentPage from "../generated_pages/list_collector_content_page/list-collector-content.page";
import ListCollectorContentSectionSummaryPage from "../generated_pages/list_collector_content_page/section-list-collector-contents-summary.page";
import ConfirmationCheckboxPage from "../generated_pages/list_collector_content_page/confirmation-checkbox.page";
import { checkListItemComplete, checkListItemIncomplete, click } from "../helpers";
import { listItemComplete, click } from "../helpers";

describe("List Collector Section Summary and Summary Items", () => {
describe("Given I launch the test list collector section summary items survey", () => {
Expand Down Expand Up @@ -92,13 +92,13 @@ describe("List Collector Section Summary and Summary Items", () => {
await expect(await $(HubPage.summaryRowState("section-list-collector-contents")).getText()).toBe("Partially completed");
await click(HubPage.submit());
await expect(browser).toHaveUrlContaining(ListCollectorContentPage.pageName);
await checkListItemComplete(`dt[data-qa="list-item-1-label"]`);
await checkListItemComplete(`dt[data-qa="list-item-2-label"]`);
await checkListItemIncomplete(`dt[data-qa="list-item-3-label"]`);
await listItemComplete(`li[data-qa="list-item-1-label"]`, true);
await listItemComplete(`li[data-qa="list-item-2-label"]`, true);
await listItemComplete(`li[data-qa="list-item-3-label"]`, false);
await click(ListCollectorContentPage.submit());
await expect(browser).toHaveUrlContaining(ListCollectorFirstRepeatingBlockPage.pageName);
await completeRepeatingBlocks(666, 2, 5, 1995, true, true);
await checkListItemComplete(`dt[data-qa="list-item-3-label"]`);
await listItemComplete(`li[data-qa="list-item-3-label"]`, true);
await click(ListCollectorContentPage.submit());
await click(ListCollectorContentSectionSummaryPage.submit());
await expect(await $(HubPage.summaryRowState("section-list-collector-contents")).getText()).toBe("Completed");
Expand All @@ -114,7 +114,7 @@ describe("List Collector Section Summary and Summary Items", () => {
await click(CompaniesSummaryPage.submit());
await expect(await $(HubPage.summaryRowState("section-list-collector-contents")).getText()).toBe("Partially completed");
await click(HubPage.submit());
await checkListItemComplete(`dt[data-qa="list-item-1-label"]`);
await listItemComplete(`li[data-qa="list-item-1-label"]`, true);
await click(ListCollectorContentPage.submit());
await expect(browser).toHaveUrlContaining(ListCollectorContentSectionSummaryPage.pageName);
await click(ListCollectorContentSectionSummaryPage.submit());
Expand Down
Loading