Skip to content
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

Merged
merged 4 commits into from
Jan 10, 2024
Merged

SWC-6621 #5250

merged 4 commits into from
Jan 10, 2024

Conversation

hallieswan
Copy link
Contributor

  • 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',
Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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!

Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor Author

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) => {
Copy link
Contributor Author

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

Comment on lines -116 to +110
let fileHandleIds: string[] = []
const fileHandleIds: string[] = []
Copy link
Contributor Author

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

Comment on lines -347 to -349
testAuth(
'should create and delete a file',
async ({ userPage, browserName }) => {
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 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

Copy link
Contributor

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

Comment on lines +117 to 118
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async ({ browser, browserName, createUsers }, use) => {
Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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!

Copy link
Contributor Author

@hallieswan hallieswan Jan 6, 2024

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

Comment on lines +15 to +19
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
return (await SRC.SynapseClient.getEntityACL(
entityId,
accessToken,
)) as AccessControlList
Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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()
Copy link
Contributor Author

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

Comment on lines -242 to -243
const expectedText =
await test.step('format expected text', async () => {
Copy link
Contributor Author

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'
Copy link
Contributor Author

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 @@
{
Copy link
Contributor Author

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.

@hallieswan hallieswan marked this pull request as ready for review January 6, 2024 00:58
@hallieswan hallieswan requested a review from nickgros January 6, 2024 00:58
Copy link
Contributor

@nickgros nickgros left a 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',
Copy link
Contributor

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

Comment on lines -347 to -349
testAuth(
'should create and delete a file',
async ({ userPage, browserName }) => {
Copy link
Contributor

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

Comment on lines +117 to 118
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async ({ browser, browserName, createUsers }, use) => {
Copy link
Contributor

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?

Comment on lines +15 to +19
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
return (await SRC.SynapseClient.getEntityACL(
entityId,
accessToken,
)) as AccessControlList
Copy link
Contributor

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?

@hallieswan hallieswan force-pushed the SWC-6621 branch 12 times, most recently from f048ca8 to a1031d9 Compare January 9, 2024 22:49
@hallieswan hallieswan merged commit 7670df9 into Sage-Bionetworks:develop Jan 10, 2024
2 checks passed
@hallieswan hallieswan deleted the SWC-6621 branch January 10, 2024 20:45
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