Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(site): only show method warning if some template is using it#14565

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
BrunoQuaresma merged 8 commits intomainfrombq/notifications-warning
Sep 6, 2024

Conversation

BrunoQuaresma
Copy link
Collaborator

@BrunoQuaresmaBrunoQuaresma commentedSep 4, 2024
edited
Loading

Previously, we were showing the warning regardless of whether a template was using the misconfigured notification method or not. However, we realized this could be too noisy, so we decided to display the warning only when the user has a template configured to use the misconfigured method.

@BrunoQuaresmaBrunoQuaresma requested a review froma teamSeptember 4, 2024 18:44
@BrunoQuaresmaBrunoQuaresma self-assigned thisSep 4, 2024
@BrunoQuaresmaBrunoQuaresma requested review frombcpeinhardt and removed request fora teamSeptember 4, 2024 18:44
@BrunoQuaresmaBrunoQuaresma changed the titlefix(site): only show notification method warning if some template is using itfix(site): only show method warning if some template is using itSep 4, 2024
Copy link
Contributor

@dannykoppingdannykopping left a comment

Choose a reason for hiding this comment

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

Thanks for looking into this!

spyOn(API, "updateNotificationTemplateMethod").mockResolvedValue();
const user = userEvent.setup();
const canvas = within(canvasElement);
const option = await canvas.findByText("Workspace Marked as Dormant");
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should include the template ID as a data attribute and select on that? It'll be more stable than the name.

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

In this case, it doesn't matter too much since we control the data. I prefer to use the name in UI tests to match the user behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

We control it, yes, but we may rename this template, which will cause this test to fail mysteriously.
IDs will likely never be changed, so it's more resilient.

Copy link
CollaboratorAuthor

@BrunoQuaresmaBrunoQuaresmaSep 5, 2024
edited
Loading

Choose a reason for hiding this comment

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

This test won't fail if we rename the template because we're using mocked data. It's not an end-to-end test. I understand that using IDs makes the test more resilient, but this is a UI test in a controlled context, so I think we should test it as the user would. However, if you strongly prefer using IDs, we can switch to that approach and start a discussion with the front-end guild to establish it as a convention, since the community uses a different method. The goal is to test the UI as the user would.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, but when you implement what we discussed inhttps://github.com/coder/coder/pull/14565/files#r1745353934 then itwill go out of sync, and this is an entirely preventable problem.
I'm not part of the front-end guild so it's up to you.

// Extracted from a real API response
export const mockNotificationsDeploymentOptions: SerpentOption[] = [
{
name: "Notifications: Dispatch Timeout",
Copy link
Contributor

Choose a reason for hiding this comment

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

This will go out of sync; is there a way we can lint this?

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

The only check we have here is the type, as we do for the other mocks as well, but I know it is not sufficient. I've been thinking about how we could improve our mocks and keep them in sync. One option that came to mind was to use a script that communicates with the API and generates the mocks. However, this would require more investigation and is beyond the scope of this pull request. What do you think about this idea? Do you see a simpler way we could achieve better results?

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfectly fine to do as a follow-up, yup. Your idea sounds good 👍

BrunoQuaresma reacted with thumbs up emoji
Copy link
Contributor

@dannykoppingdannykopping left a comment

Choose a reason for hiding this comment

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

LGTM, thanks@BrunoQuaresma!
I think waiting for@bcpeinhardt is a good idea though since I'm not qualified to review frontend code.

BrunoQuaresma reacted with thumbs up emoji
@@ -203,6 +203,8 @@ export const baseMeta = {
},
email: {
smarthost: "smtp.example.com",
from: "localhost",
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

BrunoQuaresmaand others added2 commitsSeptember 6, 2024 11:04
…onEvents.stories.tsxCo-authored-by: Danny Kopping <danny@coder.com>
obj: Record<string, string | undefined>,
fields: string[],
): boolean {
return fields.every((field) => Boolean(obj[field]));
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Could use thein operator here maybe?fields.every((field) => field in obj)

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

We also need to check if the field is not an empty string so I thinkBoolean(obj[field]) works best.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yeah fair enough 😎

@BrunoQuaresmaBrunoQuaresma merged commit84d312c intomainSep 6, 2024
27 checks passed
@BrunoQuaresmaBrunoQuaresma deleted the bq/notifications-warning branchSeptember 6, 2024 18:00
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsSep 6, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@bcpeinhardtbcpeinhardtbcpeinhardt approved these changes

@dannykoppingdannykoppingdannykopping approved these changes

Assignees

@BrunoQuaresmaBrunoQuaresma

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@BrunoQuaresma@dannykopping@bcpeinhardt

[8]ページ先頭

©2009-2025 Movatter.jp