Skip to content

Commit

Permalink
[CP-3093] Add data-testid to Success modal for Contact Support Form s…
Browse files Browse the repository at this point in the history
…ending (#2054)
  • Loading branch information
dkarski authored Sep 17, 2024
1 parent 15a5980 commit 93600ea
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

import React from "react"
import { defineMessages } from "react-intl"
import { FunctionComponent } from "Core/core/types/function-component.interface"
import { ContactSupportModalTestIds } from "e2e-test-ids"
import { Modal } from "generic-view/ui"
import { IconType } from "generic-view/utils"
import { FunctionComponent } from "Core/core/types/function-component.interface"
import { intl } from "Core/__deprecated__/renderer/utils/intl"
import { ButtonSecondary } from "../../../generic-view/ui/src/lib/buttons/button-secondary"
import { IconType } from "generic-view/utils"

const messages = defineMessages({
title: { id: "component.supportModalSuccessTitle" },
Expand All @@ -26,10 +27,15 @@ export const ContactSupportModalSuccess: FunctionComponent<Props> = ({
}) => (
<>
<Modal.TitleIcon config={{ type: IconType.Success }} />
<Modal.Title>{intl.formatMessage(messages.title)}</Modal.Title>
<p>{intl.formatMessage(messages.body)}</p>
<Modal.Title data-testid={ContactSupportModalTestIds.Title}>
{intl.formatMessage(messages.title)}
</Modal.Title>
<p data-testid={ContactSupportModalTestIds.Description}>
{intl.formatMessage(messages.body)}
</p>
<Modal.Buttons config={{ vertical: true }}>
<ButtonSecondary
data-testid={ContactSupportModalTestIds.CloseButton}
config={{
text: intl.formatMessage(messages.closeButtonLabel),
action: {
Expand Down
18 changes: 18 additions & 0 deletions libs/e2e-test-ids/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.js"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
7 changes: 7 additions & 0 deletions libs/e2e-test-ids/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# e2e-test-ids

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build e2e-test-ids` to build the library.
23 changes: 23 additions & 0 deletions libs/e2e-test-ids/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "e2e-test-ids",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/e2e-test-ids/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/e2e-test-ids",
"main": "libs/e2e-test-ids/src/index.ts",
"tsConfig": "libs/e2e-test-ids/tsconfig.lib.json",
"assets": ["libs/e2e-test-ids/*.md"]
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
}
},
"tags": []
}
14 changes: 14 additions & 0 deletions libs/e2e-test-ids/src/e2e-test-ids.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Copyright (c) Mudita sp. z o.o. All rights reserved.
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/

export enum ModalCloseButtonTestIds {
IconButton = "modal-close-button-icon-button",
}

export enum ContactSupportModalTestIds {
Title = "contact-support-modal-success-title",
Description = "contact-support-modal-success-description",
CloseButton = "contact-support-modal-success-close-button",
}
6 changes: 6 additions & 0 deletions libs/e2e-test-ids/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Copyright (c) Mudita sp. z o.o. All rights reserved.
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/

export * from "./e2e-test-ids"
16 changes: 16 additions & 0 deletions libs/e2e-test-ids/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"allowJs": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
}
]
}
9 changes: 9 additions & 0 deletions libs/e2e-test-ids/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["node"]
},
"include": ["src/**/*.ts"],
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"]
}
2 changes: 1 addition & 1 deletion libs/generic-view/theme/src/lib/generic-theme-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const GlobalStyle = createGlobalStyle<{ theme: Theme }>`
box-shadow: 0 2rem 10rem 0 ${({ theme }) => theme.color.black + "26"};
}
.modal-close-button:nth-child(2) {
.modal-close-icon-button:nth-child(2) {
display: none;
}
* {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@

import React from "react"
import styled, { css } from "styled-components"
import { ModalCloseButtonTestIds } from "e2e-test-ids"
import { APIFC, IconType } from "generic-view/utils"
import { ModalCloseButtonConfig } from "generic-view/models"
import { ButtonBase } from "../../../buttons/button-base/button-base"
import { iconButtonStyles } from "../../../shared/button"
import { Icon } from "../../../icon/icon"
import { ModalCloseButtonConfig } from "generic-view/models"

export const ModalCloseButton: APIFC<undefined, ModalCloseButtonConfig> = ({
data,
config,
className,
className = "",
...rest
}) => {
if (!config?.action) return null
return (
<ModalClose
action={config.action}
test-id={"modal-close-button"}
className={"modal-close-button " + className}
data-testid={ModalCloseButtonTestIds.IconButton}
className={"modal-close-icon-button " + className}
{...rest}
>
<ModalCloseIcon />
Expand Down
5 changes: 5 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,10 @@
}
}
}
},
"pluginsConfig": {
"@nx/js": {
"analyzeSourceFiles": true
}
}
}
1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"e2e-mock-client": ["libs/e2e-mock/client/src/index.ts"],
"e2e-mock-responses": ["libs/e2e-mock/responses/src/index.ts"],
"e2e-mock-server": ["libs/e2e-mock/server/src/index.ts"],
"e2e-test-ids": ["libs/e2e-test-ids/src/index.ts"],
"electron/application-updater": [
"libs/electron/application-updater/src/index.ts"
],
Expand Down

0 comments on commit 93600ea

Please sign in to comment.