Skip to content

Commit

Permalink
Enable cloudinary tests (#5386)
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie committed Apr 7, 2021
1 parent 184b631 commit 952db71
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-dancers-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/fields-cloudinary-image-legacy': patch
---

Fixed the type resolver when using the `sqlite` provider.
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ jobs:
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
run: yarn jest --ci --maxWorkers=1 api-tests
env:
CLOUDINARY_CLOUD_NAME: keystone-cloudinary
CLOUDINARY_KEY: 758252673115372
CLOUDINARY_CLOUD_NAME: ${{ secrets.CLOUDINARY_CLOUD_NAME }}
CLOUDINARY_KEY: ${{ secrets.CLOUDINARY_KEY }}
CLOUDINARY_SECRET: ${{ secrets.CLOUDINARY_SECRET }}
CI_NODE_TOTAL: 9
CI_NODE_INDEX: ${{ matrix.index }}
Expand Down Expand Up @@ -200,8 +200,8 @@ jobs:
- name: Unit tests
run: yarn jest --ci --maxWorkers=1 --testPathIgnorePatterns=api-tests --testPathIgnorePatterns=examples-smoke-tests
env:
CLOUDINARY_CLOUD_NAME: keystone-cloudinary
CLOUDINARY_KEY: 758252673115372
CLOUDINARY_CLOUD_NAME: ${{ secrets.CLOUDINARY_CLOUD_NAME }}
CLOUDINARY_KEY: ${{ secrets.CLOUDINARY_KEY }}
CLOUDINARY_SECRET: ${{ secrets.CLOUDINARY_SECRET }}

examples_smoke_tests:
Expand Down
2 changes: 2 additions & 0 deletions packages/fields-cloudinary-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"main": "dist/fields-cloudinary-image-legacy.cjs.js",
"module": "dist/fields-cloudinary-image-legacy.esm.js",
"devDependencies": {
"@keystone-next/cloudinary": "*",
"@keystone-next/fields": "*",
"@keystone-next/file-adapters-legacy": "*",
"cloudinary": "^1.25.1",
"dotenv": "^8.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/fields-cloudinary-image/src/Implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class CloudinaryImage extends File.implementation {
gqlOutputFieldResolvers() {
return {
[this.path]: item => {
const itemValues = item[this.path];
let itemValues = item[this.path];
if (!itemValues) {
return null;
}
Expand Down
36 changes: 20 additions & 16 deletions packages/fields-cloudinary-image/src/test-fixtures.skip.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });

import fs from 'fs';
import mime from 'mime';
import { Upload } from 'graphql-upload';
import cloudinary from 'cloudinary';
import { Text } from '@keystone-next/fields-legacy';
import { CloudinaryAdapter } from '@keystone-next/file-adapters-legacy';
import { cloudinaryImage } from '@keystone-next/cloudinary';
import { text } from '@keystone-next/fields';

import { CloudinaryImage } from './';
const path = require('path');

cloudinary.v2.config({
Expand All @@ -28,16 +25,9 @@ const prepareFile = _filePath => {
return upload;
};

const cloudinaryAdapter = new CloudinaryAdapter({
cloudName: process.env.CLOUDINARY_CLOUD_NAME || 'cloudinary_cloud_name',
apiKey: process.env.CLOUDINARY_KEY || 'cloudinary_key',
apiSecret: process.env.CLOUDINARY_SECRET || 'cloudinary_secret',
folder: 'cloudinary-test',
});

// Configurations
export const name = 'CloudinaryImage';
export const type = CloudinaryImage;
export const typeFunction = cloudinaryImage;
export const supportsUnique = false;
export const fieldName = 'image';
export const subfieldName = 'originalFilename';
Expand All @@ -50,10 +40,24 @@ export const exampleValue2 = () => prepareFile('keystone.jpeg');
export const createReturnedValue = exampleValue().file.filename;
export const updateReturnedValue = exampleValue2().file.filename;

export const fieldConfig = () => ({ adapter: cloudinaryAdapter });
export const fieldConfig = () => ({
cloudinary: {
cloudName: process.env.CLOUDINARY_CLOUD_NAME || 'cloudinary_cloud_name',
apiKey: process.env.CLOUDINARY_KEY || 'cloudinary_key',
apiSecret: process.env.CLOUDINARY_SECRET || 'cloudinary_secret',
folder: 'cloudinary-test',
},
});
export const getTestFields = () => ({
name: { type: Text },
image: { type, adapter: cloudinaryAdapter },
name: text(),
image: cloudinaryImage({
cloudinary: {
cloudName: process.env.CLOUDINARY_CLOUD_NAME || 'cloudinary_cloud_name',
apiKey: process.env.CLOUDINARY_KEY || 'cloudinary_key',
apiSecret: process.env.CLOUDINARY_SECRET || 'cloudinary_secret',
folder: 'cloudinary-test',
},
}),
});

export const initItems = () => [
Expand Down

1 comment on commit 952db71

@vercel
Copy link

@vercel vercel bot commented on 952db71 Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.