Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#3476] update cypress tests baseurl #3509

Merged
merged 32 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {apiHostUrl} from '../../../../../httpClient';
import {StateModel} from '../../../../../reducers';
import {allChannels} from '../../../../../selectors/channels';
import {connectChatPlugin, updateChannel, disconnectChannel} from '../../../../../actions';
import {cyChannelCreatedChatPluginCloseButton} from 'handles';

import {Button, LinkButton, SettingsModal} from 'components';
import {Channel, Source} from 'model';
Expand Down Expand Up @@ -209,6 +210,7 @@ const ChatPluginConnect = (props: ConnectedProps<typeof connector>) => {
title={t('successfullyCreatedChannel')}
close={handleClose}
headerClassName={styles.headerModal}
dataCyCloseButton={cyChannelCreatedChatPluginCloseButton}
>
<Button styleVariant="normal" type="submit" onClick={handleCustomize} className={styles.modalButton}>
{t('customize')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const ItemInfo = (props: ComponentInfoProps) => {
)}
</div>

{!needsConfig && (
{isComponent && !needsConfig && (
<div className={styles.enabled}>
Copy link
Contributor Author

@AudreyKj AudreyKj Jul 29, 2022

Choose a reason for hiding this comment

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

status page here: only components display the toggle

<Toggle value={componentEnabled} updateValue={onEnableComponent} size="small" variant="green" />
</div>
Expand Down
1 change: 1 addition & 0 deletions frontend/inbox/handles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const cyChannelsChatPluginConnectButton = 'channelsChatPluginConnectButto
export const cyConnectorsAddNewButton = 'connectorsAddNewButton';
export const cyChannelsChatPluginFormNameInput = 'channelsChatPluginFormNameInput';
export const cyChannelsChatPluginFormSubmitButton = 'channelsChatPluginFormSubmitButton';
export const cyChannelCreatedChatPluginCloseButton = 'channelCreatedChatPluginCloseButton';
export const cyChannelsFormBackButton = 'channelsFormBackButton';

export const cyOpenStateButton = 'openStateButton';
Expand Down
3 changes: 2 additions & 1 deletion integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ nodejs_binary(
data = [
":cypress.config.ts",
"//integration/chat-plugin",
"//integration/commands",
"//integration/support",
"//integration/ui",
"@npm//@types/node",
"@npm//cypress",
],
entry_point = {
Expand Down
1 change: 1 addition & 0 deletions integration/chat-plugin/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ts_web_library(
deps = [
"//frontend/chat-plugin/handles:chat-plugin-handles",
"//frontend/inbox/handles",
"@npm//@types/node",
"@npm//cypress",
],
)
33 changes: 14 additions & 19 deletions integration/chat-plugin/websocket_test.spec.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
import {cyInputbarTextarea, cyInputbarButton, cyChatPluginMessageList} from 'chat-plugin-handles';

import {
cyChannelsChatPluginAddButton,
cyConnectorsAddNewButton,
cyChannelsChatPluginFormNameInput,
cyChannelsChatPluginFormSubmitButton,
} from 'handles';
import {cyChatPluginMessageList} from 'chat-plugin-handles';

declare global {
namespace Cypress {
interface Chainable<Subject> {
createChatPluginConversation(): Chainable<Subject>;
editContactDetails(): Chainable<Subject>;
connectChatPluginConnector(): Chainable<Subject>;
editDisplayName(): Chainable<Subject>;
listConversationsForContact(): Chainable<Subject>;
}
}
}

describe('Websocket test', () => {
it('Send message from Inbox to Chatplugin and assert Websocket is working', () => {
cy.visit('/control-center/connectors');
cy.wait(500);
cy.url().should('include', '/connectors');
cy.get(`[data-cy=${cyChannelsChatPluginAddButton}]`).click();
cy.get(`[data-cy=${cyConnectorsAddNewButton}]`).click();
cy.get(`[data-cy=${cyChannelsChatPluginFormNameInput}]`).type(Cypress.env('chatPluginName'));
cy.get(`[data-cy=${cyChannelsChatPluginFormSubmitButton}]`).click();

cy.visit('/chatplugin/ui/example?channel_id=' + Cypress.env('channelId'));
cy.get(`[data-cy=${cyInputbarTextarea}]`).type(Cypress.env('messageChatplugin'));
cy.get(`[data-cy=${cyInputbarButton}]`).click();
cy.createChatPluginConversation();

cy.wait(500);

Expand Down
4 changes: 2 additions & 2 deletions integration/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {defineConfig} from 'cypress';

export default defineConfig({
e2e: {
baseUrl: 'http://airy.core',
baseUrl: 'http://localhost',
specPattern: 'integration/**/*.spec.?s',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

change of base url here

supportFile: 'integration/commands/index.ts',
supportFile: 'integration/support/index.ts',
},
env: {
chatPluginName: 'Cypress Chatplugin',
Expand Down
7 changes: 4 additions & 3 deletions integration/commands/BUILD → integration/support/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ check_pkg(name = "buildifier")
package(default_visibility = ["//visibility:public"])

ts_web_library(
name = "commands",
srcs = glob(["*.spec.ts"]),
name = "support",
tsconfig = {
"compilerOptions": {
"lib": [
"esnext",
"dom",
],
"types": ["cypress"],
"types": [
"cypress",
],
},
},
deps = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ import {
cyChannelsChatPluginFormSubmitButton,
cyChannelsChatPluginList,
cyChannelsFormBackButton,
cyChannelCreatedChatPluginCloseButton,
} from 'handles';
import {cyInputbarButton, cyInputbarTextarea} from 'chat-plugin-handles';

export const connectChatPluginConnector = (): void => {
cy.get(`[data-cy=${cyChannelsChatPluginAddButton}]`).click();
cy.get(`[data-cy=${cyConnectorsAddNewButton}]`).click();
cy.get(`[data-cy=${cyChannelsChatPluginFormNameInput}]`).type(Cypress.env('chatPluginName'));
cy.get(`[data-cy=${cyConnectorsAddNewButton}]`).first().click({force: true});
cy.wait(500);
cy.get(`[data-cy=${cyChannelsChatPluginFormNameInput}]`).type(Cypress.env('chatPluginName'), {force: true});
cy.get(`[data-cy=${cyChannelsChatPluginFormSubmitButton}]`).click();
cy.get(`[data-cy=${cyChannelCreatedChatPluginCloseButton}]`).click();
};

export const createChatPluginConversation = (): void => {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions integration/ui/connect_chatplugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ declare global {
describe('Connect chatplugin channel', () => {
it('Connect chatplugin channel', () => {
cy.visit('/control-center/connectors');
cy.wait(500);
cy.wait(8000);
cy.url().should('include', '/control-center/connectors');
cy.connectChatPluginConnector();

cy.url().should('include', '/control-center/connectors/connected');
cy.url().should('include', '/control-center/connectors');
cy.get(`[data-cy=${cyChannelsFormBackButton}]`).click();
cy.get(`[data-cy=${cyChannelsChatPluginList}]`).filter(`:contains("${Cypress.env('chatPluginName')}")`);
});
Expand Down
20 changes: 2 additions & 18 deletions integration/ui/create_tag.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,16 @@ import {
cyTagsDialogColorSelectorRed,
cyTagsSearchField,
cyTagsTable,
cyChannelsChatPluginAddButton,
cyConnectorsAddNewButton,
cyChannelsChatPluginFormNameInput,
cyChannelsChatPluginFormSubmitButton,
cyTagsTableRowDisplayDeleteModal,
cyTagsTableRowDisplayDeleteModalInput,
cyTagsTableRowDisplayDeleteModalButton,
cyChannelsFormBackButton,
} from 'handles';

import {cyInputbarButton, cyInputbarTextarea} from 'chat-plugin-handles';

describe('Creates and Deletes a Tag', () => {
it('Creates and Deletes a Tag', () => {
cy.visit('/control-center/connectors');
cy.wait(500);
cy.get(`[data-cy=${cyChannelsChatPluginAddButton}]`).click();
cy.get(`[data-cy=${cyConnectorsAddNewButton}]`).click();
cy.get(`[data-cy=${cyChannelsChatPluginFormNameInput}]`).type(Cypress.env('chatPluginName'));
cy.get(`[data-cy=${cyChannelsChatPluginFormSubmitButton}]`).click();
cy.createChatPluginConversation();

cy.get(`[data-cy=${cyChannelsFormBackButton}]`).click();

cy.visit('/chatplugin/ui/example?channel_id=' + Cypress.env('channelId'));
cy.get(`[data-cy=${cyInputbarTextarea}]`).type(Cypress.env('messageChatplugin'));
cy.get(`[data-cy=${cyInputbarButton}]`).click();
cy.wait(500);

cy.visit('/inbox/inbox');
cy.get(`[data-cy=${cyShowTagsDialog}]`).click();
Expand Down
13 changes: 1 addition & 12 deletions integration/ui/filter_conversation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
import {
cySearchButton,
cySearchField,
cyConversationList,
cyChannelsChatPluginAddButton,
cyChannelsChatPluginFormNameInput,
cyChannelsChatPluginFormSubmitButton,
cyChannelsFormBackButton,
cyConnectorsAddNewButton,
} from 'handles';

import {cyInputbarButton, cyInputbarTextarea} from 'chat-plugin-handles';
import {cySearchButton, cySearchField, cyConversationList} from 'handles';

describe('Filter conversation', () => {
it('Filter conversation', () => {
Expand Down
2 changes: 1 addition & 1 deletion integration/ui/suggested_replies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('adds two suggested replies to a message and sends one of the suggested
cy.visit(`/inbox/inbox/conversations/${Cypress.env('conversationId')}`);
cy.url().should('include', '/inbox');

cy.get(`[data-cy=${cySuggestionsButton}]`).should('be.visible').click();
cy.get(`[data-cy=${cySuggestionsButton}]`).first().click({force: true});

cy.get(`[data-cy=${cySuggestionsList}]`).contains('Welcome!').click({force: true});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ type ModalHeaderProps = {
close: (event: React.MouseEvent<HTMLButtonElement>) => void;
headerClassName: string;
style: CSSProperties;
dataCyCloseButton?: string;
};

const ModalHeader = ({title, close, headerClassName, style}: ModalHeaderProps) => {
const ModalHeader = ({title, close, headerClassName, style, dataCyCloseButton}: ModalHeaderProps) => {
return (
<div className={styles.modalHeader}>
<button className={styles.closeButton} onClick={close}>
<button className={styles.closeButton} onClick={close} data-cy={dataCyCloseButton}>
<CloseIcon className={styles.closeIcon} title="Close" />
</button>
<div style={style} className={`${styles.headline} ${headerClassName}`}>
Expand Down
21 changes: 19 additions & 2 deletions lib/typescript/components/alerts/SettingsModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,21 @@ type SettingsModalProps = {
Icon?: React.ReactElement | null;
headerClassName?: string;
style?: CSSProperties;
dataCyCloseButton?: string;
};

export const SettingsModal = (props: SettingsModalProps) => {
const {close, title, children, headerClassName, wrapperClassName, style, containerClassName, Icon} = props;
const {
close,
title,
children,
headerClassName,
wrapperClassName,
style,
containerClassName,
Icon,
dataCyCloseButton,
} = props;
return (
<Modal
className={`${styles.content} ${wrapperClassName}`}
Expand All @@ -29,7 +40,13 @@ export const SettingsModal = (props: SettingsModalProps) => {
>
<div className={containerClassName}>
{Icon ? Icon : ''}
<ModalHeader title={title ?? ''} close={close} style={style} headerClassName={headerClassName} />
<ModalHeader
title={title ?? ''}
close={close}
style={style}
headerClassName={headerClassName}
dataCyCloseButton={dataCyCloseButton}
/>
{children}
</div>
</Modal>
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
},
"include": [
"./frontend/**/*",
"./lib/typescript/**/*"
"./lib/typescript/**/*",
],
"types": ["node", "jest", "@testing-library/jest-dom"],
"types": ["node", "@testing-library/jest-dom", "jest", "./integration/commands/index.ts"],
"rootDirs": ["."]
}