skillbox/client/cypress/integration/frontend/modules/content-blocks-mobile.spec.js

55 lines
1.4 KiB
JavaScript

import {graphql} from 'graphql';
import {makeExecutableSchema} from '@graphql-tools/schema';
import {addMocksToSchema} from '@graphql-tools/mock';
import {addResolversToSchema} from '@graphql-tools/schema';
import defaultMocks from '../../../fixtures/mocks';
// const operations = {
// MeQuery: getMinimalMe({isTeacher: false}),
// };
describe('Content Blocks', () => {
beforeEach(() => {
cy.fakeLogin('nino.teacher', 'test');
cy.viewport('macbook-15');
cy.task('getSchema').then(schemaString => {
cy.intercept('POST', '/api/graphql', (req) => {
// if (hasOperationName('MeQuery')) {
// graphql()
const schema = makeExecutableSchema({
typeDefs: schemaString,
});
const preserveResolvers = true;
const mocks = {
...defaultMocks,
module: {
title: 'I am a custom Title!'
}
};
const schemaWithMocks = addMocksToSchema({
schema,
preserveResolvers,
mocks,
});
const {query} = req.body;
console.log(req.body);
graphql({
schema: schemaWithMocks,
source: query,
}).then(result => {
console.log(result);
req.reply(result);
});
// }
});
});
});
it('opens the module', () => {
cy.visit('module/some-module');
});
});