From cdd58c77aaace751493a04320241868d37f0be27 Mon Sep 17 00:00:00 2001 From: Yuyutsu Rai <113098086+Yuyuutsu@users.noreply.github.com> Date: Wed, 8 May 2024 09:23:43 +0100 Subject: [PATCH 1/2] Create test cases for rules that compare to a boolean (#1348) * Create Test for Boolean Flag * revert accidental edit on test * format files using prettier * make booleanFlag null instead of false * revert booleanFlag default value to False * update description for functional tests * update Functional test description to be generic * update booleanFlag configuratgion in jwt helper for recent v2 change * fix lint spacing for json --- tests/functional/jwt_helper.js | 6 +++-- .../spec/features/routing/boolean.spec.js | 22 +++++++++++++++++++ tests/functional/wdio.conf.js | 2 ++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 tests/functional/spec/features/routing/boolean.spec.js diff --git a/tests/functional/jwt_helper.js b/tests/functional/jwt_helper.js index 2862cffd75..ba8d84c65d 100644 --- a/tests/functional/jwt_helper.js +++ b/tests/functional/jwt_helper.js @@ -76,6 +76,7 @@ export function generateToken( includeLogoutUrl = true, displayAddress = "", cirInstrumentId = null, + booleanFlag = false, }, ) { let schemaParams = {}; @@ -113,7 +114,7 @@ export function generateToken( region_code: regionCode, language_code: languageCode, account_service_url: "http://localhost:8000", - survey_metadata: getSurveyMetadata(theme, userId, displayAddress, surveyId, periodId, periodStr, ruRef, sdsDatasetId), + survey_metadata: getSurveyMetadata(theme, userId, displayAddress, surveyId, periodId, periodStr, ruRef, sdsDatasetId, booleanFlag), version: launchVersion, response_expires_at: isoDate, }; @@ -158,7 +159,7 @@ export function generateToken( }); } -function getSurveyMetadata(theme, userId, displayAddress, surveyId, periodId, periodStr, ruRef, sdsDatasetId) { +function getSurveyMetadata(theme, userId, displayAddress, surveyId, periodId, periodStr, ruRef, sdsDatasetId, booleanFlag) { let surveyMetadata = {}; if (theme === "social") { @@ -185,6 +186,7 @@ function getSurveyMetadata(theme, userId, displayAddress, surveyId, periodId, pe return_by: "2017-03-01", ru_name: "Apple", trad_as: "Apple", + boolean_flag: booleanFlag, }, }; } diff --git a/tests/functional/spec/features/routing/boolean.spec.js b/tests/functional/spec/features/routing/boolean.spec.js new file mode 100644 index 0000000000..4359c1e996 --- /dev/null +++ b/tests/functional/spec/features/routing/boolean.spec.js @@ -0,0 +1,22 @@ +import Block1Page from "../../../generated_pages/metadata_routing/block1.page"; +import Block2Page from "../../../generated_pages/metadata_routing/block2.page"; +import Block3Page from "../../../generated_pages/metadata_routing/block3.page"; +import { click } from "../../../helpers"; + +describe("Feature: Routing - Boolean Flag", () => { + it("Given I have a routing rule that uses a boolean flag and it is False, When I press continue, Then I should be routed to the correct page", async () => { + await browser.openQuestionnaire("test_metadata_routing.json", { + booleanFlag: false, + }); + await click(Block1Page.submit()); + await expect(browser).toHaveUrlContaining(Block2Page.pageName); + }); + + it("Given I have a routing rule that uses a boolean flag and it is True, When I press continue, Then I should be routed to the correct page ", async () => { + await browser.openQuestionnaire("test_metadata_routing.json", { + booleanFlag: true, + }); + await click(Block1Page.submit()); + await expect(browser).toHaveUrlContaining(Block3Page.pageName); + }); +}); diff --git a/tests/functional/wdio.conf.js b/tests/functional/wdio.conf.js index 3bfd8aad63..74dd7065b9 100644 --- a/tests/functional/wdio.conf.js +++ b/tests/functional/wdio.conf.js @@ -215,6 +215,7 @@ export const config = { language = "en", includeLogoutUrl = false, cirInstrumentId = null, + booleanFlag = false, } = {}, ) { const token = await JwtHelper.generateToken(schema, { @@ -232,6 +233,7 @@ export const config = { languageCode: language, includeLogoutUrl, cirInstrumentId, + booleanFlag, }); this.url(`/session?token=${token}`); }, From 1f851ca8d84f3289cadea67f93b13e5f3d6509a6 Mon Sep 17 00:00:00 2001 From: liamtoozer Date: Wed, 8 May 2024 11:22:22 +0100 Subject: [PATCH 2/2] Update tests with new supplementary dataset IDs (#1341) --- .../spec/features/hub_and_spoke/hub_and_spoke.spec.js | 2 +- .../supplementary_data/supplementary_data.spec.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/functional/spec/features/hub_and_spoke/hub_and_spoke.spec.js b/tests/functional/spec/features/hub_and_spoke/hub_and_spoke.spec.js index 592e06c284..830d98ced4 100644 --- a/tests/functional/spec/features/hub_and_spoke/hub_and_spoke.spec.js +++ b/tests/functional/spec/features/hub_and_spoke/hub_and_spoke.spec.js @@ -308,7 +308,7 @@ describe("Feature: Hub and Spoke", () => { await browser.openQuestionnaire("test_hub_section_required_with_repeat_supplementary.json.json", { version: "v2", - sdsDatasetId: "c067f6de-6d64-42b1-8b02-431a3486c178", + sdsDatasetId: "d8afa921-1305-d553-d2c6-955a6db2cc2d", responseId, }); }); diff --git a/tests/functional/spec/features/supplementary_data/supplementary_data.spec.js b/tests/functional/spec/features/supplementary_data/supplementary_data.spec.js index da0eaae74f..e9539e0788 100644 --- a/tests/functional/spec/features/supplementary_data/supplementary_data.spec.js +++ b/tests/functional/spec/features/supplementary_data/supplementary_data.spec.js @@ -42,7 +42,7 @@ describe("Using supplementary data", () => { before("Starting the survey", async () => { await browser.openQuestionnaire("test_supplementary_data.json", { version: "v2", - sdsDatasetId: "c067f6de-6d64-42b1-8b02-431a3486c178", + sdsDatasetId: "d8afa921-1305-d553-d2c6-955a6db2cc2d", responseId, }); }); @@ -341,7 +341,7 @@ describe("Using supplementary data", () => { it("Given I relaunch the survey with new supplementary data and new list items for the repeating section, When I open the Hub page, Then I see the new supplementary list items as new incomplete sections and not any old ones", async () => { await browser.openQuestionnaire("test_supplementary_data.json", { version: "v2", - sdsDatasetId: "693dc252-2e90-4412-bd9c-c4d953e36fcd", + sdsDatasetId: "1f61750f-51dd-e933-0df9-40261b06d93f", responseId, }); await expect(await $(HubPage.summaryItems("section-4-1")).getText()).toContain("Harry Potter"); @@ -391,7 +391,7 @@ describe("Using supplementary data", () => { await expect(await $(HubPage.summaryRowState("section-6")).getText()).toBe("Completed"); await browser.openQuestionnaire("test_supplementary_data.json", { version: "v2", - sdsDatasetId: "c067f6de-6d64-42b1-8b02-431a3486c178", + sdsDatasetId: "d8afa921-1305-d553-d2c6-955a6db2cc2d", responseId, }); await expect(await $(HubPage.summaryRowState("section-6")).getText()).toBe("Partially completed"); @@ -401,7 +401,7 @@ describe("Using supplementary data", () => { it("Given I return to the new data resulting in a new incomplete section, When I start the section, Then I see the new supplementary data piped in accordingly", async () => { await browser.openQuestionnaire("test_supplementary_data.json", { version: "v2", - sdsDatasetId: "693dc252-2e90-4412-bd9c-c4d953e36fcd", + sdsDatasetId: "1f61750f-51dd-e933-0df9-40261b06d93f", responseId, }); await click(HubPage.submit());