Skip to content

Commit

Permalink
fix: fixtures use constants string instead of env var
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-Torrent committed Jan 13, 2022
1 parent 0ca684e commit b5af0eb
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 43 deletions.
4 changes: 4 additions & 0 deletions cypress/fixtures/itemTags.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export const ITEM_PUBLISHED_TAG = {
name: SETTINGS.ITEM_PUBLISHED.name,
};

export const ITEM_HIDDEN_TAG = {
id: '12345678-1234-1234-1234-123456789012',
};

export const DEFAULT_TAGS = [
ITEM_LOGIN_TAG,
ITEM_PUBLIC_TAG,
Expand Down
53 changes: 19 additions & 34 deletions cypress/fixtures/items.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { HIDDEN_ITEM_TAG_ID, SETTINGS } from '../../src/config/constants';
import { SETTINGS } from '../../src/config/constants';
import { ITEM_TYPES, PERMISSION_LEVELS } from '../../src/enums';
import { buildItemLoginSchemaExtra } from '../../src/utils/itemExtra';
import {
DEFAULT_TAGS,
ITEM_HIDDEN_TAG,
ITEM_LOGIN_TAG,
ITEM_PUBLIC_TAG,
ITEM_PUBLISHED_TAG,
Expand Down Expand Up @@ -70,8 +71,7 @@ export const SAMPLE_ITEMS = {
...DEFAULT_FOLDER_ITEM,
id: 'fdf09f5a-5688-11eb-ae93-0242ac130003',
name: 'own_item_name3',
path:
'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130003',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130003',
extra: {
image: 'someimageurl',
},
Expand All @@ -87,8 +87,7 @@ export const SAMPLE_ITEMS = {
...DEFAULT_FOLDER_ITEM,
id: 'fdf09f5a-5688-11eb-ae93-0242ac130004',
name: 'own_item_name4',
path:
'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130004',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130004',
extra: {
image: 'someimageurl',
},
Expand All @@ -104,8 +103,7 @@ export const SAMPLE_ITEMS = {
...DEFAULT_FOLDER_ITEM,
id: 'fdf09f5a-5688-11eb-ae93-0242ac130005',
name: 'own_item_name5',
path:
'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130005',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130005',
extra: {
image: 'someimageurl',
},
Expand Down Expand Up @@ -211,8 +209,7 @@ export const ITEM_LOGIN_ITEMS = {
...DEFAULT_FOLDER_ITEM,
id: 'fdf09f5a-5688-11eb-ae93-0242ac130003',
name: 'child of item login with username',
path:
'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130003',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130003',
extra: {
image: 'someimageurl',
},
Expand All @@ -229,8 +226,7 @@ export const ITEM_LOGIN_ITEMS = {
...DEFAULT_FOLDER_ITEM,
id: 'fdf09f5a-5688-11eb-ae93-0242ac130004',
name: 'item login with username and password',
path:
'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130004',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130004',
extra: {
image: 'someimageurl',
...buildItemLoginSchemaExtra(
Expand Down Expand Up @@ -286,8 +282,7 @@ export const ITEM_LOGIN_ITEMS = {
...DEFAULT_FOLDER_ITEM,
id: 'bdf09f5a-5688-11eb-ae93-0242ac130004',
name: 'child of item login with username and password',
path:
'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130004.bdf09f5a_5688_11eb_ae93_0242ac130004',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130004.bdf09f5a_5688_11eb_ae93_0242ac130004',
tags: [
{
tagId: ITEM_LOGIN_TAG.id,
Expand Down Expand Up @@ -358,8 +353,7 @@ export const SAMPLE_PUBLIC_ITEMS = {
...DEFAULT_FOLDER_ITEM,
id: 'fdf09f5a-5688-11eb-ae93-0242ac130003',
name: 'child of public item',
path:
'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130003',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130003',
extra: {
image: 'someimageurl',
},
Expand All @@ -376,8 +370,7 @@ export const SAMPLE_PUBLIC_ITEMS = {
...DEFAULT_FOLDER_ITEM,
id: 'fdf09f5a-5688-11eb-ae93-0242ac130004',
name: 'public item',
path:
'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130004',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130004',
extra: {
image: 'someimageurl',
},
Expand Down Expand Up @@ -420,8 +413,7 @@ export const SAMPLE_PUBLIC_ITEMS = {
...DEFAULT_FOLDER_ITEM,
id: 'bdf09f5a-5688-11eb-ae93-0242ac130004',
name: 'child of public item',
path:
'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130004.bdf09f5a_5688_11eb_ae93_0242ac130004',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130004.bdf09f5a_5688_11eb_ae93_0242ac130004',
tags: [
{
tagId: ITEM_PUBLIC_TAG.id,
Expand All @@ -442,8 +434,7 @@ export const SAMPLE_PUBLIC_ITEMS = {
...DEFAULT_FOLDER_ITEM,
id: 'fdf09f5a-5688-11eb-ae93-0242ac133002',
name: 'child of private item',
path:
'fdf09f5a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac133002',
path: 'fdf09f5a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac133002',
extra: {
image: 'someimageurl',
},
Expand Down Expand Up @@ -478,8 +469,7 @@ export const ITEM_REORDER_ITEMS = {
...DEFAULT_FOLDER_ITEM,
id: 'fdf09f5a-5688-11eb-ae93-0242ac130003',
name: 'child1',
path:
'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130003',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130003',
extra: {
image: 'someimageurl',
},
Expand All @@ -488,8 +478,7 @@ export const ITEM_REORDER_ITEMS = {
...DEFAULT_FOLDER_ITEM,
id: 'fdf09f5a-5688-11eb-ae93-0242ac130004',
name: 'child2',
path:
'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130004',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130004',
extra: {
image: 'someimageurl',
},
Expand All @@ -498,8 +487,7 @@ export const ITEM_REORDER_ITEMS = {
...DEFAULT_FOLDER_ITEM,
id: 'fdf09f5a-5688-11eb-ae93-0242ac130005',
name: 'child3',
path:
'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130005',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130005',
extra: {
image: 'someimageurl',
},
Expand Down Expand Up @@ -531,8 +519,7 @@ export const ORDERED_ITEMS = {
...DEFAULT_FOLDER_ITEM,
id: 'adf09f5a-5688-11eb-ae93-0242ac130003',
name: 'child1',
path:
'ecafbd2a_5688_11eb_ae93_0242ac130002.adf09f5a_5688_11eb_ae93_0242ac130003',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002.adf09f5a_5688_11eb_ae93_0242ac130003',
extra: {
image: 'someimageurl',
},
Expand All @@ -541,8 +528,7 @@ export const ORDERED_ITEMS = {
...DEFAULT_FOLDER_ITEM,
id: 'adf09f5a-5688-11eb-ae93-0242ac130004',
name: 'child2',
path:
'ecafbd2a_5688_11eb_ae93_0242ac130002.adf09f5a_5688_11eb_ae93_0242ac130004',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002.adf09f5a_5688_11eb_ae93_0242ac130004',
extra: {
image: 'someimageurl',
},
Expand All @@ -551,8 +537,7 @@ export const ORDERED_ITEMS = {
...DEFAULT_FOLDER_ITEM,
id: 'adf09f5a-5688-11eb-ae93-0242ac130005',
name: 'child3',
path:
'ecafbd2a_5688_11eb_ae93_0242ac130002.adf09f5a_5688_11eb_ae93_0242ac130005',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002.adf09f5a_5688_11eb_ae93_0242ac130005',
extra: {
image: 'someimageurl',
},
Expand Down Expand Up @@ -616,7 +601,7 @@ export const HIDDEN_ITEM = {
},
{
id: 'ecbfbd2a-5688-12eb-ae93-0242ac130001',
tagId: HIDDEN_ITEM_TAG_ID,
tagId: ITEM_HIDDEN_TAG.id,
itemPath: 'ecafbd2a_5688_11eb_ae93_0242ac130001',
},
],
Expand Down
7 changes: 3 additions & 4 deletions cypress/integration/item/hide/hideItem.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {
} from '../../../../src/config/selectors';
import { TABLE_ITEM_RENDER_TIME } from '../../../support/constants';
import { ITEM_LAYOUT_MODES } from '../../../../src/enums';

const hiddenTagId = '12345678-1234-1234-1234-123456789012';
import { ITEM_HIDDEN_TAG } from '../../../fixtures/itemTags';

const toggleHideButton = (itemId) => {
cy.wait(TABLE_ITEM_RENDER_TIME);
Expand Down Expand Up @@ -40,7 +39,7 @@ describe('Hiding Item', () => {
body: { tagId },
},
}) => {
expect(tagId).to.equals(hiddenTagId);
expect(tagId).to.equals(ITEM_HIDDEN_TAG.id);
},
);
});
Expand Down Expand Up @@ -75,7 +74,7 @@ describe('Hiding Item', () => {
body: { tagId },
},
}) => {
expect(tagId).to.equals(hiddenTagId);
expect(tagId).to.equals(ITEM_HIDDEN_TAG.id);
},
);
});
Expand Down
7 changes: 4 additions & 3 deletions cypress/support/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ export const mockGetItemTags = (items) => {
},
({ reply, url }) => {
const itemId = url.slice(API_HOST.length).split('/')[2];
const result = items.find(({ id }) => id === itemId).tags || [];
const result = items.find(({ id }) => id === itemId)?.tags || [];
reply(result);
},
).as('getItemTags');
Expand Down Expand Up @@ -1195,8 +1195,9 @@ export const mockGetItemThumbnail = (items, shouldThrowError) => {
const id = link.slice(API_HOST.length).split('/')[3];
const { size } = qs.parse(querystrings);

const thumbnails = items.find(({ id: thisId }) => id === thisId)
?.thumbnails;
const thumbnails = items.find(
({ id: thisId }) => id === thisId,
)?.thumbnails;
if (!thumbnails) {
return reply({ statusCode: StatusCodes.NOT_FOUND });
}
Expand Down
3 changes: 2 additions & 1 deletion src/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
AUTHENTICATION_HOST: ENV_AUTHENTICATION_HOST,
NODE_ENV: ENV_NODE_ENV,
GA_MEASUREMENT_ID: ENV_GA_MEASUREMENT_ID,
HIDDEN_ITEM_TAG_ID: ENV_HIDDEN_ITEM_TAG_ID,
} = env;

export const APP_NAME = 'Graasp';
Expand Down Expand Up @@ -44,7 +45,7 @@ export const GA_MEASUREMENT_ID =
ENV_GA_MEASUREMENT_ID || process.env.REACT_APP_GA_MEASUREMENT_ID;

export const HIDDEN_ITEM_TAG_ID =
process.env.REACT_APP_HIDDEN_ITEM_TAG_ID || false;
ENV_HIDDEN_ITEM_TAG_ID || process.env.REACT_APP_HIDDEN_ITEM_TAG_ID || false;

export const DESCRIPTION_MAX_LENGTH = 30;

Expand Down
3 changes: 2 additions & 1 deletion src/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"AUTHENTICATION_HOST": false,
"NODE_ENV": false,
"GRAASP_PERFORM_HOST": false,
"GA_MEASUREMENT_ID": false
"GA_MEASUREMENT_ID": false,
"HIDDEN_ITEM_TAG_ID": false
}

0 comments on commit b5af0eb

Please sign in to comment.