-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(cli): provide full cli tests for both v2 and v3
- Loading branch information
Showing
59 changed files
with
2,494 additions
and
355 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict' | ||
|
||
const {createJestConfig} = require('../../../test/config.cjs') | ||
|
||
module.exports = createJestConfig({ | ||
displayName: require('./package.json').name, | ||
testEnvironment: 'node', | ||
rootDir: __dirname, | ||
globalSetup: '<rootDir>/test/shared/globalSetup.ts', | ||
globalTeardown: '<rootDir>/test/shared/globalTeardown.ts', | ||
slowTestThreshold: 60000, | ||
testTimeout: 30000, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"rules": { | ||
"max-nested-callbacks": "off" | ||
} | ||
} |
Binary file not shown.
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
packages/@sanity/cli/test/__fixtures__/v2/components/MyLogo.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react' | ||
import styles from './MyLogo.module.css' | ||
|
||
// Test that we can import CSS modules and that they get bundled | ||
export function MyLogo() { | ||
return <div className={styles.logo}>Hello</div> | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/@sanity/cli/test/__fixtures__/v2/components/MyLogo.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.logo { | ||
background: green; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"_id": "drafts.magnus-carlsen", | ||
"_type": "person", | ||
"name": "Magnus Carlsen" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "v2-studio", | ||
"private": true, | ||
"version": "0.0.1", | ||
"description": "A Sanity v2 studio for CI testing.", | ||
"author": "Sanity.io <hello@sanity.io>", | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "sanity build", | ||
"start": "sanity start" | ||
}, | ||
"keywords": [ | ||
"fixture" | ||
], | ||
"dependencies": { | ||
"@sanity/base": "^2.33.3", | ||
"@sanity/cli": "^2.33.3", | ||
"@sanity/core": "^2.33.3", | ||
"@sanity/default-layout": "^2.33.3", | ||
"@sanity/default-login": "^2.33.3", | ||
"@sanity/desk-tool": "^2.33.3", | ||
"react": "17.0.2", | ||
"react-dom": "17.0.2", | ||
"styled-components": "^5.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* eslint-disable import/no-unresolved */ | ||
import schemaTypes from 'all:part:@sanity/base/schema-type' | ||
import createSchema from 'part:@sanity/base/schema-creator' | ||
|
||
export default createSchema({ | ||
name: 'v2-schema', | ||
types: schemaTypes.concat([ | ||
{ | ||
name: 'person', | ||
title: 'Person', | ||
type: 'document', | ||
fields: [ | ||
{ | ||
name: 'name', | ||
title: 'Name', | ||
type: 'string', | ||
}, | ||
{ | ||
name: 'slug', | ||
title: 'Slug', | ||
type: 'slug', | ||
options: { | ||
source: 'name', | ||
maxLength: 100, | ||
}, | ||
}, | ||
{ | ||
name: 'image', | ||
title: 'Image', | ||
type: 'image', | ||
options: { | ||
hotspot: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
]), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* eslint-disable import/no-unresolved, no-console */ | ||
// Tests that `sanity exec` in v2 can import parts, and use a preconfigured client | ||
import client from 'part:@sanity/base/client' | ||
|
||
client | ||
.withConfig({apiVersion: '2022-09-09'}) | ||
.users.getById('me') | ||
.then( | ||
(user) => console.log(JSON.stringify(user, null, 2)), | ||
(err) => console.error(err) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"rules": { | ||
"import/no-extraneous-dependencies": "off" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/@sanity/cli/test/__fixtures__/v3/components/MyLogo.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react' | ||
import styles from './MyLogo.module.css' | ||
|
||
// Test that we can import CSS modules and that they get bundled | ||
export function MyLogo() { | ||
return <div className={styles.logo}>Hello</div> | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/@sanity/cli/test/__fixtures__/v3/components/MyLogo.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.logo { | ||
background: green; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"_id": "drafts.magnus-carlsen", | ||
"_type": "person", | ||
"name": "Magnus Carlsen" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "v3-studio", | ||
"private": true, | ||
"version": "0.0.1", | ||
"description": "A Sanity v3 studio for CI testing.", | ||
"author": "Sanity.io <hello@sanity.io>", | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "sanity build", | ||
"start": "sanity start" | ||
}, | ||
"keywords": [ | ||
"fixture" | ||
], | ||
"dependencies": { | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"sanity": "3.0.0-dev-preview.20", | ||
"styled-components": "^5.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {createCliConfig} from 'sanity/cli' | ||
|
||
export default createCliConfig({ | ||
api: { | ||
projectId: 'aeysrmym', | ||
dataset: 'production', | ||
}, | ||
|
||
graphql: [ | ||
{ | ||
playground: false, | ||
workspace: 'default', // @todo remove | ||
}, | ||
], | ||
}) |
11 changes: 11 additions & 0 deletions
11
packages/@sanity/cli/test/__fixtures__/v3/sanity.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {createConfig} from 'sanity' | ||
import {MyLogo} from './components/MyLogo' | ||
import {schema} from './schema' | ||
|
||
export default createConfig({ | ||
name: 'default', // @todo remove | ||
projectId: 'aeysrmym', | ||
dataset: 'production', | ||
logo: MyLogo, | ||
schema, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
export const schema = { | ||
name: 'default', | ||
types: [ | ||
{ | ||
name: 'person', | ||
title: 'Person', | ||
type: 'document', | ||
fields: [ | ||
{ | ||
name: 'name', | ||
title: 'Name', | ||
type: 'string', | ||
}, | ||
{ | ||
name: 'slug', | ||
title: 'Slug', | ||
type: 'slug', | ||
options: { | ||
source: 'name', | ||
maxLength: 100, | ||
}, | ||
}, | ||
{ | ||
name: 'image', | ||
title: 'Image', | ||
type: 'image', | ||
options: { | ||
hotspot: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* eslint-disable no-console */ | ||
// Tests that `sanity exec` in v3 can import the CLI client | ||
import {getCliClient} from 'sanity/cli' | ||
|
||
getCliClient() | ||
.withConfig({apiVersion: '2022-09-09'}) | ||
.users.getById('me') | ||
.then( | ||
(user) => console.log(JSON.stringify(user, null, 2)), | ||
(err) => console.error(err) | ||
) |
Oops, something went wrong.