From 7dd1773d2d5c3a60cd06f80c18bd9fb0c8d8769a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Lem=C3=A9nager?= Date: Wed, 17 Jul 2024 11:18:58 +0200 Subject: [PATCH] Fix flaky test for multi profiles and alerts for props (#3847) * add test id for close button * close alert before moving on * fix all alerts to use taost props * update test to wait after each profile creation * remove alert in console * wait for interface to be ready * correctly wait before query creation * fix check after comment creation * update verifiactions tests + increase timeout for proposed changes * increase timeout for proposed change * update objects in test to avoid concurrent testing on the same objects * update locators for hover --- frontend/app/src/Root.tsx | 8 ++--- frontend/app/src/components/account-menu.tsx | 2 +- .../app/src/components/buttons/clipboard.tsx | 2 +- .../src/components/conversations/thread.tsx | 2 +- .../app/src/components/editor/code-editor.tsx | 2 +- frontend/app/src/components/file.tsx | 2 +- .../app/src/components/form/object-form.tsx | 2 +- frontend/app/src/components/list.tsx | 2 +- frontend/app/src/components/ui/alert.tsx | 7 ++-- .../app/src/decorators/withSchemaContext.tsx | 4 +-- .../app/src/graphql/graphqlClientApollo.tsx | 2 +- frontend/app/src/hooks/useAuth.tsx | 2 +- .../app/src/screens/artifacts/generate.tsx | 4 +-- .../src/screens/branches/branch-details.tsx | 2 +- .../artifact-diff/artifact-content-diff.tsx | 8 ++--- .../diff/artifact-diff/artifacts-diff.tsx | 2 +- .../screens/diff/checks/checks-summary.tsx | 2 +- .../app/src/screens/diff/checks/conflict.tsx | 2 +- frontend/app/src/screens/diff/data-diff.tsx | 2 +- .../app/src/screens/diff/diff-comments.tsx | 2 +- .../diff/file-diff/file-content-diff.tsx | 8 ++--- frontend/app/src/screens/diff/schema-diff.tsx | 2 +- .../app/src/screens/groups/add-group-form.tsx | 4 +-- .../ip-addresses/ipam-ip-address-list.tsx | 4 +-- .../ipam/prefixes/ipam-prefix-details.tsx | 4 +-- .../prefixes/ipam-prefixes-summary-list.tsx | 4 +-- .../screens/layout/sidebar/desktop-menu.tsx | 2 +- .../relationship-details-paginated.tsx | 8 ++--- .../relationships-details-paginated.tsx | 2 +- .../object-item-edit-paginated.tsx | 2 +- .../object-item-meta-edit.tsx | 2 +- .../object-items/object-items-paginated.tsx | 4 +-- .../proposed-changes/conversations.tsx | 16 ++++----- .../proposed-changes-create-form.tsx | 2 +- .../proposed-changes-item.tsx | 2 +- .../screens/user-profile/tab-preferences.tsx | 2 +- .../core-graphql-query.spec.ts | 1 + .../tests/e2e/objects/object-groups.spec.ts | 1 + .../e2e/objects/object-relationships.spec.ts | 31 ++++++++-------- .../objects/profiles/multi-profiles.spec.ts | 4 +++ .../proposed-changes_data.spec.ts | 35 ++++--------------- 41 files changed, 94 insertions(+), 107 deletions(-) diff --git a/frontend/app/src/Root.tsx b/frontend/app/src/Root.tsx index 5d2ab939d6..381f9091c2 100644 --- a/frontend/app/src/Root.tsx +++ b/frontend/app/src/Root.tsx @@ -21,9 +21,9 @@ export const Root = ({ children }: { children?: ReactNode }) => { try { return fetchUrl(CONFIG.CONFIG_URL); } catch (err) { - toast(() => ( + toast( - )); + ); console.error("Error while fetching the config: ", err); return undefined; } @@ -42,9 +42,9 @@ export const Root = ({ children }: { children?: ReactNode }) => { return; } - toast(() => ( + toast( - )); + ); console.error("Error while fetching the config: ", error); } }; diff --git a/frontend/app/src/components/account-menu.tsx b/frontend/app/src/components/account-menu.tsx index 0dddcfe062..d26db649f0 100644 --- a/frontend/app/src/components/account-menu.tsx +++ b/frontend/app/src/components/account-menu.tsx @@ -51,7 +51,7 @@ export const AccountMenu = () => { const profile = data?.AccountProfile; if (error) { - toast(() => , { + toast(, { toastId: customId, }); diff --git a/frontend/app/src/components/buttons/clipboard.tsx b/frontend/app/src/components/buttons/clipboard.tsx index e8fc32a82e..d651000fec 100644 --- a/frontend/app/src/components/buttons/clipboard.tsx +++ b/frontend/app/src/components/buttons/clipboard.tsx @@ -22,7 +22,7 @@ export const Clipboard = (props: tClipboard) => { await navigator.clipboard.writeText(value); - toast(() => ); + toast(); setTimeout(() => { setIsCopied(false); diff --git a/frontend/app/src/components/conversations/thread.tsx b/frontend/app/src/components/conversations/thread.tsx index cd4bda154d..8441638dff 100644 --- a/frontend/app/src/components/conversations/thread.tsx +++ b/frontend/app/src/components/conversations/thread.tsx @@ -168,7 +168,7 @@ export const Thread = (props: tThread) => { setDisplayAddComment(false); } - toast(() => ); + toast(); }; const comments = thread?.comments?.edges?.map((comment: any) => comment.node) ?? []; diff --git a/frontend/app/src/components/editor/code-editor.tsx b/frontend/app/src/components/editor/code-editor.tsx index 6fabad005c..6368d72869 100644 --- a/frontend/app/src/components/editor/code-editor.tsx +++ b/frontend/app/src/components/editor/code-editor.tsx @@ -22,7 +22,7 @@ export const CodeEditor = (props: any) => { await navigator.clipboard.writeText(value); - toast(() => ); + toast(); setTimeout(() => { setIsCopied(false); diff --git a/frontend/app/src/components/file.tsx b/frontend/app/src/components/file.tsx index 29a01fd270..ab0c4987c9 100644 --- a/frontend/app/src/components/file.tsx +++ b/frontend/app/src/components/file.tsx @@ -28,7 +28,7 @@ export const File = (props: tFile) => { setFileContent(fileResult); } catch (err) { console.error("err: ", err); - toast(() => ); + toast(); } setIsLoading(false); diff --git a/frontend/app/src/components/form/object-form.tsx b/frontend/app/src/components/form/object-form.tsx index 18b23e3c56..46dd135089 100644 --- a/frontend/app/src/components/form/object-form.tsx +++ b/frontend/app/src/components/form/object-form.tsx @@ -206,7 +206,7 @@ const NodeForm = ({ }, }); - toast(() => , { + toast(, { toastId: `alert-success-${schema?.name}-created`, }); diff --git a/frontend/app/src/components/list.tsx b/frontend/app/src/components/list.tsx index 26a38398ba..a0b2a71cd5 100644 --- a/frontend/app/src/components/list.tsx +++ b/frontend/app/src/components/list.tsx @@ -40,7 +40,7 @@ const List = forwardRef((props, ref) => { sertInputValue(""); if (newArray.length === value.length) { - toast(() => ); + toast(); } } }; diff --git a/frontend/app/src/components/ui/alert.tsx b/frontend/app/src/components/ui/alert.tsx index dcf77fe7b9..124c81a6ca 100644 --- a/frontend/app/src/components/ui/alert.tsx +++ b/frontend/app/src/components/ui/alert.tsx @@ -27,7 +27,7 @@ type AlertProps = { }; export const Alert = (props: AlertProps) => { - const { closeToast, message, details, onDismiss, type, ...otherProps } = props; + const { closeToast, message, details, onDismiss, type } = props; const getIcon = () => { switch (type) { @@ -113,7 +113,7 @@ export const Alert = (props: AlertProps) => { const alertDetails =

{details}

; return ( -
+
{getIcon()}
@@ -127,7 +127,8 @@ export const Alert = (props: AlertProps) => { "inline-flex rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2", alertClasses?.button )} - onClick={handleDismiss}> + onClick={handleDismiss} + data-testid="close-alert">
diff --git a/frontend/app/src/decorators/withSchemaContext.tsx b/frontend/app/src/decorators/withSchemaContext.tsx index b2c2847031..3ee7ff0a7f 100644 --- a/frontend/app/src/decorators/withSchemaContext.tsx +++ b/frontend/app/src/decorators/withSchemaContext.tsx @@ -98,9 +98,9 @@ export const withSchemaContext = (AppComponent: any) => (props: any) => { setProfiles(profiles); setState({ isReady: true }); } catch (error) { - toast(() => ( + toast( - )); + ); console.error("Error while fetching the schema: ", error); } diff --git a/frontend/app/src/graphql/graphqlClientApollo.tsx b/frontend/app/src/graphql/graphqlClientApollo.tsx index d9c67c3d52..78b8c8c162 100644 --- a/frontend/app/src/graphql/graphqlClientApollo.tsx +++ b/frontend/app/src/graphql/graphqlClientApollo.tsx @@ -126,7 +126,7 @@ export const errorLink = onError(({ graphQLErrors, operation, forward }) => { } default: if (graphQLError.message) { - toast(() => , { + toast(, { toastId: "alert-error", }); } diff --git a/frontend/app/src/hooks/useAuth.tsx b/frontend/app/src/hooks/useAuth.tsx index 9efcaba06a..0552897045 100644 --- a/frontend/app/src/hooks/useAuth.tsx +++ b/frontend/app/src/hooks/useAuth.tsx @@ -108,7 +108,7 @@ export function AuthProvider({ children }: { children: ReactNode }) { setIsLoading(false); if (!result?.access_token) { - toast(() => , { + toast(, { toastId: "alert-error-sign-in", }); diff --git a/frontend/app/src/screens/artifacts/generate.tsx b/frontend/app/src/screens/artifacts/generate.tsx index 674bae90d6..12af7908cd 100644 --- a/frontend/app/src/screens/artifacts/generate.tsx +++ b/frontend/app/src/screens/artifacts/generate.tsx @@ -50,9 +50,9 @@ export const Generate = (props: tGenerateProps) => { }); if (artifactid) { - toast(() => ); + toast(); } else { - toast(() => ); + toast(); } setIsLoading(false); diff --git a/frontend/app/src/screens/branches/branch-details.tsx b/frontend/app/src/screens/branches/branch-details.tsx index 76cb72867b..5d1ac43481 100644 --- a/frontend/app/src/screens/branches/branch-details.tsx +++ b/frontend/app/src/screens/branches/branch-details.tsx @@ -77,7 +77,7 @@ export const BranchDetails = () => { console.log("error: ", error); setDetailsContent(error); - toast(() => ); + toast(); } setIsLoadingRequest(false); diff --git a/frontend/app/src/screens/diff/artifact-diff/artifact-content-diff.tsx b/frontend/app/src/screens/diff/artifact-diff/artifact-content-diff.tsx index 5455eff7fb..302ce95379 100644 --- a/frontend/app/src/screens/diff/artifact-diff/artifact-content-diff.tsx +++ b/frontend/app/src/screens/diff/artifact-diff/artifact-content-diff.tsx @@ -141,7 +141,7 @@ export const ArtifactContentDiff = (props: any) => { setState(fileResult || ""); } catch (err) { console.error("Error while loading files diff: ", err); - toast(() => ); + toast(); } setIsLoading(false); @@ -244,7 +244,7 @@ export const ArtifactContentDiff = (props: any) => { }, }); - toast(() => ); + toast(); if (refetch) { refetch(); @@ -275,13 +275,13 @@ export const ArtifactContentDiff = (props: any) => { console.error("An error occurred while creating the comment: ", error); - toast(() => ( + toast( - )); + ); setIsLoading(false); } diff --git a/frontend/app/src/screens/diff/artifact-diff/artifacts-diff.tsx b/frontend/app/src/screens/diff/artifact-diff/artifacts-diff.tsx index 00b5d01971..e2367de322 100644 --- a/frontend/app/src/screens/diff/artifact-diff/artifacts-diff.tsx +++ b/frontend/app/src/screens/diff/artifact-diff/artifacts-diff.tsx @@ -45,7 +45,7 @@ export const ArtifactsDiff = forwardRef((props, ref) => { setArtifactsDiff(filesResult); } catch (err) { console.error("Error while loading artifacts diff: ", err); - toast(() => ); + toast(); } setIsLoading(false); diff --git a/frontend/app/src/screens/diff/checks/checks-summary.tsx b/frontend/app/src/screens/diff/checks/checks-summary.tsx index 6dec675d9e..58485d08a9 100644 --- a/frontend/app/src/screens/diff/checks/checks-summary.tsx +++ b/frontend/app/src/screens/diff/checks/checks-summary.tsx @@ -64,7 +64,7 @@ export const ChecksSummary = (props: tChecksSummaryProps) => { refetch(); if (result?.data?.CoreProposedChangeRunCheck?.ok) { - toast(() => ); + toast(); } }; diff --git a/frontend/app/src/screens/diff/checks/conflict.tsx b/frontend/app/src/screens/diff/checks/conflict.tsx index e470445a36..1752228e27 100644 --- a/frontend/app/src/screens/diff/checks/conflict.tsx +++ b/frontend/app/src/screens/diff/checks/conflict.tsx @@ -92,7 +92,7 @@ export const Conflict = (props: any) => { }, }); - toast(() => ); + toast(); setIsLoading(false); diff --git a/frontend/app/src/screens/diff/data-diff.tsx b/frontend/app/src/screens/diff/data-diff.tsx index 5e248e967e..e33aa3debe 100644 --- a/frontend/app/src/screens/diff/data-diff.tsx +++ b/frontend/app/src/screens/diff/data-diff.tsx @@ -135,7 +135,7 @@ export const DataDiff = forwardRef((props, ref) => { } catch (err) { console.error("Error when fethcing branches: ", err); - toast(() => ); + toast(); } setIsLoading(false); diff --git a/frontend/app/src/screens/diff/diff-comments.tsx b/frontend/app/src/screens/diff/diff-comments.tsx index 5ed9b21c9b..74e54f7390 100644 --- a/frontend/app/src/screens/diff/diff-comments.tsx +++ b/frontend/app/src/screens/diff/diff-comments.tsx @@ -153,7 +153,7 @@ export const DataDiffComments = (props: tDataDiffComments) => { }, }); - toast(() => ); + toast(); handleRefetch(); } catch (error: any) { diff --git a/frontend/app/src/screens/diff/file-diff/file-content-diff.tsx b/frontend/app/src/screens/diff/file-diff/file-content-diff.tsx index 670b1755f8..ab826aae11 100644 --- a/frontend/app/src/screens/diff/file-diff/file-content-diff.tsx +++ b/frontend/app/src/screens/diff/file-diff/file-content-diff.tsx @@ -160,7 +160,7 @@ export const FileContentDiff = (props: any) => { setState(fileResult); } catch (err) { console.error("Error while loading files diff: ", err); - toast(() => ); + toast(); } setIsLoading(false); @@ -274,7 +274,7 @@ export const FileContentDiff = (props: any) => { }, }); - toast(() => ); + toast(); if (refetch) { refetch(); @@ -305,13 +305,13 @@ export const FileContentDiff = (props: any) => { console.error("An error occurred while creating the comment: ", error); - toast(() => ( + toast( - )); + ); setIsLoading(false); } diff --git a/frontend/app/src/screens/diff/schema-diff.tsx b/frontend/app/src/screens/diff/schema-diff.tsx index bf37f82208..cc012428ab 100644 --- a/frontend/app/src/screens/diff/schema-diff.tsx +++ b/frontend/app/src/screens/diff/schema-diff.tsx @@ -45,7 +45,7 @@ export const SchemaDiff = forwardRef((props, ref) => { setDiff(diffDetails?.diffs ?? []); } catch (err) { console.error("Error when loading branch diff: ", err); - toast(() => ); + toast(); } setIsLoading(false); diff --git a/frontend/app/src/screens/groups/add-group-form.tsx b/frontend/app/src/screens/groups/add-group-form.tsx index d51cef4f15..61c7d4e86f 100644 --- a/frontend/app/src/screens/groups/add-group-form.tsx +++ b/frontend/app/src/screens/groups/add-group-form.tsx @@ -35,12 +35,12 @@ export default function AddGroupForm({ try { await addObjectToGroups({ variables: { objectId, relationshipIds: groupIds } }); - toast(() => ( + toast( - )); + ); if (onUpdateCompleted) onUpdateCompleted(); } catch (e) { diff --git a/frontend/app/src/screens/ipam/ip-addresses/ipam-ip-address-list.tsx b/frontend/app/src/screens/ipam/ip-addresses/ipam-ip-address-list.tsx index a2a680ebd3..0c1c07d9ae 100644 --- a/frontend/app/src/screens/ipam/ip-addresses/ipam-ip-address-list.tsx +++ b/frontend/app/src/screens/ipam/ip-addresses/ipam-ip-address-list.tsx @@ -127,12 +127,12 @@ const IpamIPAddressesList = forwardRef((props, ref) => { setRelatedRowToDelete(undefined); - toast(() => ( + toast( - )); + ); } catch (error) { console.error("Error while deleting address: ", error); } diff --git a/frontend/app/src/screens/ipam/prefixes/ipam-prefix-details.tsx b/frontend/app/src/screens/ipam/prefixes/ipam-prefix-details.tsx index 08429f7174..7a666aee9e 100644 --- a/frontend/app/src/screens/ipam/prefixes/ipam-prefix-details.tsx +++ b/frontend/app/src/screens/ipam/prefixes/ipam-prefix-details.tsx @@ -136,13 +136,13 @@ const IpamIPPrefixDetails = forwardRef((props, ref) => { setRelatedRowToDelete(undefined); - toast(() => ( + toast( - )); + ); } catch (error) { console.error("Error while deleting address: ", error); } diff --git a/frontend/app/src/screens/ipam/prefixes/ipam-prefixes-summary-list.tsx b/frontend/app/src/screens/ipam/prefixes/ipam-prefixes-summary-list.tsx index 8d756be9c8..e1e5eafb16 100644 --- a/frontend/app/src/screens/ipam/prefixes/ipam-prefixes-summary-list.tsx +++ b/frontend/app/src/screens/ipam/prefixes/ipam-prefixes-summary-list.tsx @@ -123,12 +123,12 @@ const IpamIPPrefixesSummaryList = forwardRef((props, ref) => { setRelatedRowToDelete(undefined); - toast(() => ( + toast( - )); + ); } catch (error) { console.error("Error while deleting address: ", error); } diff --git a/frontend/app/src/screens/layout/sidebar/desktop-menu.tsx b/frontend/app/src/screens/layout/sidebar/desktop-menu.tsx index 111d8fe929..43eb137b44 100644 --- a/frontend/app/src/screens/layout/sidebar/desktop-menu.tsx +++ b/frontend/app/src/screens/layout/sidebar/desktop-menu.tsx @@ -43,7 +43,7 @@ export function DesktopMenu({ className = "" }: MenuProps) { setIsLoading(false); } catch (error) { console.error("error: ", error); - toast(() => ); + toast(); setIsLoading(false); } }; diff --git a/frontend/app/src/screens/object-item-details/relationship-details-paginated.tsx b/frontend/app/src/screens/object-item-details/relationship-details-paginated.tsx index 7e77b27b17..592dc02486 100644 --- a/frontend/app/src/screens/object-item-details/relationship-details-paginated.tsx +++ b/frontend/app/src/screens/object-item-details/relationship-details-paginated.tsx @@ -156,12 +156,12 @@ export default function RelationshipDetails(props: iRelationDetailsProps) { refetch(); } - toast(() => ( + toast( - )); + ); }; const handleSubmit = async (data: any) => { @@ -180,12 +180,12 @@ export default function RelationshipDetails(props: iRelationDetailsProps) { refetch(); } - toast(() => ( + toast( - )); + ); setShowAddDrawer(false); } diff --git a/frontend/app/src/screens/object-item-details/relationships-details-paginated.tsx b/frontend/app/src/screens/object-item-details/relationships-details-paginated.tsx index 75da815af1..65c90e3949 100644 --- a/frontend/app/src/screens/object-item-details/relationships-details-paginated.tsx +++ b/frontend/app/src/screens/object-item-details/relationships-details-paginated.tsx @@ -103,7 +103,7 @@ export const RelationshipsDetails = forwardRef((props: RelationshipsDetailsProps updatePageData(); - toast(() => ); + toast(); }; // const count = data[schemaData?.kind].count; diff --git a/frontend/app/src/screens/object-item-edit/object-item-edit-paginated.tsx b/frontend/app/src/screens/object-item-edit/object-item-edit-paginated.tsx index f1d974574c..293a4fce3f 100644 --- a/frontend/app/src/screens/object-item-edit/object-item-edit-paginated.tsx +++ b/frontend/app/src/screens/object-item-edit/object-item-edit-paginated.tsx @@ -122,7 +122,7 @@ export default function ObjectItemEditComponent(props: Props) { context: { branch: branch?.name, date }, }); - toast(() => , { + toast(, { toastId: "alert-success-updated", }); diff --git a/frontend/app/src/screens/object-item-meta-edit/object-item-meta-edit.tsx b/frontend/app/src/screens/object-item-meta-edit/object-item-meta-edit.tsx index ad8462167e..61118b8b0f 100644 --- a/frontend/app/src/screens/object-item-meta-edit/object-item-meta-edit.tsx +++ b/frontend/app/src/screens/object-item-meta-edit/object-item-meta-edit.tsx @@ -60,7 +60,7 @@ export default function ObjectItemMetaEdit(props: Props) { context: { branch: branch?.name, date }, }); - toast(() => ); + toast(); onUpdateComplete(); diff --git a/frontend/app/src/screens/object-items/object-items-paginated.tsx b/frontend/app/src/screens/object-items/object-items-paginated.tsx index 1a897d5f13..99e414aa45 100644 --- a/frontend/app/src/screens/object-items/object-items-paginated.tsx +++ b/frontend/app/src/screens/object-items/object-items-paginated.tsx @@ -111,12 +111,12 @@ export default function ObjectItems({ setRowToDelete(undefined); - toast(() => ( + toast( - )); + ); } catch (error) { console.error("Error while deleting object: ", error); } diff --git a/frontend/app/src/screens/proposed-changes/conversations.tsx b/frontend/app/src/screens/proposed-changes/conversations.tsx index 13a2643e79..b7f078b253 100644 --- a/frontend/app/src/screens/proposed-changes/conversations.tsx +++ b/frontend/app/src/screens/proposed-changes/conversations.tsx @@ -174,7 +174,7 @@ export const Conversations = forwardRef((props: tConversations, ref) => { }, }); - toast(() => ); + toast(); await refetch(); } catch (error: any) { @@ -234,7 +234,7 @@ export const Conversations = forwardRef((props: tConversations, ref) => { context: { branch: branch?.name, date }, }); - toast(() => ); + toast(); if (detailsRefetch) { await detailsRefetch(); @@ -283,18 +283,16 @@ export const Conversations = forwardRef((props: tConversations, ref) => { detailsRefetch(); } - toast(() => ( - - )); + toast(); } catch (error: any) { console.log("error: ", error); - toast(() => ( + toast( - )); + ); } setIsLoadingMerge(false); @@ -329,12 +327,12 @@ export const Conversations = forwardRef((props: tConversations, ref) => { context: { branch: branch?.name, date }, }); - toast(() => ( + toast( - )); + ); if (detailsRefetch) { detailsRefetch(); diff --git a/frontend/app/src/screens/proposed-changes/proposed-changes-create-form.tsx b/frontend/app/src/screens/proposed-changes/proposed-changes-create-form.tsx index 456a49605b..9fb0d6e73f 100644 --- a/frontend/app/src/screens/proposed-changes/proposed-changes-create-form.tsx +++ b/frontend/app/src/screens/proposed-changes/proposed-changes-create-form.tsx @@ -53,7 +53,7 @@ export const ProposedChangeCreateForm = () => { }, }); - toast(() => , { + toast(, { toastId: "alert-success-CoreProposedChange-created", }); diff --git a/frontend/app/src/screens/proposed-changes/proposed-changes-item.tsx b/frontend/app/src/screens/proposed-changes/proposed-changes-item.tsx index d05ee1c577..ae1cefc957 100644 --- a/frontend/app/src/screens/proposed-changes/proposed-changes-item.tsx +++ b/frontend/app/src/screens/proposed-changes/proposed-changes-item.tsx @@ -66,7 +66,7 @@ export const ProposedChange = (props: any) => { setIsLoading(false); - toast(() => ); + toast(); }; return ( diff --git a/frontend/app/src/screens/user-profile/tab-preferences.tsx b/frontend/app/src/screens/user-profile/tab-preferences.tsx index 27b53d56f0..2c4e32ef8d 100644 --- a/frontend/app/src/screens/user-profile/tab-preferences.tsx +++ b/frontend/app/src/screens/user-profile/tab-preferences.tsx @@ -41,7 +41,7 @@ export default function TabPreferences() { try { await updateAccountPassword({ variables: { password: newPassword } }); - toast(() => ); + toast(); } catch (error) { console.error("Error while updating the password: ", error); } diff --git a/frontend/app/tests/e2e/objects/CoreGraphQLQuery/core-graphql-query.spec.ts b/frontend/app/tests/e2e/objects/CoreGraphQLQuery/core-graphql-query.spec.ts index 51bd979647..9b10bf3530 100644 --- a/frontend/app/tests/e2e/objects/CoreGraphQLQuery/core-graphql-query.spec.ts +++ b/frontend/app/tests/e2e/objects/CoreGraphQLQuery/core-graphql-query.spec.ts @@ -17,6 +17,7 @@ test.describe("/objects/CoreGraphQLQuery/:graphqlQueryId - GraphQL Query details await test.step("Navigate to CoreGraphQLQuery page", async () => { await page.goto("/objects/CoreGraphQLQuery"); await expect(page.getByRole("heading", { name: "GraphQL Query" })).toBeVisible(); + await expect(page.getByText("Just a moment")).not.toBeVisible(); }); await test.step("Create a new graphql query", async () => { diff --git a/frontend/app/tests/e2e/objects/object-groups.spec.ts b/frontend/app/tests/e2e/objects/object-groups.spec.ts index cbff20d531..23333cccb4 100644 --- a/frontend/app/tests/e2e/objects/object-groups.spec.ts +++ b/frontend/app/tests/e2e/objects/object-groups.spec.ts @@ -17,6 +17,7 @@ test.describe("Object groups update", () => { test("should contain initial values and update them", async ({ page }) => { await test.step("access the tags and create a new one", async () => { await page.goto("/objects/BuiltinTag"); + await expect(page.getByTestId("create-object-button")).toBeVisible(); await expect(page.getByText("Just a moment")).not.toBeVisible(); await page.getByTestId("create-object-button").click(); await page.getByLabel("Name *").fill(NEW_TAG); diff --git a/frontend/app/tests/e2e/objects/object-relationships.spec.ts b/frontend/app/tests/e2e/objects/object-relationships.spec.ts index a315d2170f..3cf01ef284 100644 --- a/frontend/app/tests/e2e/objects/object-relationships.spec.ts +++ b/frontend/app/tests/e2e/objects/object-relationships.spec.ts @@ -2,6 +2,9 @@ import { expect, test } from "@playwright/test"; import { ACCOUNT_STATE_PATH } from "../../constants"; test.describe("/objects/:objectKind/:objectid - relationship tab", () => { + // Avoid checking as non-admin + updating as admin at the same time + test.describe.configure({ mode: "serial" }); + test.beforeEach(async function ({ page }) { page.on("response", async (response) => { if (response.status() === 500) { @@ -14,8 +17,8 @@ test.describe("/objects/:objectKind/:objectid - relationship tab", () => { test("should not be able to edit relationship", async ({ page }) => { await test.step("Navigate to relationship tab of an object", async () => { await page.goto("/objects/InfraPlatform"); - await page.getByRole("link", { name: "Juniper JunOS" }).click(); - await page.getByText(/Devices9|Devices10/).click(); // since this test can run in parallel with the "should delete the relationship" test + await page.getByRole("link", { name: "Cisco IOS", exact: true }).click(); + await page.getByText("Devices5").click(); }); await test.step("all buttons are disabled", async () => { @@ -33,47 +36,47 @@ test.describe("/objects/:objectKind/:objectid - relationship tab", () => { test("should delete the relationship", async ({ page }) => { await test.step("Navigate to relationship tab of an object", async () => { await page.goto("/objects/InfraPlatform"); - await page.getByRole("link", { name: "Juniper JunOS" }).click(); - await page.getByText("Devices10").click(); + await page.getByRole("link", { name: "Cisco IOS", exact: true }).click(); + await page.getByText("Devices5").click(); }); await test.step("Delete the relationship", async () => { await page - .getByRole("row", { name: "dfw1-core1" }) + .getByRole("row", { name: "ord1-edge2" }) .getByTestId("relationship-delete-button") .click(); await expect(page.getByRole("paragraph")).toContainText( - "Are you sure you want to remove the association between `Juniper JunOS` and `dfw1-core1`? The `InfraDevice` `dfw1-core1` won't be deleted in the process." + "Are you sure you want to remove the association between `Cisco IOS` and `ord1-edge2`? The `InfraDevice` `ord1-edge2` won't be deleted in the process." ); await page.getByTestId("modal-delete-confirm").click(); }); await test.step("Verify deletion of relationship", async () => { await expect(page.getByRole("alert")).toContainText("Item removed from the group"); - await expect(page.getByRole("main")).toContainText("Showing 1 to 9 of 9 results"); - await expect(page.getByLabel("Tabs")).toContainText("Devices9"); + await expect(page.getByRole("main")).toContainText("Showing 1 to 4 of 4 results"); + await expect(page.getByLabel("Tabs")).toContainText("Devices4"); }); }); test("should add a new relationship", async ({ page }) => { await test.step("Navigate to relationship tab of an object", async () => { await page.goto("/objects/InfraPlatform"); - await page.getByRole("link", { name: "Juniper JunOS" }).click(); - await page.getByText("Devices9").click(); + await page.getByRole("link", { name: "Cisco IOS", exact: true }).click(); + await page.getByText("Devices4").click(); }); await test.step("Add a new relationship", async () => { await page.getByTestId("open-relationship-form-button").click(); await page.getByTestId("side-panel-container").getByLabel("Devices").click(); - await page.getByRole("option", { name: "dfw1-core1" }).click(); + await page.getByRole("option", { name: "ord1-edge2" }).click(); await page.getByRole("button", { name: "Save" }).click(); }); await test.step("Verify new relationship addition", async () => { await expect(page.getByRole("alert")).toContainText("Association with InfraDevice added"); - await expect(page.getByRole("main")).toContainText("Showing 1 to 10 of 10 results"); - await expect(page.getByLabel("Tabs")).toContainText("Devices10"); - await expect(page.getByRole("cell", { name: "dfw1-core1" })).toBeVisible(); + await expect(page.getByRole("main")).toContainText("Showing 1 to 5 of 5 results"); + await expect(page.getByLabel("Tabs")).toContainText("Devices5"); + await expect(page.getByRole("cell", { name: "ord1-edge2" })).toBeVisible(); }); }); diff --git a/frontend/app/tests/e2e/objects/profiles/multi-profiles.spec.ts b/frontend/app/tests/e2e/objects/profiles/multi-profiles.spec.ts index 7938326d59..fc6631e4c4 100644 --- a/frontend/app/tests/e2e/objects/profiles/multi-profiles.spec.ts +++ b/frontend/app/tests/e2e/objects/profiles/multi-profiles.spec.ts @@ -27,6 +27,8 @@ test.describe("/objects/CoreProfile - Profiles page", () => { await page.getByLabel("Description").fill("Desc from generic profile"); await page.getByRole("button", { name: "Save" }).click(); await expect(page.getByText("InfraInterface created")).toBeVisible(); + await page.getByTestId("close-alert").click(); + await expect(page.getByText("InfraInterface created")).not.toBeVisible(); // L2 profile v1 await page.getByTestId("create-object-button").click(); @@ -36,6 +38,8 @@ test.describe("/objects/CoreProfile - Profiles page", () => { await page.getByLabel("Description").fill("Desc from L2 profile v1"); await page.getByRole("button", { name: "Save" }).click(); await expect(page.getByText("InfraInterfaceL2 created")).toBeVisible(); + await page.getByTestId("close-alert").click(); + await expect(page.getByText("InfraInterfaceL2 created")).not.toBeVisible(); // L2 profile v2 await page.getByTestId("create-object-button").click(); diff --git a/frontend/app/tests/e2e/proposed-changes/proposed-changes_data.spec.ts b/frontend/app/tests/e2e/proposed-changes/proposed-changes_data.spec.ts index ff85c595ca..cf213bbcd7 100644 --- a/frontend/app/tests/e2e/proposed-changes/proposed-changes_data.spec.ts +++ b/frontend/app/tests/e2e/proposed-changes/proposed-changes_data.spec.ts @@ -38,34 +38,11 @@ test.describe("/proposed-changes diff data", () => { }); await test.step("go to Data tab and open comment form", async () => { - var count = 0; - await Promise.all([ - page.waitForResponse((response) => { - const reqData = response.request().postDataJSON(); - const status = response.status(); - - if ( - reqData?.operationName === "getProposedChangesThreadsForCoreObjectThread" && - status === 200 - ) { - count++; - } - - return count == 9; // waiting for 9 diff elements - }), - page.waitForResponse((response) => { - const status = response.status(); - - return ( - response - .url() - .includes("/api/diff/data?branch=atl1-delete-upstream&branch_only=true") && - status === 200 - ); - }), // wait for diff data otherwise hover won't show comment button - page.getByLabel("Tabs").getByText("Data").click(), - ]); - await page.getByText("InfraCircuit").first().hover(); + await page.getByLabel("Tabs").getByText("Data").click(); + await expect(page.getByText("Just a moment")).not.toBeVisible(); + await expect(page.getByText("REMOVEDInfraCircuit", { exact: true }).first()).toBeVisible(); + await page.getByText("REMOVEDInfraCircuit", { exact: true }).first().hover(); + await expect(page.getByTestId("data-diff-add-comment").first()).toBeVisible(); await page.getByTestId("data-diff-add-comment").first().click(); await expect(page.getByText("Conversation")).toBeVisible(); }); @@ -73,6 +50,7 @@ test.describe("/proposed-changes diff data", () => { await test.step("add first comment", async () => { await page.getByTestId("codemirror-editor").getByRole("textbox").fill("first is comment"); await page.getByRole("button", { name: "Comment", exact: true }).click(); + await expect(page.getByText("Reply")).toBeVisible(); await expect(page.getByTestId("thread").getByTestId("comment")).toContainText( "first is comment" ); @@ -85,6 +63,7 @@ test.describe("/proposed-changes diff data", () => { await thread.getByRole("button", { name: "Reply" }).click(); await thread.getByTestId("codemirror-editor").getByRole("textbox").fill("second is reply"); await page.getByRole("button", { name: "Comment", exact: true }).click(); + await expect(page.getByText("Reply")).toBeVisible(); await expect(page.getByText("second is reply")).toBeVisible(); await expect(page.getByTestId("comments-count")).toContainText("2"); });