Skip to content

Commit

Permalink
Merge pull request #113 from replayio-public/feature/PRO-697-muiv5-up…
Browse files Browse the repository at this point in the history
…date

Upgrade to MUI v5 for React 18 / 19 compat
  • Loading branch information
markerikson authored Jun 25, 2024
2 parents 60748f3 + 3bdceb9 commit 3649741
Show file tree
Hide file tree
Showing 67 changed files with 1,862 additions and 1,468 deletions.
12 changes: 3 additions & 9 deletions backend/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@ type Query {
}

type Mutation {
createBankAccount(
bankName: String!,
accountNumber: String!,
routingNumber: String!
): BankAccount
deleteBankAccount(
id: ID!
): Boolean
createBankAccount(bankName: String!, accountNumber: String!, routingNumber: String!): BankAccount
deleteBankAccount(id: ID!): Boolean
}

type BankAccount {
Expand All @@ -23,4 +17,4 @@ type BankAccount {
isDeleted: Boolean
createdAt: String
modifiedAt: String
}
}
1 change: 1 addition & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ Cypress.Commands.add("setTransactionAmountRange", (min, max) => {
.getBySelLike("filter-amount-range-slider")
.reactComponent()
.its("memoizedProps")
.its("ownerState")
.invoke("onChange", null, [min / 10, max / 10]);
});

Expand Down
10 changes: 4 additions & 6 deletions cypress/support/component-index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<title>Components App</title>

</head>
<body>

<div data-cy-root></div>
</body>
</html>
110 changes: 52 additions & 58 deletions cypress/tests/ui/notifications.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,65 +26,59 @@ describe("Notifications", function () {
});

describe("notifications from user interactions", function () {
it(
"User A likes a transaction of User B; User B gets notification that User A liked transaction ",
// NOTE: this test seems to have issues in Firefox UI/Mobile tests due to an issue with the Base Button component in MUI v4
// we should try unskipping this test in Firefox once we upgrade MUI to v5+. @see https://github.com/cypress-io/cypress-realworld-app/issues/1278
{ browser: { name: "!firefox" } },
function () {
cy.loginByXstate(ctx.userA.username);
cy.wait("@getNotifications");

cy.database("find", "transactions", { senderId: ctx.userB.id }).then(
(transaction: Transaction) => {
cy.visit(`/transaction/${transaction.id}`);
}
);

cy.log("🚩 Renders the notifications badge with count");
cy.wait("@getNotifications")
.its("response.body.results.length")
.then((notificationCount) => {
cy.getBySel("nav-top-notifications-count").should("have.text", `${notificationCount}`);
});
cy.visualSnapshot("Renders the notifications badge with count");

const likesCountSelector = "[data-test*=transaction-like-count]";
cy.contains(likesCountSelector, 0);
cy.getBySelLike("like-button").click();
// a successful "like" should disable the button and increment
// the number of likes
cy.getBySelLike("like-button").should("be.disabled");
cy.contains(likesCountSelector, 1);
cy.visualSnapshot("Like Count Incremented");

cy.switchUserByXstate(ctx.userB.username);
cy.visualSnapshot(`Switch to User ${ctx.userB.username}`);

cy.wait("@getNotifications")
.its("response.body.results.length")
.as("preDismissedNotificationCount");

cy.visit("/notifications");

cy.wait("@getNotifications");

cy.getBySelLike("notification-list-item")
.should("have.length", 9)
.first()
.should("contain", ctx.userA?.firstName)
.and("contain", "liked");

cy.log("🚩 Marks notification as read");
cy.getBySelLike("notification-mark-read").first().click({ force: true });
cy.wait("@updateNotification");

cy.get("@preDismissedNotificationCount").then((count) => {
cy.getBySelLike("notification-list-item").should("have.length.lessThan", Number(count));
it("User A likes a transaction of User B; User B gets notification that User A liked transaction ", function () {
cy.loginByXstate(ctx.userA.username);
cy.wait("@getNotifications");

cy.database("find", "transactions", { senderId: ctx.userB.id }).then(
(transaction: Transaction) => {
cy.visit(`/transaction/${transaction.id}`);
}
);

cy.log("🚩 Renders the notifications badge with count");
cy.wait("@getNotifications")
.its("response.body.results.length")
.then((notificationCount) => {
cy.getBySel("nav-top-notifications-count").should("have.text", `${notificationCount}`);
});
cy.visualSnapshot("Notification count after notification dismissed");
}
);
cy.visualSnapshot("Renders the notifications badge with count");

const likesCountSelector = "[data-test*=transaction-like-count]";
cy.contains(likesCountSelector, 0);
cy.getBySelLike("like-button").click();
// a successful "like" should disable the button and increment
// the number of likes
cy.getBySelLike("like-button").should("be.disabled");
cy.contains(likesCountSelector, 1);
cy.visualSnapshot("Like Count Incremented");

cy.switchUserByXstate(ctx.userB.username);
cy.visualSnapshot(`Switch to User ${ctx.userB.username}`);

cy.wait("@getNotifications")
.its("response.body.results.length")
.as("preDismissedNotificationCount");

cy.visit("/notifications");

cy.wait("@getNotifications");

cy.getBySelLike("notification-list-item")
.should("have.length", 9)
.first()
.should("contain", ctx.userA?.firstName)
.and("contain", "liked");

cy.log("🚩 Marks notification as read");
cy.getBySelLike("notification-mark-read").first().click({ force: true });
cy.wait("@updateNotification");

cy.get("@preDismissedNotificationCount").then((count) => {
cy.getBySelLike("notification-list-item").should("have.length.lessThan", Number(count));
});
cy.visualSnapshot("Notification count after notification dismissed");
});

it("User C likes a transaction between User A and User B; User A and User B get notifications that User C liked transaction", function () {
cy.loginByXstate(ctx.userC.username);
Expand Down
4 changes: 2 additions & 2 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"lib": ["es2015", "dom"],
"isolatedModules": false,
"allowJs": true,
"noEmit": true
}
"noEmit": true,
},
}
2 changes: 1 addition & 1 deletion data/database.json
Original file line number Diff line number Diff line change
Expand Up @@ -10985,4 +10985,4 @@
"modifiedAt": "2024-03-07T13:32:42.472Z"
}
]
}
}
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
"@babel/core": "7.23.9",
"@babel/plugin-syntax-flow": "^7.14.5",
"@babel/plugin-transform-react-jsx": "^7.14.9",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0",
"@graphql-tools/graphql-file-loader": "7.5.17",
"@graphql-tools/load": "7.8.14",
"@material-ui/core": "4.12.4",
"@material-ui/icons": "4.11.3",
"@material-ui/lab": "4.0.0-alpha.61",
"@matheusluizn/react-google-login": "^5.1.6",
"@mui/icons-material": "^5.15.12",
"@mui/lab": "^5.0.0-alpha.167",
"@mui/material": "^5.15.12",
"@okta/jwt-verifier": "^3.0.1",
"@okta/okta-auth-js": "^7.3.0",
"@okta/okta-react": "^6.7.0",
Expand Down
103 changes: 0 additions & 103 deletions patches/@material-ui+core+4.12.4.patch

This file was deleted.

2 changes: 1 addition & 1 deletion renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
},
{
"groupName": "Material UI",
"matchPackagePatterns": ["^@material-ui/"]
"matchPackagePatterns": ["^@mui/"]
},
{
"groupName": "Graphql",
Expand Down
4 changes: 2 additions & 2 deletions scripts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"exclude": [],
"compilerOptions": {
"types": ["node"],
"isolatedModules": false
}
"isolatedModules": false,
},
}
38 changes: 19 additions & 19 deletions src/__tests__/comments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ import {
import { User, Transaction } from "../../src/models";

describe("Comments", () => {
// beforeEach(() => {
// seedDatabase();
// });
// it("should comment a transaction for a contact", () => {
// const user: User = getAllUsers()[0];
// const transactions: Transaction[] = getTransactionsForUserContacts(user.id);
// const content = "This is my comment content";
// const comment = createComment(user.id, transactions[0].id, content);
// expect(comment.transactionId).toBe(transactions[0].id);
// expect(comment.content).toBe(content);
// });
// it("should get a list of comments for a transaction", () => {
// const user: User = getAllUsers()[0];
// const transactions: Transaction[] = getTransactionsByUserId(user.id);
// const transaction = transactions[0];
// createComment(user.id, transaction.id, "This is my comment");
// const comments = getCommentsByTransactionId(transaction.id);
// expect(comments[0].transactionId).toBe(transaction.id);
// });
beforeEach(() => {
seedDatabase();
});
it("should comment a transaction for a contact", () => {
const user: User = getAllUsers()[0];
const transactions: Transaction[] = getTransactionsForUserContacts(user.id);
const content = "This is my comment content";
const comment = createComment(user.id, transactions[0].id, content);
expect(comment.transactionId).toBe(transactions[0].id);
expect(comment.content).toBe(content);
});
it("should get a list of comments for a transaction", () => {
const user: User = getAllUsers()[0];
const transactions: Transaction[] = getTransactionsByUserId(user.id);
const transaction = transactions[0];
createComment(user.id, transaction.id, "This is my comment");
const comments = getCommentsByTransactionId(transaction.id);
expect(comments[0].transactionId).toBe(transaction.id);
});
});
Loading

0 comments on commit 3649741

Please sign in to comment.