Prefer using arrow functions for callbacks (#1287)

This commit is contained in:
Jon Koops 2021-10-04 08:03:19 +02:00 committed by GitHub
parent 3b677c6e8e
commit 55307ec1ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 40 additions and 38 deletions

View file

@ -35,6 +35,7 @@ module.exports = {
"react/prop-types": "off", "react/prop-types": "off",
// Prevent fragments from being added that have only a single child. // Prevent fragments from being added that have only a single child.
"react/jsx-no-useless-fragment": "error", "react/jsx-no-useless-fragment": "error",
"prefer-arrow-callback": "error",
"prettier/prettier": [ "prettier/prettier": [
"error", "error",
{ {

View file

@ -15,15 +15,15 @@ const listingPage = new ListingPage();
const createClientScopePage = new CreateClientScopePage(); const createClientScopePage = new CreateClientScopePage();
const modalUtils = new ModalUtils(); const modalUtils = new ModalUtils();
describe("Client Scopes test", function () { describe("Client Scopes test", () => {
describe("Client Scope creation", function () { describe("Client Scope creation", () => {
beforeEach(function () { beforeEach(() => {
keycloakBefore(); keycloakBefore();
loginPage.logIn(); loginPage.logIn();
sidebarPage.goToClientScopes(); sidebarPage.goToClientScopes();
}); });
it("should fail creating client scope", function () { it("should fail creating client scope", () => {
listingPage.goToCreateItem(); listingPage.goToCreateItem();
createClientScopePage.save().checkClientNameRequiredMessage(); createClientScopePage.save().checkClientNameRequiredMessage();

View file

@ -19,15 +19,15 @@ const listingPage = new ListingPage();
const createClientPage = new CreateClientPage(); const createClientPage = new CreateClientPage();
const modalUtils = new ModalUtils(); const modalUtils = new ModalUtils();
describe("Clients test", function () { describe("Clients test", () => {
describe("Client creation", function () { describe("Client creation", () => {
beforeEach(function () { beforeEach(() => {
keycloakBefore(); keycloakBefore();
loginPage.logIn(); loginPage.logIn();
sidebarPage.goToClients(); sidebarPage.goToClients();
}); });
it("should fail creating client", function () { it("should fail creating client", () => {
listingPage.goToCreateItem(); listingPage.goToCreateItem();
createClientPage.continue().checkClientIdRequiredMessage(); createClientPage.continue().checkClientIdRequiredMessage();
@ -46,7 +46,7 @@ describe("Clients test", function () {
); );
}); });
it("Client CRUD test", function () { it("Client CRUD test", () => {
itemId += "_" + (Math.random() + 1).toString(36).substring(7); itemId += "_" + (Math.random() + 1).toString(36).substring(7);
// Create // Create

View file

@ -34,7 +34,7 @@ describe("Identity provider test", () => {
describe("Identity provider creation", () => { describe("Identity provider creation", () => {
const identityProviderName = "github"; const identityProviderName = "github";
beforeEach(function () { beforeEach(() => {
keycloakBefore(); keycloakBefore();
loginPage.logIn(); loginPage.logIn();
sidebarPage.goToIdentityProviders(); sidebarPage.goToIdentityProviders();

View file

@ -8,18 +8,18 @@ const password = "admin";
const loginPage = new LoginPage(); const loginPage = new LoginPage();
const masthead = new Masthead(); const masthead = new Masthead();
describe("Logging In", function () { describe("Logging In", () => {
beforeEach(function () { beforeEach(() => {
keycloakBefore(); keycloakBefore();
}); });
it("displays errors on wrong credentials", function () { it("displays errors on wrong credentials", () => {
loginPage.logIn("wrong", "user{enter}"); loginPage.logIn("wrong", "user{enter}");
loginPage.checkErrorMessage("Invalid username or password.").isLogInPage(); loginPage.checkErrorMessage("Invalid username or password.").isLogInPage();
}); });
it("logs in", function () { it("logs in", () => {
loginPage.logIn(username, password); loginPage.logIn(username, password);
masthead.isAdminConsole(); masthead.isAdminConsole();

View file

@ -16,15 +16,15 @@ const listingPage = new ListingPage();
const createRealmRolePage = new CreateRealmRolePage(); const createRealmRolePage = new CreateRealmRolePage();
const associatedRolesPage = new AssociatedRolesPage(); const associatedRolesPage = new AssociatedRolesPage();
describe("Realm roles test", function () { describe("Realm roles test", () => {
describe("Realm roles creation", function () { describe("Realm roles creation", () => {
beforeEach(function () { beforeEach(() => {
keycloakBefore(); keycloakBefore();
loginPage.logIn(); loginPage.logIn();
sidebarPage.goToRealmRoles(); sidebarPage.goToRealmRoles();
}); });
it("should fail creating realm role", function () { it("should fail creating realm role", () => {
listingPage.goToCreateItem(); listingPage.goToCreateItem();
createRealmRolePage.save().checkRealmRoleNameRequiredMessage(); createRealmRolePage.save().checkRealmRoleNameRequiredMessage();
@ -37,7 +37,7 @@ describe("Realm roles test", function () {
); );
}); });
it("Realm role CRUD test", function () { it("Realm role CRUD test", () => {
itemId += "_" + (Math.random() + 1).toString(36).substring(7); itemId += "_" + (Math.random() + 1).toString(36).substring(7);
// Create // Create
@ -63,7 +63,7 @@ describe("Realm roles test", function () {
listingPage.itemExist(itemId, false); listingPage.itemExist(itemId, false);
}); });
it("Associated roles test", function () { it("Associated roles test", () => {
itemId += "_" + (Math.random() + 1).toString(36).substring(7); itemId += "_" + (Math.random() + 1).toString(36).substring(7);
// Create // Create

View file

@ -108,7 +108,7 @@ describe("Realm settings tests", () => {
return this; return this;
}; };
it("Go to general tab", function () { it("Go to general tab", () => {
sidebarPage.goToRealmSettings(); sidebarPage.goToRealmSettings();
realmSettingsPage.toggleSwitch(realmSettingsPage.managedAccessSwitch); realmSettingsPage.toggleSwitch(realmSettingsPage.managedAccessSwitch);
realmSettingsPage.save(realmSettingsPage.generalSaveBtn); realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
@ -446,27 +446,27 @@ describe("Realm settings tests", () => {
cy.findByTestId("rs-profiles-clientPolicies-tab").click(); cy.findByTestId("rs-profiles-clientPolicies-tab").click();
}); });
it("Go to client policies profiles tab", function () { it("Go to client policies profiles tab", () => {
realmSettingsPage.shouldDisplayProfilesTab(); realmSettingsPage.shouldDisplayProfilesTab();
}); });
it("Check new client form is displaying", function () { it("Check new client form is displaying", () => {
realmSettingsPage.shouldDisplayNewClientProfileForm(); realmSettingsPage.shouldDisplayNewClientProfileForm();
}); });
it("Complete new client form and cancel", function () { it("Complete new client form and cancel", () => {
realmSettingsPage.shouldCompleteAndCancelCreateNewClientProfile(); realmSettingsPage.shouldCompleteAndCancelCreateNewClientProfile();
}); });
it("Complete new client form and submit", function () { it("Complete new client form and submit", () => {
realmSettingsPage.shouldCompleteAndCreateNewClientProfile(); realmSettingsPage.shouldCompleteAndCreateNewClientProfile();
}); });
it("Check cancelling the client profile deletion", function () { it("Check cancelling the client profile deletion", () => {
realmSettingsPage.shouldDisplayDeleteClientProfileDialog(); realmSettingsPage.shouldDisplayDeleteClientProfileDialog();
}); });
it("Check deleting the client profile", function () { it("Check deleting the client profile", () => {
realmSettingsPage.shouldDeleteClientProfileDialog(); realmSettingsPage.shouldDeleteClientProfileDialog();
}); });
}); });

View file

@ -7,9 +7,9 @@ const loginPage = new LoginPage();
const sidebarPage = new SidebarPage(); const sidebarPage = new SidebarPage();
const sessionsPage = new SessionsPage(); const sessionsPage = new SessionsPage();
describe("Sessions test", function () { describe("Sessions test", () => {
describe("Session type dropdown", function () { describe("Session type dropdown", () => {
beforeEach(function () { beforeEach(() => {
keycloakBefore(); keycloakBefore();
loginPage.logIn(); loginPage.logIn();
sidebarPage.goToSessions(); sidebarPage.goToSessions();

View file

@ -6,10 +6,7 @@ type ConditionalNodeProps = {
selected: boolean; selected: boolean;
}; };
export const ConditionalNode = memo(function TheNode({ const ConditionalNodeInner = ({ data, selected }: ConditionalNodeProps) => {
data,
selected,
}: ConditionalNodeProps) {
return ( return (
<> <>
<Handle position={Position.Right} type="source" /> <Handle position={Position.Right} type="source" />
@ -23,4 +20,6 @@ export const ConditionalNode = memo(function TheNode({
<Handle position={Position.Left} type="target" /> <Handle position={Position.Left} type="target" />
</> </>
); );
}); };
export const ConditionalNode = memo(ConditionalNodeInner);

View file

@ -10,11 +10,11 @@ type SubFlowNodeProps = NodeProps & {
prefix: string; prefix: string;
}; };
export const SubFlowNode = memo(function TheNode({ const SubFlowNodeInner = ({
data: { label }, data: { label },
prefix, prefix,
selected, selected,
}: SubFlowNodeProps) { }: SubFlowNodeProps) => {
return ( return (
<> <>
<Handle position={Position.Right} type="source" /> <Handle position={Position.Right} type="source" />
@ -30,7 +30,9 @@ export const SubFlowNode = memo(function TheNode({
<Handle position={Position.Left} type="target" /> <Handle position={Position.Left} type="target" />
</> </>
); );
}); };
export const SubFlowNode = memo(SubFlowNodeInner);
export const StartSubFlowNode = ({ ...props }: NodeProps) => ( export const StartSubFlowNode = ({ ...props }: NodeProps) => (
<SubFlowNode {...props} prefix="Start" /> <SubFlowNode {...props} prefix="Start" />