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

Add e2e test for meditor validation #1865

Merged
merged 2 commits into from
Feb 21, 2024
Merged

Conversation

mvandenburgh
Copy link
Member

@mvandenburgh mvandenburgh commented Feb 20, 2024

This adds a new playwright-based E2E test that loads all the current dandisets on dandiarchive.org into the test DB, opens the meditor for each of them, and ensures the validation status is as expected depending on the current state of the metadata.

This will help us be confident that the changes in #1823 don't break anything.

@mvandenburgh mvandenburgh marked this pull request as draft February 20, 2024 20:33
@mvandenburgh mvandenburgh changed the title Add e2e test for meditor validation [wip] Add e2e test for meditor validation Feb 20, 2024
@mvandenburgh mvandenburgh force-pushed the playwright-meditor-tests branch 3 times, most recently from 71035c7 to 8d4aa48 Compare February 20, 2024 20:47
@mvandenburgh mvandenburgh force-pushed the playwright-meditor-tests branch 3 times, most recently from f5923ae to 537af67 Compare February 20, 2024 21:18
@mvandenburgh mvandenburgh changed the title [wip] Add e2e test for meditor validation Add e2e test for meditor validation Feb 20, 2024
@mvandenburgh mvandenburgh marked this pull request as ready for review February 20, 2024 21:47
Copy link
Member

@waxlamp waxlamp left a comment

Choose a reason for hiding this comment

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

Approving this because it works and it's blocking other necessary efforts, but I left some questions and suggestions to follow up on later. Let's track those and get them all resolved soon!

Copy link
Member

Choose a reason for hiding this comment

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

What is this file for?

Comment on lines +3 to +7
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
Copy link
Member

Choose a reason for hiding this comment

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

Should we strike this code block?

Comment on lines +21 to +22
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
Copy link
Member

Choose a reason for hiding this comment

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

I believe we should be using either list, line, dot, or github when process.env.CI is set (probably github, though the docs don't fully explain what output you get when using that reporter).

Comment on lines +25 to +26
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',
Copy link
Member

Choose a reason for hiding this comment

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

We should remove this or set it to http://127.0.0.1:8085 (if that's what's actually needed here).

Comment on lines +41 to +46
/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
Copy link
Member

Choose a reason for hiding this comment

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

Probably get rid of this since we use a custom setup to launch the server and client, etc.

).toBeVisible();
};

const allDandisets = [
Copy link
Member

Choose a reason for hiding this comment

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

I'm assuming all these Dandisets' metadatas are loaded into the database at some point?

await page.getByPlaceholder("Password").click();
await page.getByPlaceholder("Password").fill("password");
await page.getByRole("button", { name: "Sign In " }).click();
await page.waitForLoadState("networkidle");
Copy link
Member

Choose a reason for hiding this comment

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

This is cool! However, the docs state

'networkidle' - DISCOURAGED wait until there are no network connections for at least 500 ms. Don't use this method for testing, rely on web assertions to assess readiness instead.

What's our justification for ignoring their (strongly worded) recommendation?

Comment on lines +480 to +487
await page.getByLabel("Dandiset title").click();
await page.keyboard.press("End");
await page.keyboard.press("Space");
await page.keyboard.press("Tab");
await page.getByLabel("Dandiset title").click();
await page.keyboard.press("End");
await page.keyboard.press("Backspace");
await page.keyboard.press("Tab");
Copy link
Member

Choose a reason for hiding this comment

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

Why does this part repeat?

Comment on lines +480 to +490
await page.getByLabel("Dandiset title").click();
await page.keyboard.press("End");
await page.keyboard.press("Space");
await page.keyboard.press("Tab");
await page.getByLabel("Dandiset title").click();
await page.keyboard.press("End");
await page.keyboard.press("Backspace");
await page.keyboard.press("Tab");
await page.locator(".v-card__actions > button").first().click();
await page.waitForTimeout(3000);
await page.waitForLoadState("networkidle");
Copy link
Member

Choose a reason for hiding this comment

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

This needs a comment to explain what it's doing.

const validIcon = await page.locator(".v-card__actions > i");
const iconClass = await validIcon.getAttribute("class");

if (Object.keys(invalidDandisets).includes(dandisetId)) {
Copy link
Member

Choose a reason for hiding this comment

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

Can this just be Object.hasOwn(invalidDandisets, dandisetId)?

@mvandenburgh mvandenburgh merged commit 0a072dc into master Feb 21, 2024
11 checks passed
@mvandenburgh mvandenburgh deleted the playwright-meditor-tests branch February 21, 2024 16:45
Comment on lines +7 to +8
"axios": "^1.6.7",
"lodash": "^4.17.21"
Copy link
Member Author

Choose a reason for hiding this comment

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

Remove this

@dandibot
Copy link
Member

🚀 PR was released in v0.3.77 🚀

@dandibot dandibot added the released This issue/pull request has been released. label Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants