Skip to content

Conversation

aweng98
Copy link
Contributor

@aweng98 aweng98 commented Apr 5, 2022

Checking for whether the genomic extraction job has finished was relying on existences of Success icon in Genomic Extraction History table. But, if job has failed, test just waits until test timed out because test code only look for the Success icon.
Screen Shot 2022-04-11 at 3 16 37 PM

PR checklist

  • This PR meets the Acceptance Criteria in the JIRA story
  • The JIRA story has been moved to Dev Review
  • This PR includes appropriate unit tests
  • I have added explanatory comments where the logic is not obvious
  • I have run and tested this change locally, and my testing process is described here
  • If this includes a new feature flag, I have created and linked new JIRA tickets to (a) turn on the feature flag and (b) remove it later
  • If this includes an API change, I have run the E2E tests on this change against my local server with yarn test-local because this PR won't be covered by the CircleCI tests
  • If this includes a UI change, I have taken screen recordings or screenshots of the new behavior and notified the PO and UX designer in Slack
  • If this change impacts deployment safety (e.g. removing/altering APIs which are in use) I have documented these in the description
  • If this includes an API change, I have updated the appropriate Swagger definitions and updated the appropriate API consumers

break;
}
}
async findCellByRowValue(searchColumnHeader, searchCellValue, resultColumnHeader): Promise<Cell | null> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This func did not work for the History table. So I had to fix this. Some changed files in this PR are due to this func change.

});

// Check creation status.
async function waitForComplete(page: Page, maxTime: number): Promise<boolean> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waitForComplete() is just too big. Broke it down into two smaller functions: waitForRuntimeComplete() and waitForExtractionComplete.

private async getStatusSpinnerXpath(datasetName: string): Promise<string> {
const historyTable = this.getHistoryTable();
await historyTable.waitUntilVisible();
const statusCell = await historyTable.findCellByRowValue('DATASET NAME', datasetName, 'STATUS');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the Extraction History table could contain more than 1 row (from running few times in same day), look for the spinner icon in STATUS column in the same row that contains the dataset name, not look for it in the whole table.

@aweng98 aweng98 requested a review from calbach April 6, 2022 18:00
Copy link
Contributor

@calbach calbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, mostly minor style comments

// Find the searchColumnHeader index
const allColumns = await this.getColumns();
const colValues = await Promise.all(allColumns.map((column) => getPropValue<string>(column, 'innerText')));
console.log({ colValues });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like leftover debug statements, would remove

break;
}
}
async findCellByRowValue(searchColumnHeader, searchCellValue, resultColumnHeader): Promise<Cell | null> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add types to the parameters, it makes it easier to follow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added types to parameters. Added comments to explain the function. Removed console.log.

break;
}
}
async findCellByRowValue(searchColumnHeader, searchCellValue, resultColumnHeader): Promise<Cell | null> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add method documentation of what this is supposed to do - the semantics are not obvious from the method name.

}
// Find the row index which contains searchCellValue
const allRows = await this.getRows();
const tds = await Promise.all(allRows.map((row) => row.$x('./td')));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of extraneous state variables introduced compared to the previous approach which is making this more challenging to read, in my opinion. I'm thinking it may be more readable to group these together, e.g.:

const searchColumnTdValues = await Promise.all(allRows.map(async (row) => {
  const td = await row.$x('./td');
  return getPropValue<string>(td[columnIndex], 'innerText');
}))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like new code. Going to try it if it works.

return true;
.waitForXPath(statusSpinnerXpath, {
visible: true,
timeout: timeout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: just timeout

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


/**
* Open Runtime sidebar, check status for running.
* Open Runtime sidebar, wait for running or error status.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logically, why would waitForRunning return when it's in the error state? Consider renaming the method or else updating the semantics some other way

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments. Renamed func to waitForFinish.

/**
   * Open the Runtime sidebar, wait for the Running or Error status.
   * The Running or Error status in runtime creation is considered as done/complete.
   */
  async waitForFinish(timeout?: number): Promise<boolean> 

const cell = await accountAccessTable.findCellByRowValue(
TableColumns.ACCESS_MODULE,
accessModule,
TableColumns.REQUIRED_FOR_TIER
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting - how did this work previously, without specifying a search column?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it worked in this table because the TableColumns.ACCESS_MODULE is the first column and it was the only column where the search area was.

await signInWithAccessToken(page);
});

const waitForCompletionMaxTime = 60 * 60 * 1000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This limit should be shorter than the overall timeout. By the time we reach this point in the code, we don't have 60 minutes left

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, forgot to update this timeout after shorten jest timeout.

// Total Count should be greater than 1.
// Total Count should be greater than or equal to 1 and less than or equal to 5.
// At the time of writing test, Total Count is 2. Total Count can change if synthetic dataset changes.
// We want keep Total Count is larger, it will take longer time to for the extraction job to complete.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice


// Check creation status.
async function waitForComplete(page: Page, maxTime: number): Promise<boolean> {
async function waitForRuntimeComplete(page: Page, maxTime: number): Promise<boolean> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have so much custom code in this test case for waiting on a runtime to start? Isn't this a very central function which should be supported by a library or utility? Is this not duplicated somewhere else in the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function can be a common function but no other tests can use it as it is now. I would need more time to refactor this function so it can be used in other places. This function doesn't initiate the Create Runtime process. The only other runtime test is nightly/runtime.spec.ts. It's much simpler and doesn't have same test steps. But it could use this function if it is more generalized.

@aweng98 aweng98 force-pushed the aw/e2e-genomic-extraction-to-vcf-test branch from 20df4bf to 4856ec1 Compare April 8, 2022 21:05
import DataTable from 'app/component/data-table';
import { waitWhileLoading } from 'utils/waits-utils';
import { exists } from 'utils/element-utils';
import Cell from '../component/cell';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please avoid path relative imports like this (except same dir)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I missed this.

@aweng98 aweng98 merged commit 5c1cc6f into main Apr 11, 2022
@aweng98 aweng98 deleted the aw/e2e-genomic-extraction-to-vcf-test branch April 11, 2022 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants