Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
server
Manage
Activity
Members
Labels
Plan
Issues
25
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cokoapps
server
Commits
3da3b430
Commit
3da3b430
authored
8 months ago
by
Yannis Barlas
Browse files
Options
Downloads
Patches
Plain Diff
chore(*): remove redundant file
parent
b046ca17
No related branches found
No related tags found
1 merge request
!123
v4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/__tests__/graphql/subscriptions.test.bak.js
+0
-193
0 additions, 193 deletions
src/__tests__/graphql/subscriptions.test.bak.js
with
0 additions
and
193 deletions
src/__tests__/graphql/subscriptions.test.bak.js
deleted
100644 → 0
+
0
−
193
View file @
b046ca17
/* eslint-disable jest/no-commented-out-tests */
// const { fixtures } = require('@pubsweet/model-user/test')
// const WebSocket = require('ws')
// const {
// ApolloClient,
// createHttpLink,
// gql,
// InMemoryCache,
// split,
// } = require('@apollo/client')
// const { WebSocketLink } = require('@apollo/client/link/ws')
// const { getMainDefinition } = require('@apollo/client/utilities')
// const FormData = require('form-data')
// const fetch = require('node-fetch')
// const wait = require('waait')
// const { startServer } = require('../../src')
// const authentication = require('../../src/authentication')
// const cleanDB = require('../helpers/db_cleaner')
// function generateFetchOptions(token, fileSize) {
// // This dance needs to happen because apollo-upload-client is 'untestable':
// // https://github.com/jaydenseric/apollo-upload-client/issues/32#issuecomment-327694315
// let variables
// let size
// let query
// if (fileSize) {
// variables = {
// file: null,
// fileSize,
// }
// query =
// 'mutation uploadFile($file: Upload!, $fileSize: Int) { upload(file: $file, fileSize: $fileSize) { url, __typename }}'
// size = fileSize
// } else {
// variables = {
// file: null,
// }
// query =
// 'mutation uploadFile($file: Upload!) { upload(file: $file) { url, __typename }}'
// size = 1000000
// }
// const body = new FormData()
// body.append(
// 'operations',
// JSON.stringify({
// operationName: 'uploadFile',
// variables,
// query,
// }),
// )
// body.append('map', JSON.stringify({ 1: ['variables.file'] }))
// body.append('1', 'a'.repeat(size), { filename: 'a.txt' })
// const options = {
// method: 'POST',
// body,
// headers: {
// Authorization: `Bearer ${token}`,
// },
// }
// return options
// }
// describe('GraphQL subscriptions', () => {
// let token
// let user
// let server
// let apolloClient
// let wsLink
// beforeAll(async () => {
// server = await startServer()
// })
// beforeEach(async () => {
// await cleanDB()
// user = await new User(fixtures.user).save()
// token = authentication.token.create(user)
// wsLink = new WebSocketLink({
// uri: `ws://localhost:4000/subscriptions`,
// options: {
// connectionParams: {
// authToken: token,
// },
// },
// reconnect: false,
// webSocketImpl: WebSocket,
// })
// const httpLink = createHttpLink({ fetch })
// const link = split(
// ({ query }) => {
// const { kind, operation } = getMainDefinition(query)
// return kind === 'OperationDefinition' && operation === 'subscription'
// },
// wsLink,
// httpLink,
// )
// const config = {
// link,
// cache: new InMemoryCache(),
// }
// apolloClient = new ApolloClient(config)
// })
// afterEach(async () => {
// await wsLink.subscriptionClient.client.close()
// })
// afterAll(done => server.close(done))
// it('reports progress when fileSize is given', async () => {
// let done
// let progress = 0
// const subscriptionPromise = new Promise((resolve, reject) => {
// apolloClient
// .subscribe({
// query: gql`
// subscription onUploadProgress {
// uploadProgress
// }
// `,
// })
// .subscribe({
// next: async res => {
// expect(res.data.uploadProgress).toBeGreaterThanOrEqual(progress)
// progress = res.data.uploadProgress
// expect(progress).toBeGreaterThan(-1)
// expect(progress).toBeLessThanOrEqual(100)
// // sometimes the last notification is sent slightly before
// // fetch completes, resulting in an unresolved promise, so
// // we just wait a tiny bit.
// await wait(100)
// if (done) resolve('done')
// },
// error: reject,
// })
// })
// await fetch(
// `http://localhost:4000/graphql`,
// generateFetchOptions(token, 1000000),
// )
// done = true
// expect(await subscriptionPromise).toBe('done')
// })
// it('reports progress when fileSize is not given', async () => {
// let done
// let progress = 0
// const subscriptionPromise = new Promise((resolve, reject) => {
// apolloClient
// .subscribe({
// query: gql`
// subscription onUploadProgress {
// uploadProgress
// }
// `,
// })
// .subscribe({
// next: async res => {
// expect(res.data.uploadProgress).toBeGreaterThanOrEqual(progress)
// progress = res.data.uploadProgress
// expect(progress).toBeGreaterThan(-1)
// expect(progress).toBeLessThanOrEqual(1000000)
// // sometimes the last notification is sent slightly before
// // fetch completes, resulting in an unresolved promise, so
// // we just wait a tiny bit.
// await wait(100)
// if (done) resolve('done')
// },
// error: reject,
// })
// })
// await fetch(`http://localhost:4000/graphql`, generateFetchOptions(token))
// done = true
// expect(await subscriptionPromise).toBe('done')
// })
// })
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment