-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: first draft of anvil-cmg filter tests (#4068) #4071
Conversation
78bf69e
to
ac63c9d
Compare
} from "../testFunctions"; | ||
import { anvilFilters, anvilTabs, anvilTabTestOrder } from "./anvil-tabs"; | ||
|
||
test.describe.configure({ mode: "parallel", timeout: 60 * 1000 }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you be able to tell me why you needed to add this here rather than in a global config file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a mistake - that shouldn't have been necessary, I think I just copied the header of this file form another test where I had also forgotten to remove it. I'll remove this header from all the tests in #4078 , thanks for catching it here!
); | ||
}); | ||
|
||
test.setTimeout(120000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you give me the background on why we need the test.setTimeout
calls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! When I ran these tests locally, I found that they would sometimes take too long and timeout. Adding the setTimeout calls here means the timeout for these particular tests is extended from 60 seconds to 120 seconds, which resolved the issue. I can also reduce the number of tests they run on if that is preferable. If this timeout value was changed in the global config, the timeout for all tests would be longer than necessary, causing tests to take longer if they fail.
const filter_index_list = [3, 4, 5, 10, 6, 2]; | ||
const filter_index_list_short = [1, 10, 3]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you be able to update these two to be MACRO_CASE to help indicate they are constants? Also, can you create constants for the integer values so it's more obvious what they are? For example:
const FILTER_ASSAY_INDEX = 3;
const FILTER_GENDER_INDEX = 4;
const FILTER_INDEX_LIST = [FILTER_ASSAY_INDEX, FILTER_GENDER_INDEX];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do! Do you think it makes sense to store those constants in this file or in anvilTabs.ts
?
.click(); | ||
// Expect all checkboxes to be unchecked initially and to work properly | ||
await expect(page.getByRole("checkbox").first()).toBeVisible(); | ||
const all_checkboxes = await page.getByRole("checkbox").all(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you update this variable to be camel-case (and also any other snake-case local variables throughout)?
}) => { | ||
await testFilterPersistence( | ||
page, | ||
anvilFilters[3], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you create a constant for 3
so help indicate its value?
testFilterPersistence, | ||
testFilterPresence, | ||
} from "../testFunctions"; | ||
import { anvilFilters, anvilTabs, anvilTabTestOrder } from "./anvil-tabs"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is outside the scope of this PR but would you be able to update anvilFilters
, anvilTabs
, and anvilTabTestOrder
to be MACRO_CASE to help indicate they are constants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sure! I'll do it in the cleanup ticket
page, | ||
anvilTabs.datasets, | ||
filter_index_list.map((x) => anvilFilters[x]), | ||
25 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's create a constant for this default page size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on how I've done other tests, it'd might make sense to have it as an attribute of each tab object (so each tab would have an associated maxPages), since I've tried to store constants that relate to the site there. I can make it a constant in this file though if you think that'd make more sense though, I've just tried to keep the constants there those that relate to the configuration of the actual test.
explorer/e2e/testFunctions.ts
Outdated
|
||
export const getFirstElementTextLocator = ( | ||
page: Page, | ||
workColumnPosition: number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename this to columnIndex
? I'm not familiar with "work column" so feel free to keep it as is if this is a known concept.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, just a random variable name I thought of at the time but that only made sense in my head, I'll make sure to review those in more detail for future PRs!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you go ahead and rename workColumnPosition
to columnIndex
, here and throughout?
explorer/e2e/testFunctions.ts
Outdated
export async function testFilterPresence( | ||
page: Page, | ||
tab: TabDescription, | ||
filters: string[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this an array of filter names? If so, what about renaming this to filterNames
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update this to filterNames
, here and throughout? Can you also update the corresponding for (const filter of filters)
to for (const filterName of filterNames)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks Jonah! I've asked for a couple of changes. Once you've pushed your updates, I'll do another review round on testFunctions
.
page, | ||
}) => { | ||
test.setTimeout(120000); | ||
await testFilterBubbles( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we call the bubbles "tags"; can you rename bubbles to "tags" here and throughout?
explorer/e2e/testFunctions.ts
Outdated
|
||
export const getFirstElementTextLocator = ( | ||
page: Page, | ||
workColumnPosition: number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you go ahead and rename workColumnPosition
to columnIndex
, here and throughout?
explorer/e2e/testFunctions.ts
Outdated
import { TabDescription } from "./testInterfaces"; | ||
|
||
/* eslint-disable sonarjs/no-duplicate-string -- ignoring duplicate strings here */ | ||
// Run the "Expect each tab to appear as selected when the corresponding url is accessed" test | ||
|
||
export const getFirstElementTextLocator = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this function is grabbing the first row in the table and then grabbing the text from the nth column; if so, can you rename this to getFirstRowNthColumnCellTextLocator
or similar? It's a long name but I feel its gives a clearer idea of the function's intention.
explorer/e2e/testFunctions.ts
Outdated
@@ -207,4 +215,208 @@ export async function testPreSelectedColumns( | |||
} | |||
} | |||
|
|||
export const filterRegex = (filter: string): RegExp => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment describing the regex?
explorer/e2e/testFunctions.ts
Outdated
export async function testFilterPresence( | ||
page: Page, | ||
tab: TabDescription, | ||
filters: string[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update this to filterNames
, here and throughout? Can you also update the corresponding for (const filter of filters)
to for (const filterName of filterNames)
?
explorer/e2e/testFunctions.ts
Outdated
/\.\S*/ | ||
); | ||
if (filterNameMatch == null) { | ||
test.fail(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to return a boolean here and call test.fail
in the calling code? This matches the pattern in testFilterCount.
explorer/e2e/testFunctions.ts
Outdated
@@ -1,8 +1,22 @@ | |||
import { expect, Page } from "@playwright/test"; | |||
import { expect, Locator, Page, test } from "@playwright/test"; | |||
import { TabDescription } from "./testInterfaces"; | |||
|
|||
/* eslint-disable sonarjs/no-duplicate-string -- ignoring duplicate strings here */ | |||
// Run the "Expect each tab to appear as selected when the corresponding url is accessed" test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this comment go with the function below? If so, can you remove the whitespace below?
explorer/e2e/testFunctions.ts
Outdated
import { TabDescription } from "./testInterfaces"; | ||
|
||
/* eslint-disable sonarjs/no-duplicate-string -- ignoring duplicate strings here */ | ||
// Run the "Expect each tab to appear as selected when the corresponding url is accessed" test | ||
|
||
export const getFirstElementTextLocator = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
85752ed
to
cca06e0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks Jonah!
…nce test on webkit (#4068)
6d4b8b4
to
ffa69f5
Compare
Ticket
Closes #4068 .
Reviewers
@NoopDog .
Changes
Added the following tests for AnVIL-CMG
explorer/e2e/anvilTabs.js
display on each tab, are clickable, and cause a checkbox to be displayed