Skip to content

Commit

Permalink
Fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
berroar committed Nov 7, 2023
2 parents c91b0fe + 9e2750e commit e786e48
Show file tree
Hide file tree
Showing 180 changed files with 2,347 additions and 2,368 deletions.
4 changes: 1 addition & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@
}
},
"plugins": [
"json",
"chai-friendly"
"json"
],
"rules": {
"no-loss-of-precision": 0,
"no-nonoctal-decimal-escape": 0,
"no-unsafe-optional-chaining": 0,
"no-useless-backreference": 0,
"chai-friendly/no-unused-expressions": 2,
"consistent-return": 1,
"indent": [
2,
Expand Down
2 changes: 1 addition & 1 deletion .schemas-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.76.0
v3.77.1
8 changes: 8 additions & 0 deletions app/authentication/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ def load_user(extend_session: bool = True) -> Optional[User]:

return user

if not session_store:
logger.info("session store doesn't exist") # pragma: no cover

elif not _is_session_valid(session_store):
logger.info(
"session has expired", session_expiry=session_store.expiration_time
) # pragma: no cover

logger.info("session does not exist")

cookie_session.pop(USER_IK, None)
Expand Down
13 changes: 13 additions & 0 deletions app/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ def get_questionnaire_store(user_id: str, user_ik: str) -> QuestionnaireStore:

def get_session_store() -> SessionStore | None:
if USER_IK not in cookie_session or EQ_SESSION_ID not in cookie_session:
if USER_IK not in cookie_session:
logger.info("user ik not found in cookie session") # pragma: no cover

if EQ_SESSION_ID not in cookie_session:
logger.info("eq session id not found in cookie session") # pragma: no cover

return None

# Sets up a single SessionStore instance per request context.
Expand All @@ -48,6 +54,9 @@ def get_session_store() -> SessionStore | None:
cookie_session[USER_IK], pepper, cookie_session[EQ_SESSION_ID]
)

if not store.session_data:
logger.info("session data not found") # pragma: no cover

return store if store.session_data else None


Expand All @@ -57,7 +66,11 @@ def get_session_timeout_in_seconds(schema: QuestionnaireSchema) -> int:
:return: Timeout in seconds
"""
default_session_timeout = current_app.config["EQ_SESSION_TIMEOUT_SECONDS"]
logger.info("default session timeout", timeout=default_session_timeout)

schema_session_timeout = schema.json.get("session_timeout_in_seconds")
logger.info("schema session timeout", timeout=schema_session_timeout)

timeout = (
schema_session_timeout
if schema_session_timeout and schema_session_timeout < default_session_timeout
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@
"@wdio/local-runner": "^8.14.3",
"@wdio/mocha-framework": "^8.14.0",
"@wdio/spec-reporter": "^8.14.0",
"chai": "^4.3.7",
"eslint": "^8.46.0",
"eslint-cli": "^1.1.1",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-chai-friendly": "^0.7.2",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-json": "^3.1.0",
"eslint-plugin-n": "^16.0.1",
Expand Down
14 changes: 1 addition & 13 deletions schemas/test/en/test_variants_question.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
"answers": [
{
"id": "age-answer",
"mandatory": false,
"mandatory": true,
"type": "Number",
"label": "Age"
}
Expand Down Expand Up @@ -443,18 +443,6 @@
}
],
"routing_rules": [
{
"block": "age-block",
"when": {
"==": [
{
"source": "answers",
"identifier": "age-confirm-answer"
},
"No"
]
}
},
{
"section": "End"
}
Expand Down
10 changes: 5 additions & 5 deletions tests/functional/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ export const checkItemsInList = async (itemsExpected, listLabel) => {
await $(listLabel(1)).waitForDisplayed();

for (let i = 1; i <= itemsExpected.length; i++) {
await expect(await $(listLabel(i)).getText()).to.equal(itemsExpected[i - 1]);
await expect(await $(listLabel(i)).getText()).toEqual(itemsExpected[i - 1]);
}
};

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

const assertSummaryFunction = (selector) => {
return async (entities) => {
// check each summary value/item/title is present and that the number of them matches what is on the page
await entities.map(async (entity, index) => {
await expect(await $$(selector)[index].getText()).to.equal(entity);
await expect(await $$(selector)[index].getText()).toEqual(entity);
});
await expect(await $$(selector).length).to.equal(entities.length);
await expect(await $$(selector).length).toEqual(entities.length);
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,59 +13,59 @@ describe("Answer Action: Redirect To List Add Question (Checkbox)", () => {
it('When the user selects "No", Then, they should be taken to the list collector.', async () => {
await $(AnyoneUsuallyLiveAt.no()).click();
await click(AnyoneUsuallyLiveAt.submit());
await expect(await browser.getUrl()).to.contain(AnyoneLiveAtListCollector.pageName);
await expect(browser).toHaveUrlContaining(AnyoneLiveAtListCollector.pageName);
});

it('When the user selects "Yes" then they should be taken to the list collector add question.', async () => {
await browser.url(AnyoneUsuallyLiveAt.url());
await $(AnyoneUsuallyLiveAt.iThinkSo()).click();
await click(AnyoneUsuallyLiveAt.submit());
await expect(await browser.getUrl()).to.contain(AnyoneLiveAtListCollectorAddPage.pageName);
await expect(await browser.getUrl()).to.contain("?previous=anyone-usually-live-at");
await expect(browser).toHaveUrlContaining(AnyoneLiveAtListCollectorAddPage.pageName);
await expect(browser).toHaveUrlContaining("?previous=anyone-usually-live-at");
});

it('When the user clicks the "Previous" link from the add question then they should be taken to the block they came from, not the list collector', async () => {
await $(AnyoneLiveAtListCollectorAddPage.previous()).click();
await expect(await browser.getUrl()).to.contain(AnyoneUsuallyLiveAt.pageName);
await expect(browser).toHaveUrlContaining(AnyoneUsuallyLiveAt.pageName);
});

it("When the user adds a household member, Then, they are taken to the list collector and the household members are displayed", async () => {
await click(AnyoneUsuallyLiveAt.submit());
await $(AnyoneLiveAtListCollectorAddPage.firstName()).setValue("Marcus");
await $(AnyoneLiveAtListCollectorAddPage.lastName()).setValue("Twin");
await click(AnyoneLiveAtListCollectorAddPage.submit());
await expect(await browser.getUrl()).to.contain(AnyoneLiveAtListCollector.pageName);
await expect(browser).toHaveUrlContaining(AnyoneLiveAtListCollector.pageName);

const peopleExpected = ["Marcus Twin"];
checkItemsInList(peopleExpected, AnyoneLiveAtListCollector.listLabel);
});

it('When the user click the "Previous" link from the list collector, Then, they are taken to the last complete block', async () => {
await $(AnyoneLiveAtListCollector.previous()).click();
await expect(await browser.getUrl()).to.contain(AnyoneUsuallyLiveAt.pageName);
await expect(browser).toHaveUrlContaining(AnyoneUsuallyLiveAt.pageName);
});

it("When the user resubmits the first block and then list is not empty, Then they are taken to the list collector", async () => {
await click(AnyoneUsuallyLiveAt.submit());
await expect(await browser.getUrl()).to.contain(AnyoneLiveAtListCollector.pageName);
await expect(browser).toHaveUrlContaining(AnyoneLiveAtListCollector.pageName);
});

it("When the users removes the only person (Marcus Twain), Then, they are shown an empty list collector", async () => {
await $(AnyoneLiveAtListCollector.listRemoveLink(1)).click();
await $(AnyoneLiveAtListCollectorRemovePage.yes()).click();
await click(AnyoneLiveAtListCollectorRemovePage.submit());
await expect(await browser.getUrl()).to.contain(AnyoneLiveAtListCollector.pageName);
await expect(await $(AnyoneLiveAtListCollector.listLabel(1)).isExisting()).to.be.false;
await expect(browser).toHaveUrlContaining(AnyoneLiveAtListCollector.pageName);
await expect(await $(AnyoneLiveAtListCollector.listLabel(1)).isExisting()).toBe(false);
});

it("When the user resubmits the first block and then list is empty, Then they are taken to the add question", async () => {
await expect(await browser.getUrl()).to.contain(AnyoneLiveAtListCollector.pageName);
await expect(browser).toHaveUrlContaining(AnyoneLiveAtListCollector.pageName);

await $(AnyoneLiveAtListCollector.previous()).click();
await expect(await browser.getUrl()).to.contain(AnyoneUsuallyLiveAt.pageName);
await expect(browser).toHaveUrlContaining(AnyoneUsuallyLiveAt.pageName);

await click(AnyoneUsuallyLiveAt.submit());
await expect(await browser.getUrl()).to.contain(AnyoneLiveAtListCollectorAddPage.pageName);
await expect(browser).toHaveUrlContaining(AnyoneLiveAtListCollectorAddPage.pageName);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,59 +13,59 @@ describe("Answer Action: Redirect To List Add Question (Radio)", () => {
it('When the user answers "No", Then, they should be taken to straight the list collector.', async () => {
await $(AnyoneUsuallyLiveAt.no()).click();
await click(AnyoneUsuallyLiveAt.submit());
await expect(await browser.getUrl()).to.contain(AnyoneLiveAtListCollector.pageName);
await expect(browser).toHaveUrlContaining(AnyoneLiveAtListCollector.pageName);
});

it('When the user answers "Yes" then they should be taken to the list collector add question.', async () => {
await browser.url(AnyoneUsuallyLiveAt.url());
await $(AnyoneUsuallyLiveAt.yes()).click();
await click(AnyoneUsuallyLiveAt.submit());
await expect(await browser.getUrl()).to.contain(AnyoneLiveAtListCollectorAddPage.pageName);
await expect(await browser.getUrl()).to.contain("?previous=anyone-usually-live-at");
await expect(browser).toHaveUrlContaining(AnyoneLiveAtListCollectorAddPage.pageName);
await expect(browser).toHaveUrlContaining("?previous=anyone-usually-live-at");
});

it('When the user clicks the "Previous" link from the add question then they should be taken to the block they came from, not the list collector', async () => {
await $(AnyoneLiveAtListCollectorAddPage.previous()).click();
await expect(await browser.getUrl()).to.contain(AnyoneUsuallyLiveAt.pageName);
await expect(browser).toHaveUrlContaining(AnyoneUsuallyLiveAt.pageName);
});

it("When the user adds a household member, Then, they are taken to the list collector and the household members are displayed", async () => {
await click(AnyoneUsuallyLiveAt.submit());
await $(AnyoneLiveAtListCollectorAddPage.firstName()).setValue("Marcus");
await $(AnyoneLiveAtListCollectorAddPage.lastName()).setValue("Twin");
await click(AnyoneLiveAtListCollectorAddPage.submit());
await expect(await browser.getUrl()).to.contain(AnyoneLiveAtListCollector.pageName);
await expect(browser).toHaveUrlContaining(AnyoneLiveAtListCollector.pageName);

const peopleExpected = ["Marcus Twin"];
checkItemsInList(peopleExpected, AnyoneLiveAtListCollector.listLabel);
});

it('When the user click the "Previous" link from the list collector, Then, they are taken to the last complete block', async () => {
await $(AnyoneLiveAtListCollector.previous()).click();
await expect(await browser.getUrl()).to.contain(AnyoneUsuallyLiveAt.pageName);
await expect(browser).toHaveUrlContaining(AnyoneUsuallyLiveAt.pageName);
});

it("When the user resubmits the first block and then list is not empty, Then they are taken to the list collector", async () => {
await click(AnyoneUsuallyLiveAt.submit());
await expect(await browser.getUrl()).to.contain(AnyoneLiveAtListCollector.pageName);
await expect(browser).toHaveUrlContaining(AnyoneLiveAtListCollector.pageName);
});

it("When the users removes the only person (Marcus Twain), Then, they are shown an empty list collector", async () => {
await $(AnyoneLiveAtListCollector.listRemoveLink(1)).click();
await $(AnyoneLiveAtListCollectorRemovePage.yes()).click();
await click(AnyoneLiveAtListCollectorRemovePage.submit());
await expect(await browser.getUrl()).to.contain(AnyoneLiveAtListCollector.pageName);
await expect(await $(AnyoneLiveAtListCollector.listLabel(1)).isExisting()).to.be.false;
await expect(browser).toHaveUrlContaining(AnyoneLiveAtListCollector.pageName);
await expect(await $(AnyoneLiveAtListCollector.listLabel(1)).isExisting()).toBe(false);
});

it("When the user resubmits the first block and then list is empty, Then they are taken to the add question", async () => {
await expect(await browser.getUrl()).to.contain(AnyoneLiveAtListCollector.pageName);
await expect(browser).toHaveUrlContaining(AnyoneLiveAtListCollector.pageName);

await $(AnyoneLiveAtListCollector.previous()).click();
await expect(await browser.getUrl()).to.contain(AnyoneUsuallyLiveAt.pageName);
await expect(browser).toHaveUrlContaining(AnyoneUsuallyLiveAt.pageName);

await click(AnyoneUsuallyLiveAt.submit());
await expect(await browser.getUrl()).to.contain(AnyoneLiveAtListCollectorAddPage.pageName);
await expect(browser).toHaveUrlContaining(AnyoneLiveAtListCollectorAddPage.pageName);
});
});
});
4 changes: 2 additions & 2 deletions tests/functional/spec/census_thank_you.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ describe("Thank You Census Household", () => {
it("When I navigate to the thank you page, Then I should not see the feedback call to action", async () => {
await click(SubmitPage.submit());
await click(HubPage.submit());
await expect(await browser.getUrl()).to.contain(ThankYouPage.pageName);
await expect(await $(ThankYouPage.feedback()).isExisting()).to.equal(false);
await expect(browser).toHaveUrlContaining(ThankYouPage.pageName);
await expect(await $(ThankYouPage.feedback()).isExisting()).toBe(false);
});
});
});
Loading

0 comments on commit e786e48

Please sign in to comment.