Fix frontend tests
This commit is contained in:
parent
484b7a45a6
commit
293bdd84ce
|
|
@ -0,0 +1,10 @@
|
||||||
|
export default {
|
||||||
|
username: '',
|
||||||
|
firstName: '',
|
||||||
|
lastName: '',
|
||||||
|
avatarUrl: '',
|
||||||
|
email: '',
|
||||||
|
onboardingVisited: true,
|
||||||
|
schoolClasses: {},
|
||||||
|
id: '',
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
export default {
|
||||||
|
UUID: () => '123-456-789',
|
||||||
|
GenericStreamFieldType: () => 'GenericStreamFieldType',
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
export default {
|
||||||
|
title: 'title',
|
||||||
|
metaTitle: 'metaTitle',
|
||||||
|
heroImage: 'heroImage',
|
||||||
|
teaser: 'teaser',
|
||||||
|
intro: 'intro',
|
||||||
|
assignments: {},
|
||||||
|
objectiveGroups: [],
|
||||||
|
id: '',
|
||||||
|
chapters: [],
|
||||||
|
};
|
||||||
|
|
@ -7,8 +7,7 @@
|
||||||
"length": 3,
|
"length": 3,
|
||||||
"sentenceOffset": 0,
|
"sentenceOffset": 0,
|
||||||
"affected": "Hir",
|
"affected": "Hir",
|
||||||
"corrected": "Dir",
|
"corrected": "Dir"
|
||||||
"__typename": "SpellCheckStepNode"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"sentence": "Hir ist ein Feler gewesen",
|
"sentence": "Hir ist ein Feler gewesen",
|
||||||
|
|
@ -16,8 +15,7 @@
|
||||||
"length": 5,
|
"length": 5,
|
||||||
"sentenceOffset": 0,
|
"sentenceOffset": 0,
|
||||||
"affected": "Feler",
|
"affected": "Feler",
|
||||||
"corrected": "Fehler",
|
"corrected": "Fehler"
|
||||||
"__typename": "SpellCheckStepNode"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"sentence": "Hir ist ein Feler gewesen",
|
"sentence": "Hir ist ein Feler gewesen",
|
||||||
|
|
@ -25,9 +23,7 @@
|
||||||
"length": 7,
|
"length": 7,
|
||||||
"sentenceOffset": 0,
|
"sentenceOffset": 0,
|
||||||
"affected": "gewesen",
|
"affected": "gewesen",
|
||||||
"corrected": "gewesen.",
|
"corrected": "gewesen."
|
||||||
"__typename": "SpellCheckStepNode"
|
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"__typename": "SpellCheckPayload"
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,6 @@
|
||||||
// import * as schema from '../fixtures/schema.json';
|
// import * as schema from '../fixtures/schema.json';
|
||||||
import {getModules, getMe} from '../../support/helpers';
|
import {getModules, getMe} from '../../support/helpers';
|
||||||
|
import mocks from '../../fixtures/mocks';
|
||||||
const mocks = {
|
|
||||||
UUID: () => 'Whatever',
|
|
||||||
GenericStreamFieldType: () => '',
|
|
||||||
};
|
|
||||||
|
|
||||||
const operations = {
|
const operations = {
|
||||||
MeQuery() {
|
MeQuery() {
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,19 @@
|
||||||
import minimalMe from '../../fixtures/me.minimal';
|
import minimalMe from '../../fixtures/me.minimal';
|
||||||
|
import module from '../../fixtures/module.minimal';
|
||||||
|
import mocks from '../../fixtures/mocks';
|
||||||
|
|
||||||
const me = isTeacher => ({
|
const me = isTeacher => ({
|
||||||
...minimalMe,
|
...minimalMe,
|
||||||
isTeacher,
|
isTeacher,
|
||||||
});
|
});
|
||||||
|
|
||||||
const module = () => ({
|
|
||||||
title: 'title',
|
|
||||||
metaTitle: 'metaTitle',
|
|
||||||
heroImage: 'heroImage',
|
|
||||||
teaser: 'teaser',
|
|
||||||
intro: 'intro',
|
|
||||||
assignments: {},
|
|
||||||
objectiveGroups: [],
|
|
||||||
id: '',
|
|
||||||
chapters: [],
|
|
||||||
});
|
|
||||||
|
|
||||||
const operations = isTeacher => ({
|
const operations = isTeacher => ({
|
||||||
operations: {
|
operations: {
|
||||||
MeQuery: {
|
MeQuery: {
|
||||||
me: me(isTeacher),
|
me: me(isTeacher),
|
||||||
},
|
},
|
||||||
ModuleDetailsQuery: {
|
ModuleDetailsQuery: {
|
||||||
module: module(),
|
module,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -35,10 +25,7 @@ describe('Snapshot', () => {
|
||||||
cy.task('getSchema').then(schema => {
|
cy.task('getSchema').then(schema => {
|
||||||
cy.mockGraphql({
|
cy.mockGraphql({
|
||||||
schema,
|
schema,
|
||||||
mocks: {
|
mocks,
|
||||||
UUID: () => '123-456-789',
|
|
||||||
GenericStreamFieldType: () => 'GenericStreamFieldType',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {mockUpdateLastModule} from '../../support/helpers';
|
import {mockUpdateLastModule} from '../../support/helpers';
|
||||||
|
import module from '../../fixtures/module.minimal';
|
||||||
|
|
||||||
const assignments = require('../../fixtures/assignments.json');
|
|
||||||
const module = require('../../fixtures/module.json');
|
|
||||||
const spellCheck = require('../../fixtures/spell-check.json');
|
const spellCheck = require('../../fixtures/spell-check.json');
|
||||||
|
|
||||||
const operations = {
|
const operations = {
|
||||||
|
|
@ -11,22 +10,128 @@ const operations = {
|
||||||
onboardingVisited: true,
|
onboardingVisited: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
AssignmentsQuery: {
|
AssignmentQuery: {
|
||||||
assignments,
|
assignment: {
|
||||||
|
id: '',
|
||||||
|
title: 'Ein Auftragstitel',
|
||||||
|
assignment: 'Ein Auftrag',
|
||||||
|
submission: {
|
||||||
|
id: 'U3R1ZGVudFN1Ym1pc3Npb25Ob2RlOjE=',
|
||||||
|
text: 'Hir ist ein Feler gewesen',
|
||||||
|
final: false,
|
||||||
|
document: '',
|
||||||
|
submissionFeedback: {
|
||||||
|
'id': 'U3VibWlzc2lvbkZlZWRiYWNrTm9kZTox',
|
||||||
|
'text': '\ud83d\ude42\ud83d\ude10\ud83e\udd2c\ud83d\udc4d\ud83e\udd22\ud83e\udd22\ud83e\udd22\ud83e\udd22\ud83d\ude2e\ud83e\udd17',
|
||||||
|
'teacher': {
|
||||||
|
'firstName': 'Nico',
|
||||||
|
'lastName': 'Zickgraf',
|
||||||
|
'__typename': 'UserNode',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
ModulesQuery: {
|
ModuleDetailsQuery: {
|
||||||
module,
|
module: {
|
||||||
|
...module,
|
||||||
|
assignments: [
|
||||||
|
{
|
||||||
|
'id': 'QXNzaWdubWVudE5vZGU6MQ==',
|
||||||
|
'title': 'Ein Auftragstitel',
|
||||||
|
'assignment': 'Ein Auftrag',
|
||||||
|
'solution': null,
|
||||||
|
'submission': {
|
||||||
|
'id': 'U3R1ZGVudFN1Ym1pc3Npb25Ob2RlOjE=',
|
||||||
|
'text': 'Hir ist ein Feler gewesen',
|
||||||
|
'final': false,
|
||||||
|
'document': '',
|
||||||
|
'submissionFeedback': {
|
||||||
|
'id': 'U3VibWlzc2lvbkZlZWRiYWNrTm9kZTox',
|
||||||
|
'text': '🙂😐🤬👍🤢🤢🤢🤢😮🤗',
|
||||||
|
'teacher': {
|
||||||
|
'firstName': 'Nico',
|
||||||
|
'lastName': 'Zickgraf',
|
||||||
|
'__typename': 'UserNode',
|
||||||
|
},
|
||||||
|
'__typename': 'SubmissionFeedbackNode',
|
||||||
|
},
|
||||||
|
'__typename': 'StudentSubmissionNode',
|
||||||
|
},
|
||||||
|
'__typename': 'AssignmentNode',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
chapters: [
|
||||||
|
{
|
||||||
|
'id': 'Q2hhcHRlck5vZGU6MTg=',
|
||||||
|
'title': '1.1 Lehrbeginn',
|
||||||
|
'description': 'Wie sieht Ihr Konsumverhalten aus?',
|
||||||
|
'bookmark': {
|
||||||
|
'note': {
|
||||||
|
'id': 'Tm90ZU5vZGU6Mg==',
|
||||||
|
'text': 'Chapter Chapter',
|
||||||
|
'__typename': 'NoteNode',
|
||||||
|
},
|
||||||
|
'__typename': 'ChapterBookmarkNode',
|
||||||
|
},
|
||||||
|
contentBlocks: [
|
||||||
|
{
|
||||||
|
'id': 'Q29udGVudEJsb2NrTm9kZToxOQ==',
|
||||||
|
'slug': 'assignment',
|
||||||
|
'title': 'Assignment',
|
||||||
|
'type': 'NORMAL',
|
||||||
|
'contents': [
|
||||||
|
{
|
||||||
|
'type': 'assignment',
|
||||||
|
'value': {
|
||||||
|
'title': 'Ein Auftragstitel',
|
||||||
|
'assignment': 'Ein Auftrag',
|
||||||
|
'id': 'QXNzaWdubWVudE5vZGU6MQ==',
|
||||||
|
},
|
||||||
|
'id': 'df8212ee-3e82-49fa-977e-c4b60789163e',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'userCreated': false,
|
||||||
|
'mine': false,
|
||||||
|
'bookmarks': [
|
||||||
|
{
|
||||||
|
'uuid': 'df8212ee-3e82-49fa-977e-c4b60789163e',
|
||||||
|
'note': {
|
||||||
|
'id': 'Tm90ZU5vZGU6Mw==',
|
||||||
|
'text': 'Noch eine Notiz',
|
||||||
|
'__typename': 'NoteNode',
|
||||||
|
},
|
||||||
|
'__typename': 'ContentBlockBookmarkNode',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'hiddenFor': [],
|
||||||
|
'visibleFor': [],
|
||||||
|
'__typename': 'ContentBlockNode',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
SpellCheck: {
|
SpellCheck: {
|
||||||
spellCheck,
|
spellCheck,
|
||||||
},
|
},
|
||||||
|
UpdateAssignment: {
|
||||||
|
updateAssignment: {
|
||||||
|
assignment: {
|
||||||
|
id: '',
|
||||||
|
title: 'title',
|
||||||
|
assignment: '',
|
||||||
|
solution: '',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
...mockUpdateLastModule(),
|
...mockUpdateLastModule(),
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('Spellcheck', () => {
|
describe('Spellcheck', () => {
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.server();
|
cy.server();
|
||||||
|
|
||||||
cy.task('getSchema').then(schema => {
|
cy.task('getSchema').then(schema => {
|
||||||
cy.mockGraphql({
|
cy.mockGraphql({
|
||||||
schema,
|
schema,
|
||||||
|
|
@ -40,9 +145,7 @@ describe('Spellcheck', () => {
|
||||||
cy.visit('/module/lohn-und-budget/');
|
cy.visit('/module/lohn-und-budget/');
|
||||||
|
|
||||||
cy.get('.spellcheck__correction').should('have.length', 0);
|
cy.get('.spellcheck__correction').should('have.length', 0);
|
||||||
|
|
||||||
cy.get('.submission-form-container__spellcheck').click();
|
cy.get('.submission-form-container__spellcheck').click();
|
||||||
|
|
||||||
cy.get('.spellcheck__correction').should('have.length', 3);
|
cy.get('.spellcheck__correction').should('have.length', 3);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ export const getMe = ({schoolClasses, teacher}) => {
|
||||||
'firstName': 'Rahel',
|
'firstName': 'Rahel',
|
||||||
'lastName': 'Cueni',
|
'lastName': 'Cueni',
|
||||||
'avatarUrl': '',
|
'avatarUrl': '',
|
||||||
'isTeacher': false,
|
'isTeacher': teacher,
|
||||||
'lastModule': {
|
'lastModule': {
|
||||||
'id': 'TW9kdWxlTm9kZToxNw==',
|
'id': 'TW9kdWxlTm9kZToxNw==',
|
||||||
'slug': 'lohn-und-budget',
|
'slug': 'lohn-und-budget',
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {mapGetters, mapActions} from 'vuex';
|
import {mapActions, mapGetters} from 'vuex';
|
||||||
import ASSIGNMENT_QUERY from '@/graphql/gql/queries/assignmentQuery.gql';
|
import ASSIGNMENT_QUERY from '@/graphql/gql/queries/assignmentQuery.gql';
|
||||||
import ME_QUERY from '@/graphql/gql/queries/meQuery.gql';
|
import ME_QUERY from '@/graphql/gql/queries/meQuery.gql';
|
||||||
import UPDATE_ASSIGNMENT_MUTATION from '@/graphql/gql/mutations/updateAssignmentMutation.gql';
|
import UPDATE_ASSIGNMENT_MUTATION from '@/graphql/gql/mutations/updateAssignmentMutation.gql';
|
||||||
|
|
@ -66,7 +66,7 @@
|
||||||
components: {
|
components: {
|
||||||
Solution,
|
Solution,
|
||||||
SubmissionForm,
|
SubmissionForm,
|
||||||
SpellCheck
|
SpellCheck,
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
|
|
@ -75,13 +75,13 @@
|
||||||
submission: this.initialSubmission(),
|
submission: this.initialSubmission(),
|
||||||
},
|
},
|
||||||
me: {
|
me: {
|
||||||
permissions: []
|
permissions: [],
|
||||||
},
|
},
|
||||||
inputType: 'text',
|
inputType: 'text',
|
||||||
unsaved: false,
|
unsaved: false,
|
||||||
saving: 0,
|
saving: 0,
|
||||||
corrections: '',
|
corrections: '',
|
||||||
spellcheckLoading: false
|
spellcheckLoading: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -98,7 +98,7 @@
|
||||||
},
|
},
|
||||||
solution() {
|
solution() {
|
||||||
return {
|
return {
|
||||||
text: this.assignment.solution
|
text: this.assignment.solution,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
id() {
|
id() {
|
||||||
|
|
@ -107,7 +107,7 @@
|
||||||
feedbackText() {
|
feedbackText() {
|
||||||
let feedback = this.assignment.submission.submissionFeedback;
|
let feedback = this.assignment.submission.submissionFeedback;
|
||||||
return `<span class="inline-title">Feedback von ${feedback.teacher.firstName} ${feedback.teacher.lastName}:</span> ${feedback.text}`;
|
return `<span class="inline-title">Feedback von ${feedback.teacher.firstName} ${feedback.teacher.lastName}:</span> ${feedback.text}`;
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -122,20 +122,20 @@
|
||||||
id: this.assignment.id,
|
id: this.assignment.id,
|
||||||
answer: this.assignment.submission.text,
|
answer: this.assignment.submission.text,
|
||||||
document: this.assignment.submission.document,
|
document: this.assignment.submission.document,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
update(store, {data: {updateAssignment: {successful, updatedAssignment}}}) {
|
update(store, {data: {updateAssignment: {successful, updatedAssignment}}}) {
|
||||||
try {
|
try {
|
||||||
if (successful) {
|
if (successful) {
|
||||||
const query = ASSIGNMENT_QUERY;
|
const query = ASSIGNMENT_QUERY;
|
||||||
const variables = {
|
const variables = {
|
||||||
id: updatedAssignment.id
|
id: updatedAssignment.id,
|
||||||
};
|
};
|
||||||
const data = store.readQuery({query, variables});
|
const data = store.readQuery({query, variables});
|
||||||
|
|
||||||
data.assignment = Object.assign({}, updatedAssignment, {
|
data.assignment = Object.assign({}, updatedAssignment, {
|
||||||
submission
|
submission,
|
||||||
});
|
});
|
||||||
store.writeQuery({query, variables, data});
|
store.writeQuery({query, variables, data});
|
||||||
}
|
}
|
||||||
|
|
@ -143,7 +143,7 @@
|
||||||
console.error(e);
|
console.error(e);
|
||||||
// Query did not exist in the cache, and apollo throws a generic Error. Do nothing
|
// Query did not exist in the cache, and apollo throws a generic Error. Do nothing
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.saving--;
|
this.saving--;
|
||||||
if (this.saving === 0) {
|
if (this.saving === 0) {
|
||||||
|
|
@ -177,10 +177,10 @@
|
||||||
id: this.assignment.id,
|
id: this.assignment.id,
|
||||||
answer: this.assignment.submission.text,
|
answer: this.assignment.submission.text,
|
||||||
document: this.assignment.submission.document,
|
document: this.assignment.submission.document,
|
||||||
final: true
|
final: true,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
reopen() {
|
reopen() {
|
||||||
|
|
@ -192,10 +192,10 @@
|
||||||
id: this.assignment.id,
|
id: this.assignment.id,
|
||||||
answer: this.assignment.submission.text,
|
answer: this.assignment.submission.text,
|
||||||
document: this.assignment.submission.document,
|
document: this.assignment.submission.document,
|
||||||
final: false
|
final: false,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
initialSubmission() {
|
initialSubmission() {
|
||||||
|
|
@ -213,16 +213,16 @@
|
||||||
variables: {
|
variables: {
|
||||||
input: {
|
input: {
|
||||||
assignment: this.assignment.id,
|
assignment: this.assignment.id,
|
||||||
text: this.assignment.submission.text
|
text: this.assignment.submission.text,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
update(store, {data: {spellCheck: {results}}}) {
|
update(store, {data: {spellCheck: {results}}}) {
|
||||||
self.corrections = results;
|
self.corrections = results;
|
||||||
}
|
},
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.spellcheckLoading = false;
|
this.spellcheckLoading = false;
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
apollo: {
|
apollo: {
|
||||||
|
|
@ -230,7 +230,7 @@
|
||||||
query: ASSIGNMENT_QUERY,
|
query: ASSIGNMENT_QUERY,
|
||||||
variables() {
|
variables() {
|
||||||
return {
|
return {
|
||||||
id: this.value.id
|
id: this.value.id,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
result(response) {
|
result(response) {
|
||||||
|
|
@ -240,12 +240,12 @@
|
||||||
if (this.assignment.id === this.scrollToAssignmentId && 'stale' in response) {
|
if (this.assignment.id === this.scrollToAssignmentId && 'stale' in response) {
|
||||||
this.$nextTick(() => this.scrollToAssignmentReady(true));
|
this.$nextTick(() => this.scrollToAssignmentReady(true));
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
me: {
|
me: {
|
||||||
query: ME_QUERY
|
query: ME_QUERY,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue