Skip to content

Commit

Permalink
fix: update buildGetMembersBy, apply prettier on cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
codeofmochi committed Aug 16, 2022
1 parent d4a9fde commit 23b3de3
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 50 deletions.
2 changes: 1 addition & 1 deletion cypress/fixtures/documents.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ export const GRAASP_DOCUMENT_ITEM_PUBLIC_HIDDEN = {
tagId: PUBLIC_TAG_ID,
},
],
};
};
7 changes: 6 additions & 1 deletion cypress/fixtures/items.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { ITEM_TYPES } from '../../src/enums';
import {
GRAASP_DOCUMENT_ITEM_HIDDEN,
GRAASP_DOCUMENT_ITEM_PUBLIC_HIDDEN,
GRAASP_DOCUMENT_ITEM_PUBLIC_VISIBLE,
GRAASP_DOCUMENT_ITEM_VISIBLE,
} from './documents';
import { CURRENT_USER } from './members';
import { GRAASP_DOCUMENT_ITEM_VISIBLE, GRAASP_DOCUMENT_ITEM_HIDDEN, GRAASP_DOCUMENT_ITEM_PUBLIC_VISIBLE, GRAASP_DOCUMENT_ITEM_PUBLIC_HIDDEN } from './documents'

const PUBLIC_TAG_ID = Cypress.env('PUBLIC_TAG_ID');

Expand Down
2 changes: 1 addition & 1 deletion cypress/fixtures/links.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ITEM_TYPES } from '../../src/enums';
import { CURRENT_USER } from './members';
import { buildEmbeddedLinkExtra } from '../../src/utils/itemExtra';
import { CURRENT_USER } from './members';

export const GRAASP_LINK_ITEM = {
id: 'ecafbd2a-5688-11eb-ae91-0242ac130002',
Expand Down
2 changes: 1 addition & 1 deletion cypress/fixtures/useCases/staticElectricity.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ITEM_TYPES } from '../../../src/enums';
import { CURRENT_USER } from '../members';
import {
buildAppExtra,
buildDocumentExtra,
buildEmbeddedLinkExtra,
buildFileExtra,
} from '../../../src/utils/itemExtra';
import { CURRENT_USER } from '../members';

const PUBLIC_TAG_ID = Cypress.env('PUBLIC_TAG_ID');

Expand Down
4 changes: 2 additions & 2 deletions cypress/integration/chatbox.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { buildMainPath } from '../../src/config/paths';
import { ITEM_WITHOUT_CHAT_BOX, ITEM_WITH_CHAT_BOX } from '../fixtures/items';
import {
ITEM_CHATBOX_ID,
ITEM_CHATBOX_BUTTON_ID,
ITEM_CHATBOX_ID,
PANNEL_CLOSE_BUTTON_ID,
} from '../../src/config/selectors';
import { LOAD_CHATBOX_PAUSE } from '../fixtures/constants';
import { ITEM_WITHOUT_CHAT_BOX, ITEM_WITH_CHAT_BOX } from '../fixtures/items';

describe('Chatbox', () => {
beforeEach(() => {
Expand Down
14 changes: 7 additions & 7 deletions cypress/integration/hidden.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { buildMainPath } from '../../src/config/paths';
import { FOLDER_WITH_HIDDEN_ITEMS } from '../fixtures/items';
import { buildDocumentId } from '../../src/config/selectors';
import { FOLDER_WITH_HIDDEN_ITEMS } from '../fixtures/items';

describe('Hidden Items', () => {
it("Don't display Hidden items", () => {
Expand All @@ -11,12 +11,12 @@ describe('Hidden Items', () => {
const parent = FOLDER_WITH_HIDDEN_ITEMS.items[0];
cy.visit(buildMainPath({ rootId: parent.id, id: null }));

cy.get(
`#${buildDocumentId(FOLDER_WITH_HIDDEN_ITEMS.items[1].id)}`,
).should('exist');
cy.get(
`#${buildDocumentId(FOLDER_WITH_HIDDEN_ITEMS.items[2].id)}`,
).should('not.exist');
cy.get(`#${buildDocumentId(FOLDER_WITH_HIDDEN_ITEMS.items[1].id)}`).should(
'exist',
);
cy.get(`#${buildDocumentId(FOLDER_WITH_HIDDEN_ITEMS.items[2].id)}`).should(
'not.exist',
);
});

// todo: uncomment when public tags are implemented
Expand Down
30 changes: 15 additions & 15 deletions cypress/integration/main.spec.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { buildMainPath } from '../../src/config/paths';
import { GRAASP_LINK_ITEM, YOUTUBE_LINK_ITEM } from '../fixtures/links';
import {
expectDocumentViewScreenLayout,
expectFileViewScreenLayout,
expectLinkViewScreenLayout,
expectAppViewScreenLayout,
expectFolderButtonLayout,
expectFolderLayout,
} from '../support/integrationUtils';
FOLDER_NAME_TITLE_CLASS,
MAIN_MENU_ID,
} from '../../src/config/selectors';
import { GRAASP_APP_ITEM } from '../fixtures/apps';
import { GRAASP_DOCUMENT_ITEM } from '../fixtures/documents';
import {
IMAGE_ITEM_DEFAULT,
PDF_ITEM_DEFAULT,
VIDEO_ITEM_DEFAULT,
} from '../fixtures/files';
import { GRAASP_DOCUMENT_ITEM } from '../fixtures/documents';
import { GRAASP_APP_ITEM } from '../fixtures/apps';
import { FOLDER_WITH_SUBFOLDER_ITEM } from '../fixtures/items';
import {
FOLDER_NAME_TITLE_CLASS,
MAIN_MENU_ID,
} from '../../src/config/selectors';
import { GRAASP_LINK_ITEM, YOUTUBE_LINK_ITEM } from '../fixtures/links';
import { MEMBERS } from '../fixtures/members';
import {
PUBLIC_STATIC_ELECTRICITY,
STATIC_ELECTRICITY,
} from '../fixtures/useCases/staticElectricity';
import { MEMBERS } from '../fixtures/members';
import {
expectAppViewScreenLayout,
expectDocumentViewScreenLayout,
expectFileViewScreenLayout,
expectFolderButtonLayout,
expectFolderLayout,
expectLinkViewScreenLayout,
} from '../support/integrationUtils';

describe('Main Screen', () => {
describe('Individual Items', () => {
Expand Down
10 changes: 5 additions & 5 deletions cypress/integration/pinned.spec.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { buildMainPath } from '../../src/config/paths';
import {
FOLDER_WITH_SUBFOLDER_ITEM,
FOLDER_WITH_PINNED_ITEMS,
PUBLIC_FOLDER_WITH_PINNED_ITEMS,
} from '../fixtures/items';
import {
ITEM_PINNED_BUTTON_ID,
ITEM_PINNED_ID,
buildFolderButtonId,
} from '../../src/config/selectors';
import {
FOLDER_WITH_PINNED_ITEMS,
FOLDER_WITH_SUBFOLDER_ITEM,
PUBLIC_FOLDER_WITH_PINNED_ITEMS,
} from '../fixtures/items';
import { MEMBERS } from '../fixtures/members';

describe('Pinned Items', () => {
Expand Down
3 changes: 2 additions & 1 deletion cypress/integration/ws.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { WebSocket } from '@graasp/websockets/test/mock-client';

import { buildMainPath } from '../../src/config/paths';
import {
buildFolderButtonId,
FOLDER_NAME_TITLE_CLASS,
buildFolderButtonId,
} from '../../src/config/selectors';
import { FOLDER_WITH_SUBFOLDER_ITEM } from '../fixtures/items';
import { expectFolderButtonLayout } from '../support/integrationUtils';
Expand Down
1 change: 0 additions & 1 deletion cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// eslint-disable-next-line import/no-extraneous-dependencies
import '@cypress/code-coverage/support';

Expand Down
16 changes: 7 additions & 9 deletions cypress/support/integrationUtils.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import qs from 'qs';

import {
MAIN_MENU_ID,
buildFileId,
buildDocumentId,
buildAppId,
buildDocumentId,
buildFileId,
buildTreeItemClass,
} from '../../src/config/selectors';
import { ITEM_TYPES, MIME_TYPES } from '../../src/enums';
import { getDirectParentId } from '../../src/utils/item';
import {
getDocumentExtra,
getEmbeddedLinkExtra,
getFileExtra,
getS3FileExtra,
} from '../../src/utils/itemExtra';
import { getDirectParentId } from '../../src/utils/item';
import { LOAD_FOLDER_CONTENT_PAUSE } from './constants';

export const expectLinkViewScreenLayout = ({ id, extra }) => {
Expand All @@ -30,7 +31,6 @@ export const expectLinkViewScreenLayout = ({ id, extra }) => {
} else {
cy.get(`iframe#${id}`).should('have.attr', 'src', url);
}

};

export const expectAppViewScreenLayout = ({ id, extra }) => {
Expand All @@ -44,7 +44,6 @@ export const expectAppViewScreenLayout = ({ id, extra }) => {
)}`;

cy.get(`iframe#${buildAppId(id)}`).should('have.attr', 'src', appUrl);

};

export const expectFileViewScreenLayout = ({ id, extra }) => {
Expand All @@ -61,7 +60,6 @@ export const expectFileViewScreenLayout = ({ id, extra }) => {
selector = `embed#${buildFileId(id)}`;
}
cy.get(selector).should('exist');

};

export const expectDocumentViewScreenLayout = ({ id, extra }) => {
Expand All @@ -71,9 +69,9 @@ export const expectDocumentViewScreenLayout = ({ id, extra }) => {
};

export const expectFolderButtonLayout = ({ name }) => {
// mainmenu
const menu = cy.get(`#${MAIN_MENU_ID}`);
menu.get(`#${MAIN_MENU_ID}`).contains(name);
// mainmenu
const menu = cy.get(`#${MAIN_MENU_ID}`);
menu.get(`#${MAIN_MENU_ID}`).contains(name);
};

export const expectFolderLayout = ({ rootId, items }) => {
Expand Down
10 changes: 6 additions & 4 deletions cypress/support/server.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { StatusCodes } from 'http-status-codes';
import qs from 'qs';

import { API_ROUTES } from '@graasp/query-client';
import { getItemById, isChild, isError } from '../../src/utils/item';
import { MEMBERS } from '../fixtures/members';
import { ID_FORMAT, parseStringToRegExp, EMAIL_FORMAT } from './utils';

import { DEFAULT_GET } from '../../src/api/utils';
import { MEMBER_PROFILE_PATH } from '../../src/config/constants';
import { getItemById, isChild, isError } from '../../src/utils/item';
import { MEMBERS } from '../fixtures/members';
import { EMAIL_FORMAT, ID_FORMAT, parseStringToRegExp } from './utils';

const {
buildGetChildrenRoute,
buildGetItemRoute,
buildGetMemberBy,
buildGetMembersBy,
buildGetItemTagsRoute,
GET_CURRENT_MEMBER_ROUTE,
buildDownloadFilesRoute,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"dist:dev": "env-cmd -f ./.env.development react-scripts build",
"eject": "react-scripts eject",
"lint": "eslint .",
"prettier:check": "prettier --check src/**/*.js",
"prettier:write": "prettier --write src/**/*.js",
"prettier:check": "prettier --check {src,cypress}/**/*.js",
"prettier:write": "prettier --write {src,cypress}/**/*.js",
"hooks:uninstall": "husky uninstall",
"hooks:install": "husky install",
"cypress:open": "env-cmd -f ./.env.test cypress open",
Expand Down

0 comments on commit 23b3de3

Please sign in to comment.