-
Notifications
You must be signed in to change notification settings - Fork 40
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
SWC-6621 #5250
SWC-6621 #5250
Conversation
hallieswan
commented
Jan 6, 2024
- lint e2e tests
- fix errors raised by linter
- use types from @sage-bionetworks/synapse-types
'@typescript-eslint/no-inferrable-types': 'off', | ||
'@typescript-eslint/ban-ts-comment': 'warn', | ||
'@typescript-eslint/no-empty-interface': 'warn', | ||
'@typescript-eslint/no-floating-promises': 'error', |
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.
For the most part, these rules are a direct subset of rules in synapse-web-monorepo. However, @typescript-eslint/no-floating-promises
is set to error to catch issues in Playwright tests, as recommended in their best practices guide.
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.
Do you think we should create a ticket to enable this rule in synapse-web-monorepo? I think it makes sense since we're writing tests in essentially the same way
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.
Agreed that we're writing tests in the same way! I initially enabled the rule for the entire monorepo, but since this caused many errors and I wasn't sure whether the rule should apply to non-e2e-test code, I ended up setting the rule as an override only for the Portals e2e tests directory. Happy to create a ticket if we'd like to enable the rule for the entire monorepo though!
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 think it would be good to create the ticket since we can use the void
keyword to be explicit about the places where we don't want to handle the promise. Do you mind creating it?
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.
@@ -85,6 +99,12 @@ jobs: | |||
run: yarn install --frozen-lockfile | |||
- name: Install Playwright Browsers | |||
run: yarn playwright install --with-deps | |||
- name: Confirm Docker container is running |
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.
Trying to troubleshoot the TypeError: The argument 'file' cannot be empty. Received ''
error, as seen in this run. I can reproduce the error when the SWC war does not exist or when the docker container is not running (likely because in CI, we pass a stub to the PW webServer command).
page: Page, | ||
threadTitle: string, | ||
) => { | ||
const getDiscussionParentActionButtons = (page: Page, threadTitle: 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.
Async arrow function 'getDiscussionParentActionButtons' has no 'await' expression
let fileHandleIds: string[] = [] | ||
const fileHandleIds: 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.
fileHandleIds
is never reassigned - prefer-const
testAuth( | ||
'should create and delete a file', | ||
async ({ userPage, browserName }) => { |
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 removed browserName
, since it wasn't used. This resulted in many whitespace changes, so the diff isn't very helpful -- no other changes were made in this 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.
Thanks, this was a catastrophic diff
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
async ({ browser, browserName, createUsers }, use) => { |
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.
createUsers
is not used, but must be included so that the createUser worker fixture creates each test user before this worker fixture runs. Ignore this type error.
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's not intuitive to me why createUsers
needs to be destructured in the signature to accomplish different behavior. Could you explain or point me to some documentation? And also leave a comment alongside the comment used to disable the rule?
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.
Sure! The destructured fixtures are the dependencies of the current fixture, as described in the Execution Order docs. Since the test users must be created before the test user can be authenticated, the storageStatePaths
worker fixture depends on the createUsers
worker fixture. This tells Playwright to set up createUsers
before executing storageStatePaths
. I'll add a comment to clarify in the code!
e2e/helpers/ACCESS_TYPE.ts
Outdated
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.
Import ACCESS_TYPE
from @sage-bionetworks/synapse-types instead
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call | ||
return (await SRC.SynapseClient.getEntityACL( | ||
entityId, | ||
accessToken, | ||
)) as AccessControlList |
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.
Defining an object in SWC that represents SRC would be difficult, so ignore these errors for now since we plan to clean this up once SRC can be called directly from the e2e tests.
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 still primarily blocked by ESM/CJS mismatch issues, correct?
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.
Yes, importing SRC directly is blocked by ESM/CJS issues. However, we'd also considered moving SynapseClient into its own package that could run in browser or node.js environments, so that we wouldn't have to resolve the ESM/CJS issues for all of SRC. I think this work was blocked by the OpenAPI work.
|
||
// skip initial empty column | ||
await expectTableColumnHeaders(tableRows, columnsSchemaConfig, 1) | ||
|
||
await test.step('enter test data', async () => { | ||
const addRowButton = page.getByRole('button', { name: 'Add Row' }) | ||
for (let index = 0; index < tableData.length; index++) { | ||
await test.step(`enter test data: ${tableData[index].item}`, async () => { | ||
const item = tableData[index].item.toString() |
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.
item
can be a string, string[], or number, so convert to a string before using in the template expression
const expectedText = | ||
await test.step('format expected text', async () => { |
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.
Removed the unnecessary async
, which resulted in whitespace changes. No other changes in this chunk
@@ -1,12 +1,4 @@ | |||
import ACCESS_TYPE from './ACCESS_TYPE' |
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.
Types are imported from @sage-bionetworks/synapse-types, rather than duplicated here
@@ -0,0 +1,31 @@ | |||
{ |
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.
Other than the files/paths in "files" and "include", this is almost an exact copy of tsconfig.base.json
in synapse-react-client. I'm not very familiar with TypeScript compiler options, so if there are more appropriate options, happy to adjust this as needed.
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 a great improvement, just had one question/request to add a comment in code.
'@typescript-eslint/no-inferrable-types': 'off', | ||
'@typescript-eslint/ban-ts-comment': 'warn', | ||
'@typescript-eslint/no-empty-interface': 'warn', | ||
'@typescript-eslint/no-floating-promises': 'error', |
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.
Do you think we should create a ticket to enable this rule in synapse-web-monorepo? I think it makes sense since we're writing tests in essentially the same way
testAuth( | ||
'should create and delete a file', | ||
async ({ userPage, browserName }) => { |
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.
Thanks, this was a catastrophic diff
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
async ({ browser, browserName, createUsers }, use) => { |
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's not intuitive to me why createUsers
needs to be destructured in the signature to accomplish different behavior. Could you explain or point me to some documentation? And also leave a comment alongside the comment used to disable the rule?
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call | ||
return (await SRC.SynapseClient.getEntityACL( | ||
entityId, | ||
accessToken, | ||
)) as AccessControlList |
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 still primarily blocked by ESM/CJS mismatch issues, correct?
f048ca8
to
a1031d9
Compare