Skip to content

test: add an e2e audit logs test #12868

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

Merged
merged 5 commits into from
Apr 12, 2024
Merged

test: add an e2e audit logs test #12868

merged 5 commits into from
Apr 12, 2024

Conversation

aslilac
Copy link
Member

@aslilac aslilac commented Apr 4, 2024

Closes #12507

  • Make sure we've done some stuff worth auditing
  • Poke around the logs, filter, inspect details, all the good stuff

@aslilac aslilac requested review from BrunoQuaresma, Emyrk and Parkreiner and removed request for BrunoQuaresma, sreya and Kira-Pilot April 5, 2024 18:19
Copy link
Member

@Parkreiner Parkreiner left a comment

Choose a reason for hiding this comment

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

As long as @Emyrk thinks the other file changes look good, there's nothing worth blocking here. Had a few questions/recommendations about fine-tuning the selectors, though

Comment on lines +35 to +37
const createdWorkspace = page.locator(".MuiTableRow-root", {
hasText: `${userName} created workspace ${workspaceName}`,
});
Copy link
Member

Choose a reason for hiding this comment

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

I don't fully understand this code, but I'm a little worried. If I'm understanding it right, the code is basically grabbing an element via the CSS class it gets from MUI, and then asserting it has the specific content?

I don't know how stable MUI class names are, but is there any way we can update this to be a role-based selector? Assuming MUI doesn't mess up their table semantics, this element should have a row role as well

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll double check, but I didn't notice a role, and I generally prefer those.

but also MUI's classes names are a documented part of their public API, so it should be safe to depend on.

const loginMessage = `${userName} logged in`;

// Filter by resource type
await page.getByText("All resource types").click();
Copy link
Member

Choose a reason for hiding this comment

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

Not fully sure what element this is, but could the selector be updated to have a link/button role, since whatever it is, it looks like something that can be interacted with?

Copy link
Member Author

Choose a reason for hiding this comment

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

there are multiple buttons on the page though. those roles would be ambiguous.

const createdWorkspace = page.locator(".MuiTableRow-root", {
hasText: `${userName} created workspace ${workspaceName}`,
});
await createdWorkspace.getByLabel("open-dropdown").click();
Copy link
Member

Choose a reason for hiding this comment

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

Is this a label that we're visibly showing in the UI? The hyphen makes it look like an implementation detail

Copy link
Member Author

Choose a reason for hiding this comment

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

It's an aria-label. Which probably still shouldn't have a hyphen, but it is what it is. 😅


// Filter by resource type
await page.getByText("All resource types").click();
await page.getByRole("menu").getByText("Workspace Build").click();
Copy link
Member

Choose a reason for hiding this comment

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

Could this be turned into

await page.getByRole("menu", { name: "Workspace Build" }).click();

?

Copy link
Member Author

Choose a reason for hiding this comment

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

no, this is descending into the menu, and getting by text inside of it to click a specific option. that would just get the whole menu.

await expect(page.getByText(loginMessage)).toBeVisible();

// Filter by action type
await page.getByText("All actions").click();
Copy link
Member

@Parkreiner Parkreiner Apr 11, 2024

Choose a reason for hiding this comment

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

Same comment as above, since this is some kind of interactive element

Copy link
Member Author

Choose a reason for hiding this comment

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

we could add testids to them, but tbh I kinda hate those 😅 if you'd prefer that tho, we use them all over the place and I cope

@aslilac aslilac merged commit 00fcf36 into main Apr 12, 2024
@aslilac aslilac deleted the e2e-audit branch April 12, 2024 20:01
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

e2e: Auditing
2 participants