Skip to content

Commit

Permalink
feat: implement item login and tags
Browse files Browse the repository at this point in the history
  • Loading branch information
pyphilia committed Apr 23, 2021
1 parent 031f6af commit 42d0b0f
Show file tree
Hide file tree
Showing 67 changed files with 1,895 additions and 265 deletions.
232 changes: 194 additions & 38 deletions cypress/fixtures/items.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { ITEM_TYPES } from '../../src/config/constants';
import { CURRENT_USER } from './members';
import {
ITEM_TYPES,
PERMISSION_LEVELS,
SETTINGS,
} from '../../src/config/constants';
import { buildItemLoginSchemaExtra } from '../../src/utils/itemExtra';
import { CURRENT_USER, MEMBERS } from './members';
import { DEFAULT_TAGS, ITEM_LOGIN_TAG } from './tags';

const DEFAULT_ITEM = {
description: '',
Expand All @@ -22,43 +28,193 @@ export const EDITED_FIELDS = {
description: 'new description',
};

export const SAMPLE_ITEMS = [
{
...DEFAULT_ITEM,
id: 'ecafbd2a-5688-11eb-ae93-0242ac130002',
name: 'own_item_name1',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002',
extra: {
image: 'someimageurl',
export const SAMPLE_ITEMS = {
items: [
{
...DEFAULT_ITEM,
id: 'ecafbd2a-5688-11eb-ae93-0242ac130002',
name: 'own_item_name1',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002',
extra: {
image: 'someimageurl',
},
},
},
{
...DEFAULT_ITEM,
id: 'fdf09f5a-5688-11eb-ae93-0242ac130002',
name: 'own_item_name2',
path: 'fdf09f5a_5688_11eb_ae93_0242ac130002',
extra: {
image: 'someimageurl',
{
...DEFAULT_ITEM,
id: 'fdf09f5a-5688-11eb-ae93-0242ac130002',
name: 'own_item_name2',
path: 'fdf09f5a_5688_11eb_ae93_0242ac130002',
extra: {
image: 'someimageurl',
},
},
},
{
...DEFAULT_ITEM,
id: 'fdf09f5a-5688-11eb-ae93-0242ac130003',
name: 'own_item_name3',
path:
'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130003',
extra: {
image: 'someimageurl',
{
...DEFAULT_ITEM,
id: 'fdf09f5a-5688-11eb-ae93-0242ac130003',
name: 'own_item_name3',
path:
'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130003',
extra: {
image: 'someimageurl',
},
},
},
{
...DEFAULT_ITEM,
id: 'fdf09f5a-5688-11eb-ae93-0242ac130004',
name: 'own_item_name4',
path:
'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130004',
extra: {
image: 'someimageurl',
{
...DEFAULT_ITEM,
id: 'fdf09f5a-5688-11eb-ae93-0242ac130004',
name: 'own_item_name4',
path:
'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130004',
extra: {
image: 'someimageurl',
},
},
},
];
],
memberships: [],
};

export const ITEM_LOGIN_ITEMS = {
items: [
{
...DEFAULT_ITEM,
id: 'ecafbd2a-5688-11eb-ae93-0242ac130002',
name: 'item login with username',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002',
extra: {
image: 'someimageurl',
...buildItemLoginSchemaExtra(SETTINGS.ITEM_LOGIN.OPTIONS.USERNAME),
},
tags: [
{
tagId: ITEM_LOGIN_TAG.id,
itemPath: 'ecafbd2a_5688_11eb_ae93_0242ac130002',
},
],
memberships: [
{
itemPath: 'fdf09f5a_5688_11eb_ae93_0242ac130002',
permission: PERMISSION_LEVELS.ADMIN,
memberId: MEMBERS.ANNA.id,
},
{
itemPath: 'fdf09f5a_5688_11eb_ae93_0242ac130002',
permission: PERMISSION_LEVELS.READ,
memberId: MEMBERS.BOB.id,
},
],
},
{
...DEFAULT_ITEM,
id: 'fdf09f5a-5688-11eb-ae93-0242ac130002',
name: 'no item login',
path: 'fdf09f5a_5688_11eb_ae93_0242ac130002',
extra: {
image: 'someimageurl',
},
memberships: [
{
itemPath: 'fdf09f5a_5688_11eb_ae93_0242ac130002',
permission: PERMISSION_LEVELS.ADMIN,
memberId: MEMBERS.ANNA.id,
},
],
},
{
...DEFAULT_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',
extra: {
image: 'someimageurl',
},
memberships: [
{
itemId: 'fdf09f5a-5688-11eb-ae93-0242ac130003',
itemPath: 'fdf09f5a_5688_11eb_ae93_0242ac130002',
permission: PERMISSION_LEVELS.ADMIN,
memberId: MEMBERS.ANNA.id,
},
],
},
{
...DEFAULT_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',
extra: {
image: 'someimageurl',
...buildItemLoginSchemaExtra(
SETTINGS.ITEM_LOGIN.OPTIONS.USERNAME_AND_PASSWORD,
),
},
tags: [
{
tagId: ITEM_LOGIN_TAG.id,
itemPath:
'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130004',
},
],
memberships: [
{
itemPath: 'fdf09f5a_5688_11eb_ae93_0242ac130002',
permission: PERMISSION_LEVELS.ADMIN,
memberId: MEMBERS.ANNA.id,
},
{
itemPath: 'fdf09f5a_5688_11eb_ae93_0242ac130002',
permission: PERMISSION_LEVELS.READ,
memberId: MEMBERS.BOB.id,
},
],
},
{
...DEFAULT_ITEM,
id: 'egafbd2a-5688-11eb-ae93-0242ac130002',
name: 'item login with username and password',
path: 'egafbd2a_5688_11eb_ae93_0242ac130002',
extra: {
image: 'someimageurl',
...buildItemLoginSchemaExtra(
SETTINGS.ITEM_LOGIN.OPTIONS.USERNAME_AND_PASSWORD,
),
},
tags: [
{
tagId: ITEM_LOGIN_TAG.id,
itemPath: 'egafbd2a_5688_11eb_ae93_0242ac130002',
},
],
memberships: [
{
itemPath: 'fdf09f5a_5688_11eb_ae93_0242ac130002',
permission: PERMISSION_LEVELS.ADMIN,
memberId: MEMBERS.ANNA.id,
},
],
},
{
...DEFAULT_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',
tags: [
{
tagId: ITEM_LOGIN_TAG.id,
itemPath:
'ecafbd2a_5688_11eb_ae93_0242ac130002.fdf09f5a_5688_11eb_ae93_0242ac130004',
},
],
memberships: [
{
itemId: 'bdf09f5a-5688-11eb-ae93-0242ac130004',
itemPath: 'bdf09f5a_5688_11eb_ae93_0242ac130004',
permission: PERMISSION_LEVELS.ADMIN,
memberId: MEMBERS.ANNA.id,
},
],
},
],
tags: DEFAULT_TAGS,
};
4 changes: 4 additions & 0 deletions cypress/fixtures/links.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ITEM_TYPES } from '../../src/config/constants';
import { CURRENT_USER } from './members';
import { buildEmbeddedLinkExtra } from '../../src/utils/itemExtra';

export const GRAASP_LINK_ITEM = {
Expand All @@ -7,6 +8,7 @@ export const GRAASP_LINK_ITEM = {
name: 'graasp link',
description: 'a description for graasp link',
path: 'ecafbd2a_5688_11eb_ae93_0242ac130002',
creator: CURRENT_USER.id,
extra: buildEmbeddedLinkExtra({
url: 'https://graasp.eu',
thumbnails: ['https://graasp.eu/img/epfl/logo-tile.png'],
Expand All @@ -21,6 +23,7 @@ export const YOUTUBE_LINK_ITEM = {
type: ITEM_TYPES.LINK,
name: 'graasp youtube link',
description: 'a description for graasp youtube link',
creator: CURRENT_USER.id,
path: 'gcafbd2a_5688_11eb_ae93_0242ac130002',
extra: buildEmbeddedLinkExtra({
url: 'https://www.youtube.com/watch?v=FmiEgBMTPLo',
Expand All @@ -33,6 +36,7 @@ export const YOUTUBE_LINK_ITEM = {

export const INVALID_LINK_ITEM = {
type: ITEM_TYPES.LINK,
creator: CURRENT_USER.id,
name: 'graasp youtube link',
description: 'a description for graasp youtube link',
extra: buildEmbeddedLinkExtra({
Expand Down
8 changes: 8 additions & 0 deletions cypress/fixtures/tags.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { SETTINGS } from '../../src/config/constants';

export const ITEM_LOGIN_TAG = {
id: 'item-login-tag-id',
name: SETTINGS.ITEM_LOGIN.name,
};

export const DEFAULT_TAGS = [ITEM_LOGIN_TAG];
14 changes: 5 additions & 9 deletions cypress/integration/authentication.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
import {
HEADER_APP_BAR_ID,
HEADER_USER_ID,
ITEM_MAIN_CLASS,
USER_MENU_SIGN_OUT_OPTION_ID,
} from '../../src/config/selectors';
import { SAMPLE_ITEMS } from '../fixtures/items';
Expand All @@ -19,7 +20,7 @@ import {
describe('Authentication', () => {
describe('Signed Off > Redirect to sign in route', () => {
beforeEach(() => {
cy.setUpApi({ items: SAMPLE_ITEMS, getCurrentMemberError: true });
cy.setUpApi({ ...SAMPLE_ITEMS, getCurrentMemberError: true });
});
it('Home', () => {
cy.visit(HOME_PATH);
Expand All @@ -31,16 +32,11 @@ describe('Authentication', () => {
cy.wait(REQUEST_FAILURE_LOADING_TIME);
cy.get('html').should('contain', REDIRECTION_CONTENT);
});
it('Item', () => {
cy.visit(buildItemPath(SAMPLE_ITEMS[0].id));
cy.wait(REQUEST_FAILURE_LOADING_TIME);
cy.get('html').should('contain', REDIRECTION_CONTENT);
});
});

describe('Signed In', () => {
beforeEach(() => {
cy.setUpApi({ items: SAMPLE_ITEMS });
cy.setUpApi(SAMPLE_ITEMS);
});

it('Signing Off redirect to sign in route', () => {
Expand All @@ -64,9 +60,9 @@ describe('Authentication', () => {
cy.get(`#${HEADER_APP_BAR_ID}`).should('exist');
});
it('Item', () => {
cy.visit(buildItemPath(SAMPLE_ITEMS[0].id));
cy.wait(PAGE_LOAD_WAITING_PAUSE);
cy.visit(buildItemPath(SAMPLE_ITEMS.items[0].id));
cy.get(`#${HEADER_APP_BAR_ID}`).should('exist');
cy.get(`.${ITEM_MAIN_CLASS}`).should('exist');
});
});

Expand Down
Loading

0 comments on commit 42d0b0f

Please sign in to comment.