Add test and fix a bug for project share button
This commit is contained in:
parent
bf01143e4c
commit
96b5fcbcd5
|
|
@ -108,5 +108,5 @@ export default {
|
||||||
RoomEntryNode: () => ({
|
RoomEntryNode: () => ({
|
||||||
title: 'A Room Entry',
|
title: 'A Room Entry',
|
||||||
contents: [],
|
contents: [],
|
||||||
}),
|
})
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,32 @@ import {PROJECT_ENTRY_TEMPLATE} from '../../../../src/consts/strings.consts';
|
||||||
describe('Project Page', () => {
|
describe('Project Page', () => {
|
||||||
const created = '2021-06-01T11:49:00+00:00';
|
const created = '2021-06-01T11:49:00+00:00';
|
||||||
const createdLater = '2021-06-01T12:49:00+00:00';
|
const createdLater = '2021-06-01T12:49:00+00:00';
|
||||||
|
let final = false;
|
||||||
|
|
||||||
|
const project = {
|
||||||
|
id: 'UHJvamVjdE5vZGU6MzY=',
|
||||||
|
title: 'Groot',
|
||||||
|
appearance: 'yellow',
|
||||||
|
description: 'I am Groot',
|
||||||
|
slug: 'groot',
|
||||||
|
objectives: 'Be Groot\nBe awesome',
|
||||||
|
final: false,
|
||||||
|
student: {
|
||||||
|
firstName: 'Rachel',
|
||||||
|
lastName: 'Green',
|
||||||
|
id: 'VXNlck5vZGU6NQ==',
|
||||||
|
avatarUrl: '',
|
||||||
|
},
|
||||||
|
entriesCount: 1,
|
||||||
|
entries: [
|
||||||
|
{
|
||||||
|
id: 'UHJvamVjdEVudHJ5Tm9kZTo2NQ==',
|
||||||
|
description: 'Aktivität:\nKill Thanos\n\n\nReflexion:\nHe sucks\n\n\nNächste Schritte:\nGo for the head',
|
||||||
|
documentUrl: '',
|
||||||
|
created,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
const operations = {
|
const operations = {
|
||||||
MeQuery: {
|
MeQuery: {
|
||||||
|
|
@ -32,30 +58,7 @@ describe('Project Page', () => {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
ProjectQuery: {
|
ProjectQuery: {
|
||||||
project: {
|
project,
|
||||||
id: 'UHJvamVjdE5vZGU6MzY=',
|
|
||||||
title: 'Groot',
|
|
||||||
appearance: 'yellow',
|
|
||||||
description: 'I am Groot',
|
|
||||||
slug: 'groot',
|
|
||||||
objectives: 'Be Groot\nBe awesome',
|
|
||||||
final: false,
|
|
||||||
student: {
|
|
||||||
firstName: 'Rachel',
|
|
||||||
lastName: 'Green',
|
|
||||||
id: 'VXNlck5vZGU6NQ==',
|
|
||||||
avatarUrl: '',
|
|
||||||
},
|
|
||||||
entriesCount: 1,
|
|
||||||
entries: [
|
|
||||||
{
|
|
||||||
id: 'UHJvamVjdEVudHJ5Tm9kZTo2NQ==',
|
|
||||||
description: 'Aktivität:\nKill Thanos\n\n\nReflexion:\nHe sucks\n\n\nNächste Schritte:\nGo for the head',
|
|
||||||
documentUrl: '',
|
|
||||||
created,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
AddProjectEntry: variables => ({
|
AddProjectEntry: variables => ({
|
||||||
addProjectEntry: {
|
addProjectEntry: {
|
||||||
|
|
@ -77,6 +80,16 @@ describe('Project Page', () => {
|
||||||
success: true,
|
success: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
UpdateProjectShareState: variables => {
|
||||||
|
final = !final;
|
||||||
|
return {
|
||||||
|
updateProjectSharedState: {
|
||||||
|
errors: null,
|
||||||
|
success: true,
|
||||||
|
shared: final,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
@ -103,6 +116,34 @@ describe('Project Page', () => {
|
||||||
cy.getByDataCy('edit-project').should('exist');
|
cy.getByDataCy('edit-project').should('exist');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('shares and unshares the project', () => {
|
||||||
|
const getOperationsForSharing = () => {
|
||||||
|
let projectForSharing = {
|
||||||
|
...project,
|
||||||
|
final,
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
...operations,
|
||||||
|
ProjectQuery: {
|
||||||
|
project: projectForSharing,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
cy.mockGraphqlOps({
|
||||||
|
operations: getOperationsForSharing,
|
||||||
|
});
|
||||||
|
|
||||||
|
cy.visit('/portfolio/groot');
|
||||||
|
const unsharedText = 'Mit Lehrperson teilen';
|
||||||
|
const sharedText = 'Nicht mehr teilen';
|
||||||
|
cy.getByDataCy('project-share-link').should('contain', unsharedText);
|
||||||
|
cy.getByDataCy('project-share-link').click();
|
||||||
|
cy.getByDataCy('project-share-link').should('contain', sharedText);
|
||||||
|
cy.getByDataCy('project-share-link').click();
|
||||||
|
cy.getByDataCy('project-share-link').should('contain', unsharedText);
|
||||||
|
});
|
||||||
|
|
||||||
describe('Project Entry', () => {
|
describe('Project Entry', () => {
|
||||||
it('should create a new project entry', () => {
|
it('should create a new project entry', () => {
|
||||||
cy.visit('/portfolio');
|
cy.visit('/portfolio');
|
||||||
|
|
@ -156,4 +197,5 @@ describe('Project Page', () => {
|
||||||
cy.getByDataCy('project-entry-textarea').should('have.value', PROJECT_ENTRY_TEMPLATE);
|
cy.getByDataCy('project-entry-textarea').should('have.value', PROJECT_ENTRY_TEMPLATE);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
})
|
||||||
|
;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<a class="share-icon">
|
<a class="share-icon">
|
||||||
<share-icon class="share-icon__icon"/>
|
<share-icon class="share-icon__icon"/>
|
||||||
<span class="share-icon__text">
|
<span class="share-icon__text">
|
||||||
<template v-if="final">Mit Lehrperson teilen</template>
|
<template v-if="!final">Mit Lehrperson teilen</template>
|
||||||
<template v-else>Nicht mehr teilen</template>
|
<template v-else>Nicht mehr teilen</template>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import {InMemoryCache, defaultDataIdFromObject} from 'apollo-cache-inmemory';
|
import {defaultDataIdFromObject, InMemoryCache} from 'apollo-cache-inmemory';
|
||||||
import {createHttpLink} from 'apollo-link-http';
|
import {createHttpLink} from 'apollo-link-http';
|
||||||
import {onError} from 'apollo-link-error';
|
import {onError} from 'apollo-link-error';
|
||||||
import {ApolloClient} from 'apollo-client';
|
import {ApolloClient} from 'apollo-client';
|
||||||
|
|
@ -13,18 +13,18 @@ const writeLocalCache = cache => {
|
||||||
data: {
|
data: {
|
||||||
scrollPosition: {
|
scrollPosition: {
|
||||||
__typename: 'ScrollPosition',
|
__typename: 'ScrollPosition',
|
||||||
scrollTo: ''
|
scrollTo: '',
|
||||||
},
|
},
|
||||||
sidebar: {
|
sidebar: {
|
||||||
__typename: 'Sidebar',
|
__typename: 'Sidebar',
|
||||||
profile: false,
|
profile: false,
|
||||||
navigation: false
|
navigation: false,
|
||||||
},
|
},
|
||||||
helloEmail: {
|
helloEmail: {
|
||||||
__typename: 'HelloEmail',
|
__typename: 'HelloEmail',
|
||||||
email: ''
|
email: '',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -35,8 +35,8 @@ export default function (uri, networkErrorCallback) {
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
fetch: fetch,
|
fetch: fetch,
|
||||||
headers: {
|
headers: {
|
||||||
'X-CSRFToken': document.cookie.replace(/(?:(?:^|.*;\s*)csrftoken\s*=\s*([^;]*).*$)|^.*$/, '$1')
|
'X-CSRFToken': document.cookie.replace(/(?:(?:^|.*;\s*)csrftoken\s*=\s*([^;]*).*$)|^.*$/, '$1'),
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const consoleLink = new ApolloLink((operation, forward) => {
|
const consoleLink = new ApolloLink((operation, forward) => {
|
||||||
|
|
@ -71,8 +71,8 @@ export default function (uri, networkErrorCallback) {
|
||||||
if (graphQLErrors) {
|
if (graphQLErrors) {
|
||||||
graphQLErrors.forEach(({message, locations, path}) =>
|
graphQLErrors.forEach(({message, locations, path}) =>
|
||||||
console.log(
|
console.log(
|
||||||
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
|
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`,
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,8 +106,16 @@ export default function (uri, networkErrorCallback) {
|
||||||
objective: (_, args, {getCacheKey}) => getCacheKey({__typename: 'ObjectiveNode', id: args.id}),
|
objective: (_, args, {getCacheKey}) => getCacheKey({__typename: 'ObjectiveNode', id: args.id}),
|
||||||
objectiveGroup: (_, args, {getCacheKey}) => getCacheKey({__typename: 'ObjectiveGroupNode', id: args.id}),
|
objectiveGroup: (_, args, {getCacheKey}) => getCacheKey({__typename: 'ObjectiveGroupNode', id: args.id}),
|
||||||
projectEntry: (_, args, {getCacheKey}) => getCacheKey({__typename: 'ProjectEntryNode', id: args.id}),
|
projectEntry: (_, args, {getCacheKey}) => getCacheKey({__typename: 'ProjectEntryNode', id: args.id}),
|
||||||
|
project: (_, args, {getCacheKey}) => {
|
||||||
|
console.log(args);
|
||||||
|
if (args.slug) {
|
||||||
|
return getCacheKey({__typename: 'ProjectNode', id: args.slug});
|
||||||
|
} else {
|
||||||
|
return getCacheKey({__typename: 'ProjectNode', id: args.id});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Monkey-patching in a fix for an open issue suggesting that
|
// TODO: Monkey-patching in a fix for an open issue suggesting that
|
||||||
|
|
@ -132,7 +140,7 @@ export default function (uri, networkErrorCallback) {
|
||||||
cache,
|
cache,
|
||||||
connectToDevTools: true,
|
connectToDevTools: true,
|
||||||
typeDefs,
|
typeDefs,
|
||||||
resolvers
|
resolvers,
|
||||||
});
|
});
|
||||||
client.onResetStore(() => {
|
client.onResetStore(() => {
|
||||||
writeLocalCache(cache);
|
writeLocalCache(cache);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
<div class="project__actions">
|
<div class="project__actions">
|
||||||
<share-link
|
<share-link
|
||||||
:final="project.final"
|
:final="project.final"
|
||||||
|
data-cy="project-share-link"
|
||||||
class="project__share"
|
class="project__share"
|
||||||
@click.native="updateProjectShareState(project.id, !project.final)" />
|
@click.native="updateProjectShareState(project.id, !project.final)" />
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue