diff --git a/cypress/fixtures/apps/apps.js b/cypress/fixtures/apps/apps.js new file mode 100644 index 000000000..d0c5e8be5 --- /dev/null +++ b/cypress/fixtures/apps/apps.js @@ -0,0 +1,10 @@ +// eslint-disable-next-line import/prefer-default-export +export const APPS_LIST = [ + { + name: "test", + url: "http://localhost.com:3333", + extra:{ + image: "https://pbs.twimg.com/profile_images/1300707321262346240/IsQAyu7q_400x400.jpg" + } + } +]; \ No newline at end of file diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 2151a955d..a86857062 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -11,6 +11,7 @@ import { MODE_LIST_BUTTON_ID, } from '../../src/config/selectors'; import { + mockGetAppListRoute, mockCopyItem, mockCopyItems, mockDeleteItem, @@ -65,6 +66,7 @@ import './commands/item'; import './commands/navigation'; import { CURRENT_USER, MEMBERS } from '../fixtures/members'; import { SAMPLE_FLAGS } from '../fixtures/flags'; +import { APPS_LIST } from '../fixtures/apps/apps'; Cypress.Commands.add( 'setUpApi', @@ -106,6 +108,8 @@ Cypress.Commands.add( const cachedMembers = JSON.parse(JSON.stringify(members)); const allItems = [...cachedItems, ...recycledItems]; + mockGetAppListRoute(APPS_LIST); + mockGetOwnItems(cachedItems); mockGetSharedItems({ items: cachedItems, member: currentMember }); diff --git a/cypress/support/commands/item.js b/cypress/support/commands/item.js index 348f98cae..2fd4eae7c 100644 --- a/cypress/support/commands/item.js +++ b/cypress/support/commands/item.js @@ -122,9 +122,8 @@ Cypress.Commands.add( ({ name = '', extra = {} }, { confirm = true } = {}) => { cy.fillBaseItemModal({ name }, { confirm: false }); - cy.get(`#${ITEM_FORM_APP_URL_ID}`).type( - `{selectall}${getAppExtra(extra)?.url}`, - ); + cy.get(`#${ITEM_FORM_APP_URL_ID}`).click(); + cy.get(`[data-value="${getAppExtra(extra)?.url}"]`).click(); if (confirm) { cy.get(`#${ITEM_FORM_CONFIRM_BUTTON_ID}`).click(); diff --git a/cypress/support/server.js b/cypress/support/server.js index ac9c8a9fb..e75961828 100644 --- a/cypress/support/server.js +++ b/cypress/support/server.js @@ -35,6 +35,7 @@ import { } from '../fixtures/apps'; const { + buildAppListRoute, buildCopyItemRoute, buildDeleteItemRoute, buildEditItemRoute, @@ -96,6 +97,19 @@ export const redirectionReply = { body: null, }; +export const mockGetAppListRoute = (apps) => { + cy.intercept( + { + method: DEFAULT_GET.method, + url: `${API_HOST}/${buildAppListRoute}`, + }, + (req) => { + req.reply(apps); + }, + ).as('useApps'); +}; + + export const mockGetCurrentMember = ( currentMember = MEMBERS.ANNA, shouldThrowError = false, diff --git a/src/components/item/form/AppForm.js b/src/components/item/form/AppForm.js index 44ebfc291..510ae91c2 100644 --- a/src/components/item/form/AppForm.js +++ b/src/components/item/form/AppForm.js @@ -6,6 +6,7 @@ import { InputLabel, Select, MenuItem, FormControl, makeStyles } from '@material import BaseItemForm from './BaseItemForm'; import { buildAppExtra, getAppExtra } from '../../../utils/itemExtra'; import { hooks } from '../../../config/queryClient'; +import { ITEM_FORM_APP_URL_ID } from '../../../config/selectors'; const useStyles = makeStyles((theme) => ({ img: { @@ -47,6 +48,7 @@ const AppForm = ({ onChange, item }) => { {t('App url')}