Fix cypress tests

This commit is contained in:
roschaefer 2019-12-03 22:03:35 +01:00
parent b7e36345b9
commit 77fb948c14
2 changed files with 5 additions and 5 deletions

View File

@ -1,5 +1,6 @@
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps' import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'
import { VERSION } from '../../constants/terms-and-conditions-version.js' import { VERSION } from '../../constants/terms-and-conditions-version.js'
import { gql } from '../../../backend/src/helpers/jest'
/* global cy */ /* global cy */
@ -128,7 +129,7 @@ Given('somebody reported the following posts:', table => {
cy.factory() cy.factory()
.create('User', submitter) .create('User', submitter)
.authenticateAs(submitter) .authenticateAs(submitter)
.mutate(`mutation($resourceId: ID!, $reasonCategory: ReasonCategory!, $reasonDescription: String!) { .mutate(gql`mutation($resourceId: ID!, $reasonCategory: ReasonCategory!, $reasonDescription: String!) {
fileReport(resourceId: $resourceId, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription) { fileReport(resourceId: $resourceId, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription) {
id id
} }

View File

@ -18,7 +18,7 @@ import helpers from "./helpers";
import users from "../fixtures/users.json"; import users from "../fixtures/users.json";
import { GraphQLClient, request } from 'graphql-request' import { GraphQLClient, request } from 'graphql-request'
import { gql } from '../../backend/src/helpers/jest' import { gql } from '../../backend/src/helpers/jest'
import { GRAPHQL_URI } from '../../backend/src/config' import config from '../../backend/src/config'
const switchLang = name => { const switchLang = name => {
cy.get(".locale-menu").click(); cy.get(".locale-menu").click();
@ -31,7 +31,7 @@ const authenticatedHeaders = async (variables) => {
login(email: $email, password: $password) login(email: $email, password: $password)
} }
` `
const response = await request(GRAPHQL_URI, mutation, variables) const response = await request(config.GRAPHQL_URI, mutation, variables)
return { authorization: `Bearer ${response.login}` } return { authorization: `Bearer ${response.login}` }
} }
@ -100,8 +100,7 @@ Cypress.Commands.add(
'authenticateAs', 'authenticateAs',
async ({email, password}) => { async ({email, password}) => {
const headers = await authenticatedHeaders({ email, password }) const headers = await authenticatedHeaders({ email, password })
console.log(headers) return new GraphQLClient(config.GRAPHQL_URI, { headers })
return new GraphQLClient(GRAPHQL_URI, { headers })
} }
) )