Skip to content

Commit

Permalink
Merge branch '10353-bug-duplicate-cognito-users' of github.com:flexio…
Browse files Browse the repository at this point in the history
…n/ef-cms into 10353-bug-duplicate-cognito-users
  • Loading branch information
Mwindo committed Aug 22, 2024
2 parents 9467522 + d893d4e commit ea69c07
Show file tree
Hide file tree
Showing 381 changed files with 12,931 additions and 4,451 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2.1
orbs:
git-shallow-clone: guitarrapc/[email protected]

efcms-docker-image: &efcms-docker-image $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/ef-cms-us-east-1:4.3.6
efcms-docker-image: &efcms-docker-image $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/ef-cms-us-east-1:4.3.7

parameters:
run_build_and_deploy:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Typescript Untouched File Check
name: Typescript File Check

on:
pull_request:

jobs:
CheckUntouchedFiles:
CheckAllFilesForTypeErrorCount:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -39,5 +39,5 @@ jobs:
working-directory: ./targetBranch
run: npm ci

- name: Check untouched files
run: npx ts-node scripts/checkUntouchedFiles.ts
- name: Check files for increased error count
run: npx ts-node scripts/checkAllFilesForTypeErrorCount.ts
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ RUN apt-get install -y build-essential
RUN apt-get install -y libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev

ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.17.24.zip" -o "awscliv2.zip" && \
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.17.30.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && \
./aws/install && \
rm -rf awscliv2.zip
Expand Down
65 changes: 65 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ import {
getNewAccountVerificationCode,
toggleFeatureFlag,
} from './cypress/helpers/cypressTasks/dynamo/dynamo-helpers';
import { overrideIdleTimeouts } from './cypress/local-only/support/idleLogoutHelpers';
import { unzipFile } from './cypress/helpers/file/unzip-file';
import { waitForNoce } from './cypress/helpers/cypressTasks/wait-for-noce';
import { waitForPractitionerEmailUpdate } from './cypress/helpers/cypressTasks/wait-for-practitioner-email-update';

import type { Page } from 'puppeteer-core';

import { retry, setup } from '@cypress/puppeteer';

// eslint-disable-next-line import/no-default-export
export default defineConfig({
chromeWebSecurity: false,
Expand Down Expand Up @@ -77,6 +82,66 @@ export default defineConfig({
});
},
});
// Setup for puppeteer, which supports multi-tab tests
// Define your function in onMessage, and call it like cy.puppeteer('yourFunctionName', arg1, arg2 ...)
setup({
on,
onMessage: {
async closeTab(browser: any, url: string) {
const desiredPage = await retry<Promise<Page>>(async () => {
const pages = await browser.pages();
const page = pages.find(p => p.url().includes(url));
if (!page) throw new Error('Could not find page');
return page;
});
await desiredPage.close();
},
async openExistingTabAndCheckSelectorExists(
browser: any,
url: string,
selector: string,
close: boolean = true,
) {
// Note that browser.pages is *not* sorted in any particular order.
// Therefore we pass in the URL we want to find rather than an index.

// Wait until the new tab loads
const desiredPage = await retry<Promise<Page>>(async () => {
const pages = await browser.pages();
const page = pages.find(p => p.url().includes(url));
if (!page) throw new Error('Could not find page');
return page;
});

// Activate it
await desiredPage.bringToFront();

// Make sure selector exists
await desiredPage.waitForSelector(selector, { timeout: 30000 });

if (close) {
await desiredPage.close();
}
return true;
},
async openNewTab(
browser: any,
url: string,
sessionModalTimeout: number,
sessionTimeout: number,
) {
const page = await browser.newPage();
await page.goto(url, { waitUntil: 'networkidle2' });

await page.evaluate(overrideIdleTimeouts, {
sessionModalTimeout,
sessionTimeout,
});

return page;
},
},
});
},
specPattern: 'cypress/local-only/tests/**/*.cy.ts',
supportFile: 'cypress/local-only/support/index.ts',
Expand Down
4 changes: 2 additions & 2 deletions cypress/CYPRESS-README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Best Practices

In order to write a realiable cypress test suites, there are some best practices we should follow that our outlined in the cypress documentation and also some best practices we have learned from trying to write realiable tests.
In order to write a reliable cypress test suites, there are some best practices we should follow that our outlined in the cypress documentation and also some best practices we have learned from trying to write reliable tests.

## DO'S
- Access DOM elements using `data-testid selector`.
Expand All @@ -11,7 +11,7 @@ In order to write a realiable cypress test suites, there are some best practices
- Avoid cy.get('#my-id').
- Wait for actions to finish explicitly.
- Always verify something on the page after running an action or loading a new page. For example, if you click on a button which updates a practitioner name, be sure to wait for a success alert to appear before trying to move onto the next steps in your test. Failing to do this will result in race conditions and flaky tests.
- This is especially important for accessibilty tests, wait explicitly for the page to full load before running an accessibility scan. If you are seeing 'color-contrast' violations that are intermittent you are most likely not waiting for the right element to be loaded before running a scan.
- This is especially important for accessibility tests, wait explicitly for the page to full load before running an accessibility scan. If you are seeing 'color-contrast' violations that are intermittent you are most likely not waiting for the right element to be loaded before running a scan.
- Extract reusable steps.
- Try to find ways to create helper functions which we can re-use in other tests. For example, creating a case as a petitioner is a good re-usable flow. When writing these helpers, be sure they do not contain asserts related to the high level test you are writing. They should just login as a user, create or modify the data, then return any new created values we may need.
- Test should be re-runnable.
Expand Down
8 changes: 8 additions & 0 deletions cypress/helpers/ITestableWindow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// An interface for exposing the cerebral controller on the window object, which
// can be useful for temporarily overwriting constants in cypress.
export interface ITestableWindow {
cerebral: {
getState: () => any;
getModel: () => any;
};
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export function externalUserSearchesDocketNumber(docketNumber: string) {
cy.get('[data-testid="docket-search-field"]').should('exist');
cy.get('[data-testid="docket-search-field"]').type(docketNumber);
cy.get('[data-testid="search-by-docket-number"]').click();
}
2 changes: 1 addition & 1 deletion cypress/helpers/authentication/login-as-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function loginAsIrsPractitioner1() {
}

export function loginAsPetitioner(
petitionerUser: 'petitioner' | 'petitioner1' = 'petitioner1',
petitionerUser: 'petitioner' | 'petitioner1' | 'petitioner7' = 'petitioner1',
) {
cy.login(petitionerUser);
cy.get('[data-testid="file-a-petition"]').should('exist');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function petitionerCreatesElectronicCaseUpdated(
cy.get('[data-testid="contactPrimary.city"]').type('Orlando');
cy.get('[data-testid="contactPrimary.state"]').select('AL');
cy.get('[data-testid="contactPrimary.postalCode"]').type('12345');
cy.get('[data-testid="contactPrimary.placeOfLegalResidence"]').select('AL');
cy.get('[data-testid="contactPrimary-placeOfLegalResidence"]').select('AL');
cy.get('[data-testid="contact-primary-phone"]').type('1111111111');
cy.get('[data-testid="step-1-next-button"]').click();

Expand Down Expand Up @@ -105,7 +105,7 @@ export function petitionerAttemptsToUploadCorruptPdfUpdated() {
cy.get('[data-testid="contactPrimary.city"]').type('Orlando');
cy.get('[data-testid="contactPrimary.state"]').select('AL');
cy.get('[data-testid="contactPrimary.postalCode"]').type('12345');
cy.get('[data-testid="contactPrimary.placeOfLegalResidence"]').select('AL');
cy.get('[data-testid="contactPrimary-placeOfLegalResidence"]').select('AL');
cy.get('[data-testid="contact-primary-phone"]').type('1111111111');
cy.get('[data-testid="step-1-next-button"]').click();

Expand Down
19 changes: 19 additions & 0 deletions cypress/local-only/support/idleLogoutHelpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ITestableWindow } from '../../helpers/ITestableWindow';

// This is a hack, but I do not know a better way.
export const overrideIdleTimeouts = ({
modalTimeout,
sessionTimeout,
windowObj, // For native cypress, this needs to be defined. For the puppeteer plugin, it should be left blank.
}: {
modalTimeout: number;
sessionTimeout: number;
windowObj?: ITestableWindow;
}) => {
const currentWindow = windowObj || (window as unknown as ITestableWindow);
currentWindow.cerebral.getModel().set(['constants'], {
...currentWindow.cerebral.getState().constants,
SESSION_MODAL_TIMEOUT: modalTimeout,
SESSION_TIMEOUT: sessionTimeout,
});
};
1 change: 1 addition & 0 deletions cypress/local-only/support/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import './commands';
import '@cypress/puppeteer/support';
import 'cypress-axe';

before(() => {
Expand Down
46 changes: 46 additions & 0 deletions cypress/local-only/support/statusReportOrder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {
FORMATS,
formatNow,
} from '../../../shared/src/business/utilities/DateHandler';

export const docketNumber = '107-19';
export const leadCaseDocketNumber = '102-67';
export const statusReportDocketEntryId = '178af2d2-fab1-445a-a729-d3da63517a0a';
export const messages = {
statusReport: {
messageId: '73d4365b-8b3a-4b01-9ca3-7087f7a6d4b5',
name: 'Status Report',
},
testStatusReportOrderSigned: {
messageId: '32484c7f-4606-49fc-89f1-27ba1d5596be',
name: 'Test Status Report Order (Signed)',
},
testStatusReportOrderUnsigned: {
messageId: '34483b5b-29de-4ad4-8caa-59f71ad6d906',
name: 'Test Status Report Order (Unsigned)',
},
};
export const expectedPdfLines = [
'On June 28, 2024, a status report was filed (Index no. 5). For cause, it is',
`ORDERED that the parties shall file a further status report by ${formatNow(FORMATS.MONTH_DAY_YEAR)}. It is further`,
'ORDERED that this case is stricken from the trial session. It is further',
'ORDERED that jurisdiction is retained by the undersigned. It is further',
'ORDERED that Here is my additional order text.',
];
export const selectAllOptionsInForm = () => {
cy.get('#order-type-status-report').check({ force: true });
cy.get('#status-report-due-date-picker').type(formatNow(FORMATS.MMDDYYYY));
cy.get('#stricken-from-trial-sessions').check({ force: true });
cy.get('#jurisdiction-retained').check({ force: true });
cy.get('#additional-order-text').type('Here is my additional order text.');
};

export const getLastDraftOrderElementFromDrafts = () => {
return cy.get('button:contains(Order)').last();
};

export const getLastDraftOrderElementIndexFromDrafts = () => {
return getLastDraftOrderElementFromDrafts().then(lastOrderButton => {
return lastOrderButton.index();
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { checkA11y } from '../../../support/generalCommands/checkA11y';
import { loginAsPetitioner } from '../../../../helpers/authentication/login-as-helpers';

describe('Petition generation - intro pages', () => {
it('welcome to dawson: should be free of a11y issues', () => {
loginAsPetitioner('petitioner7');
checkA11y();
});

it('before filing a case: should be free of a11y issues', () => {
loginAsPetitioner();
cy.visit('/before-filing-a-petition');
checkA11y();
});
});
Loading

0 comments on commit ea69c07

Please sign in to comment.