diff --git a/test/sanity-check/api/asset-test.js b/test/sanity-check/api/asset-test.js new file mode 100644 index 00000000..70d7fbe0 --- /dev/null +++ b/test/sanity-check/api/asset-test.js @@ -0,0 +1,217 @@ +import path from 'path' +import { expect } from 'chai' +import { describe, it, setup } from 'mocha' +import { jsonReader, writeDownloadedFile } from '../utility/fileOperations/readwrite' +import { contentstackClient } from '../utility/ContentstackClient.js' + +var client = {} + +var folderUID = '' +var assetUID = '' +var publishAssetUID = '' +var assetURL = '' +describe('Assets api Test', () => { + setup(() => { + const user = jsonReader('loggedinuser.json') + client = contentstackClient(user.authtoken) + }) + + it('should asset Upload ', done => { + const asset = { + upload: path.join(__dirname, '../mock/customUpload.html'), + title: 'customasset', + description: 'Custom Asset Desc', + tags: ['Custom'] + } + makeAsset().create(asset) + .then((asset) => { + assetUID = asset.uid + assetURL = asset.url + expect(asset.uid).to.be.not.equal(null) + expect(asset.url).to.be.not.equal(null) + expect(asset.filename).to.be.equal('customUpload.html') + expect(asset.title).to.be.equal('customasset') + expect(asset.description).to.be.equal('Custom Asset Desc') + expect(asset.content_type).to.be.equal('text/html') + done() + }) + .catch(done) + }) + + it('should download asset from URL.', done => { + makeAsset().download({ url: assetURL, responseType: 'stream' }) + .then((response) => { + writeDownloadedFile(response, 'asset1') + done() + }).catch(done) + }) + it('should download asset from fetch details ', done => { + makeAsset(assetUID).fetch() + .then((asset) => asset.download({ responseType: 'stream' })) + .then((response) => { + writeDownloadedFile(response, 'asset2') + done() + }).catch(done) + }) + + it('should create folder ', done => { + makeAsset().folder().create({ asset: { name: 'Sample Folder' } }) + .then((asset) => { + folderUID = asset.uid + expect(asset.uid).to.be.not.equal(null) + expect(asset.name).to.be.equal('Sample Folder') + expect(asset.is_dir).to.be.equal(true) + done() + }) + .catch(done) + }) + + it('should asset Upload in folder', done => { + const asset = { + upload: path.join(__dirname, '../mock/customUpload.html'), + title: 'customasset in Folder', + description: 'Custom Asset Desc in Folder', + parent_uid: folderUID, + tags: 'folder' + } + makeAsset().create(asset) + .then((asset) => { + publishAssetUID = asset.uid + expect(asset.uid).to.be.not.equal(null) + expect(asset.url).to.be.not.equal(null) + expect(asset.filename).to.be.equal('customUpload.html') + expect(asset.title).to.be.equal('customasset in Folder') + expect(asset.description).to.be.equal('Custom Asset Desc in Folder') + expect(asset.content_type).to.be.equal('text/html') + expect(asset.parent_uid).to.be.equal(folderUID) + done() + }) + .catch(done) + }) + + it('should asset Upload in folder with contenttype', done => { + const asset = { + upload: path.join(__dirname, '../mock/berries.jfif'), + title: 'customasset2 in Folder', + description: 'Custom Asset Desc in Folder', + parent_uid: folderUID, + tags: 'folder', + content_type: 'image/jpeg' + } + makeAsset().create(asset) + .then((asset) => { + publishAssetUID = asset.uid + expect(asset.uid).to.be.not.equal(null) + expect(asset.url).to.be.not.equal(null) + expect(asset.filename).to.be.equal('berries.jfif') + expect(asset.title).to.be.equal('customasset2 in Folder') + expect(asset.description).to.be.equal('Custom Asset Desc in Folder') + expect(asset.content_type).to.be.equal('image/jpeg') + expect(asset.parent_uid).to.be.equal(folderUID) + done() + }) + .catch(done) + }) + it('should replace asset ', done => { + const asset = { + upload: path.join(__dirname, '../mock/upload.html') + } + makeAsset(assetUID) + .replace(asset) + .then((asset) => { + expect(asset.uid).to.be.equal(assetUID) + expect(asset.filename).to.be.equal('upload.html') + expect(asset.content_type).to.be.equal('text/html') + done() + }) + .catch(done) + }) + + it('should fetch and Update asset details', done => { + makeAsset(assetUID) + .fetch() + .then((asset) => { + asset.title = 'Update title' + asset.description = 'Update description' + delete asset.ACL + return asset.update() + }) + .then((asset) => { + expect(asset.uid).to.be.equal(assetUID) + expect(asset.title).to.be.equal('Update title') + expect(asset.description).to.be.equal('Update description') + done() + }) + .catch(done) + }) + + it('should publish Asset', done => { + makeAsset(publishAssetUID) + .publish({ publishDetails: { + locales: ['hi-in', 'en-us'], + environments: ['development'] + } }) + .then((data) => { + expect(data.notice).to.be.equal('Asset sent for publishing.') + done() + }) + .catch(done) + }) + + it('should unpublish Asset', done => { + makeAsset(publishAssetUID) + .unpublish({ publishDetails: { + locales: ['hi-in', 'en-us'], + environments: ['development'] + } }) + .then((data) => { + expect(data.notice).to.be.equal('Asset sent for unpublishing.') + done() + }) + .catch(done) + }) + + it('should delete asset', done => { + makeAsset(assetUID) + .delete() + .then((data) => { + expect(data.notice).to.be.equal('Asset deleted successfully.') + done() + }) + .catch(done) + }) + + it('should query to fetch all asset', done => { + makeAsset() + .query() + .find() + .then((collection) => { + collection.items.forEach((asset) => { + expect(asset.uid).to.be.not.equal(null) + expect(asset.title).to.be.not.equal(null) + expect(asset.description).to.be.not.equal(null) + }) + done() + }) + .catch(done) + }) + + it('should query to fetch title match asset', done => { + makeAsset() + .query({ query: { title: 'Update title' } }) + .find() + .then((collection) => { + collection.items.forEach((asset) => { + expect(asset.uid).to.be.not.equal(null) + expect(asset.title).to.be.equal('Update title') + expect(asset.description).to.be.equal('Update description') + }) + done() + }) + .catch(done) + }) +}) + +function makeAsset (uid = null) { + return client.stack({ api_key: process.env.API_KEY }).asset(uid) +} diff --git a/test/sanity-check/api/contentType-delete-test.js b/test/sanity-check/api/contentType-delete-test.js index e50722c5..148a48ce 100644 --- a/test/sanity-check/api/contentType-delete-test.js +++ b/test/sanity-check/api/contentType-delete-test.js @@ -12,7 +12,7 @@ describe('Content Type delete api Test', () => { client = contentstackClient(user.authtoken) }) - it('Content Type delete', done => { + it('should content Type delete', done => { makeContentType(multiPageCT.content_type.uid) .delete().then((data) => { expect(data.notice).to.be.equal('Content Type deleted successfully.') diff --git a/test/sanity-check/api/contentType-test.js b/test/sanity-check/api/contentType-test.js index 49b09e7f..fbb99a0a 100644 --- a/test/sanity-check/api/contentType-test.js +++ b/test/sanity-check/api/contentType-test.js @@ -15,7 +15,7 @@ describe('Content Type api Test', () => { client = contentstackClient(user.authtoken) }) - it('Create Single page ContentType Schema', done => { + it('should create Single page ContentType Schema', done => { makeContentType() .create(singlepageCT) .then((contentType) => { @@ -26,7 +26,7 @@ describe('Content Type api Test', () => { .catch(done) }) - it('Create Multi page ContentType Schema', done => { + it('should create Multi page ContentType Schema', done => { makeContentType() .create(multiPageCT) .then((contentType) => { @@ -38,7 +38,7 @@ describe('Content Type api Test', () => { .catch(done) }) - it('Get all ContentType', done => { + it('should get all ContentType', done => { makeContentType() .query() .find() @@ -53,7 +53,7 @@ describe('Content Type api Test', () => { .catch(done) }) - it('Query ContentType title', done => { + it('should query ContentType title', done => { makeContentType() .query({ query: { title: singlepageCT.content_type.title } }) .find() @@ -70,7 +70,7 @@ describe('Content Type api Test', () => { .catch(done) }) - it('Fetch ContentType from uid', done => { + it('should fetch ContentType from uid', done => { makeContentType(multiPageCT.content_type.uid) .fetch() .then((contentType) => { @@ -81,7 +81,7 @@ describe('Content Type api Test', () => { .catch(done) }) - it('Fetch and Update ContentType schema', done => { + it('should fetch and Update ContentType schema', done => { makeContentType(multiPageCTUid) .fetch() .then((contentType) => { @@ -95,7 +95,7 @@ describe('Content Type api Test', () => { .catch(done) }) - it('Import content type', done => { + it('should import content type', done => { makeContentType().import({ content_type: path.join(__dirname, '../mock/contentType.json') }) @@ -107,7 +107,7 @@ describe('Content Type api Test', () => { .catch(done) }) - it('Delete ContentTypes', done => { + it('should delete ContentTypes', done => { makeContentType(importCTUid) .delete() .then((contentType) => { diff --git a/test/sanity-check/api/entry-test.js b/test/sanity-check/api/entry-test.js new file mode 100644 index 00000000..fc2f02bd --- /dev/null +++ b/test/sanity-check/api/entry-test.js @@ -0,0 +1,194 @@ +import path from 'path' +import { expect } from 'chai' +import { describe, it, setup } from 'mocha' +import { jsonReader, jsonWrite } from '../utility/fileOperations/readwrite' +import { multiPageCT, singlepageCT } from '../mock/content-type.js' +import { entryFirst, entrySecond, entryThird } from '../mock/entry.js' +import { contentstackClient } from '../utility/ContentstackClient.js' + +var client = {} + +var entryUTD = '' +describe('Entry api Test', () => { + setup(() => { + const user = jsonReader('loggedinuser.json') + client = contentstackClient(user.authtoken) + }) + + it('should create Entry in Single ', done => { + var entry = { + title: 'Sample Entry', + url: 'sampleEntry' + } + makeEntry(singlepageCT.content_type.uid) + .create({ entry }) + .then((entryResponse) => { + entryUTD = entryResponse.uid + expect(entryResponse.title).to.be.equal(entry.title) + expect(entryResponse.url).to.be.equal(entry.url) + expect(entryResponse.uid).to.be.not.equal(null) + done() + }) + .catch(done) + }) + it('should entry fetch with Content Type', done => { + makeEntry(singlepageCT.content_type.uid, entryUTD) + .fetch({ include_content_type: true }) + .then((entryResponse) => { + expect(entryResponse.uid).to.be.not.equal(null) + expect(entryResponse.content_type).to.be.not.equal(null) + done() + }) + .catch(done) + }) + + it('should localize entry with title update', done => { + makeEntry(singlepageCT.content_type.uid, entryUTD) + .fetch() + .then((entry) => { + entry.title = 'Sample Entry in en-at' + return entry.update({ locale: 'en-at' }) + }) + .then((entryResponse) => { + entryUTD = entryResponse.uid + expect(entryResponse.title).to.be.equal('Sample Entry in en-at') + expect(entryResponse.uid).to.be.not.equal(null) + expect(entryResponse.locale).to.be.equal('en-at') + done() + }) + .catch(done) + }) + + it('should create Entries for Multiple page', done => { + makeEntry(multiPageCT.content_type.uid) + .create({ entry: entryFirst }) + .then((entry) => { + expect(entry.uid).to.be.not.equal(null) + expect(entry.title).to.be.equal(entryFirst.title) + expect(entry.single_line).to.be.equal(entryFirst.single_line) + expect(entry.url).to.be.equal(`/${entryFirst.title.toLowerCase().replace(/ /g, '-')}`) + expect(entry.multi_line).to.be.equal(entryFirst.multi_line) + expect(entry.markdown).to.be.equal(entryFirst.markdown) + done() + }) + .catch(done) + }) + + it('should create Entries 2 for Multiple page', done => { + makeEntry(multiPageCT.content_type.uid) + .create({ entry: entrySecond }) + .then((entry) => { + expect(entry.uid).to.be.not.equal(null) + expect(entry.title).to.be.equal(entrySecond.title) + expect(entry.url).to.be.equal(`/${entrySecond.title.toLowerCase().replace(/ /g, '-')}`) + expect(entry.single_line).to.be.equal(entrySecond.single_line) + expect(entry.multi_line).to.be.equal(entrySecond.multi_line) + expect(entry.markdown).to.be.equal(entrySecond.markdown) + expect(entry.tags[0]).to.be.equal(entrySecond.tags[0]) + done() + }) + .catch(done) + }) + + it('should create Entries 3 for Multiple page', done => { + makeEntry(multiPageCT.content_type.uid) + .create({ entry: entryThird }) + .then((entry) => { + expect(entry.uid).to.be.not.equal(null) + expect(entry.title).to.be.equal(entryThird.title) + expect(entry.url).to.be.equal(`/${entryThird.title.toLowerCase().replace(/ /g, '-')}`) + expect(entry.single_line).to.be.equal(entryThird.single_line) + expect(entry.multi_line).to.be.equal(entryThird.multi_line) + expect(entry.markdown).to.be.equal(entryThird.markdown) + expect(entry.tags[0]).to.be.equal(entryThird.tags[0]) + done() + }) + .catch(done) + }) + + it('should get all Entry', done => { + makeEntry(multiPageCT.content_type.uid) + .query({ include_count: true, include_content_type: true }).find() + .then((collection) => { + jsonWrite(collection.items, 'entry.json') + expect(collection.count).to.be.equal(3) + collection.items.forEach((entry) => { + expect(entry.uid).to.be.not.equal(null) + expect(entry.content_type_uid).to.be.equal(multiPageCT.content_type.uid) + }) + done() + }) + .catch(done) + }) + + it('should get all Entry from tag', done => { + makeEntry(multiPageCT.content_type.uid) + .query({ include_count: true, query: { tags: entrySecond.tags[0] } }).find() + .then((collection) => { + expect(collection.count).to.be.equal(1) + collection.items.forEach((entry) => { + expect(entry.uid).to.be.not.equal(null) + expect(entry.tags).to.have.all.keys(0) + }) + done() + }) + .catch(done) + }) + + it('should publish Entry', done => { + makeEntry(singlepageCT.content_type.uid, entryUTD) + .publish({ publishDetails: { + locales: ['en-us'], + environments: ['development'] + } }) + .then((data) => { + expect(data.notice).to.be.equal('The requested action has been performed.') + done() + }) + .catch(done) + }) + + it('should publish localized Entry to locales', done => { + makeEntry(singlepageCT.content_type.uid, entryUTD) + .publish({ publishDetails: { + locales: ['hi-in', 'en-at'], + environments: ['development'] + }, + locale: 'en-at' }) + .then((data) => { + expect(data.notice).to.be.equal('The requested action has been performed.') + done() + }) + .catch(done) + }) + + it('should unpublish localized entry', done => { + makeEntry(singlepageCT.content_type.uid, entryUTD) + .unpublish({ publishDetails: { + locales: ['hi-in', 'en-at'], + environments: ['development'] + }, + locale: 'en-at' }) + .then((data) => { + expect(data.notice).to.be.equal('The requested action has been performed.') + done() + }) + .catch(done) + }) + + it('should import Entry', done => { + makeEntry(multiPageCT.content_type.uid) + .import({ + entry: path.join(__dirname, '../mock/entry.json') + }) + .then((response) => { + expect(response.uid).to.be.not.equal(null) + done() + }) + .catch(done) + }) +}) + +function makeEntry (contentType, uid = null) { + return client.stack({ api_key: process.env.API_KEY }).contentType(contentType).entry(uid) +} diff --git a/test/sanity-check/api/organization-test.js b/test/sanity-check/api/organization-test.js new file mode 100644 index 00000000..80fac458 --- /dev/null +++ b/test/sanity-check/api/organization-test.js @@ -0,0 +1,108 @@ +import { expect } from 'chai' +import { describe, it, setup } from 'mocha' +import { jsonReader } from '../utility/fileOperations/readwrite' +import { contentstackClient } from '../utility/ContentstackClient' + +var user = {} +var client = {} +var organization = {} + +describe('Organization api test', () => { + setup(() => { + user = jsonReader('loggedinuser.json') + client = contentstackClient(user.authtoken) + }) + + it('should fetch all organizations', done => { + client.organization().fetchAll() + .then((response) => { + for (const index in response.items) { + const organizations = response.items[index] + expect(organizations.name).to.not.equal(null, 'Organization name cannot be null') + expect(organizations.uid).to.not.equal(null, 'Organization uid cannot be null') + } + done() + }) + .catch(done) + }) + + it('should get Current user info test', done => { + client.getUser({ include_orgs: true, include_orgs_roles: true, include_stack_roles: true, include_user_settings: true }).then((user) => { + for (const index in user.organizations) { + const organizations = user.organizations[index] + if (organizations.org_roles && (organizations.org_roles.filter(function (role) { return role.admin === true }).length > 0)) { + organization = organizations + break + } + } + done() + }) + .catch(done) + }) + + it('should fetch organization', done => { + organization.fetch() + .then((organizations) => { + expect(organizations.name).to.be.equal('CLI Dev and Automation', 'Organization name dose not match') + done() + }) + .catch(done) + }) + + it('should get all stacks in an Organization', done => { + organization.stacks() + .then((response) => { + for (const index in response.items) { + const stack = response.items[index] + expect(stack.name).to.not.equal(null, 'Organization name cannot be null') + expect(stack.uid).to.not.equal(null, 'Organization uid cannot be null') + } + done() + }) + .catch(done) + }) + // need to test with transfer ownership + it.skip('should transfer Organization Ownership', done => { + organization.transferOwnership('em@em.com') + .then((data) => { + expect(data.notice).to.be.equal('Email has been successfully sent to the user.', 'Message does not match') + done() + }) + .catch((error) => { + console.log(error) + expect(error).to.be.equal(null, 'Failed Transfer Organization Ownership') + done() + }) + }) + + it('should get all roles in an organization', done => { + organization.roles() + .then((roles) => { + for (const i in roles.items) { + expect(roles.items[i].uid).to.not.equal(null, 'Role uid cannot be null') + expect(roles.items[i].name).to.not.equal(null, 'Role name cannot be null') + expect(roles.items[i].org_uid).to.be.equal(organization.uid, 'Role org_uid not match') + } + done() + }) + .catch(done) + }) + + it('should get all invitations in an organization', done => { + organization.getInvitations({ include_count: true }) + .then((response) => { + expect(response.count).to.not.equal(null, 'Failed Transfer Organization Ownership') + for (const i in response.items) { + expect(response.items[i].uid).to.not.equal(null, 'User uid cannot be null') + expect(response.items[i].email).to.not.equal(null, 'User name cannot be null') + expect(response.items[i].user_uid).to.not.equal(null, 'User name cannot be null') + expect(response.items[i].org_uid).to.not.equal(null, 'User name cannot be null') + } + done() + }) + .catch(done) + }) + + // addUser + // Resend invitation +}) diff --git a/test/sanity-check/api/stack-test.js b/test/sanity-check/api/stack-test.js new file mode 100644 index 00000000..70eb0490 --- /dev/null +++ b/test/sanity-check/api/stack-test.js @@ -0,0 +1,158 @@ +import { expect } from 'chai' +import { describe, it, setup } from 'mocha' +import { jsonReader, jsonWrite } from '../utility/fileOperations/readwrite' +import { contentstackClient } from '../utility/ContentstackClient.js' +import dotenv from 'dotenv' +dotenv.config() + +var orgID = process.env.ORGANIZATION +var user = {} +var client = {} + +var stacks = {} +describe('Stack api Test', () => { + setup(() => { + user = jsonReader('loggedinuser.json') + client = contentstackClient(user.authtoken) + }) + const newStack = { + stack: + { + name: 'My New Stack', + description: 'My new test stack', + master_locale: 'en-us' + } + } + + it('should create Stack', done => { + client.stack() + .create(newStack, { organization_uid: orgID }) + .then((stack) => { + jsonWrite(stack, 'stack.json') + expect(stack.org_uid).to.be.equal(orgID) + expect(stack.api_key).to.not.equal(null) + expect(stack.name).to.be.equal(newStack.stack.name) + expect(stack.description).to.be.equal(newStack.stack.description) + done() + stacks = jsonReader('stack.json') + }) + .catch(done) + }) + + it('should fetch Stack details', done => { + client.stack({ api_key: stacks.api_key }) + .fetch() + .then((stack) => { + expect(stack.org_uid).to.be.equal(orgID) + expect(stack.api_key).to.not.equal(null) + expect(stack.name).to.be.equal(newStack.stack.name) + expect(stack.description).to.be.equal(newStack.stack.description) + done() + }) + .catch(done) + }) + + it('should update Stack details', done => { + const name = 'My New Stack Update Name' + const description = 'My New description stack' + client.stack({ api_key: stacks.api_key }) + .fetch().then((stack) => { + stack.name = name + stack.description = description + return stack.update() + }).then((stack) => { + expect(stack.name).to.be.equal(name) + expect(stack.description).to.be.equal(description) + done() + }) + .catch(done) + }) + + it('should get all users of stack', done => { + client.stack({ api_key: stacks.api_key }) + .users() + .then((response) => { + expect(response[0].uid).to.be.not.equal(null) + done() + }) + .catch(done) + }) + + it('should get stack settings', done => { + client.stack({ api_key: stacks.api_key }) + .settings() + .then((response) => { + expect(response.stack_variable).to.be.equal(undefined, 'Stack variable must be blank') + expect(response.discrete_variables.access_token).to.not.equal(null, 'Stack variable must not be blank') + expect(response.discrete_variables.secret_key).to.not.equal(null, 'Stack variable must not be blank') + done() + }) + .catch(done) + }) + + it('should add stack settings', done => { + client.stack({ api_key: stacks.api_key }) + .addSettings({ samplevariable: 'too' }) + .then((response) => { + expect(response.stack_variables.samplevariable).to.be.equal('too', 'samplevariable must set to \'too\' ') + done() + }) + .catch(done) + }) + + it('should reset stack settings', done => { + client.stack({ api_key: stacks.api_key }) + .resetSettings() + .then((response) => { + expect(response.stack_variable).to.be.equal(undefined, 'Stack variable must be blank') + expect(response.discrete_variables.access_token).to.not.equal(null, 'Stack variable must not be blank') + expect(response.discrete_variables.secret_key).to.not.equal(null, 'Stack variable must not be blank') + done() + }) + .catch(done) + }) + + it('should get all stack', done => { + client.stack() + .query() + .find() + .then((response) => { + for (const index in response.items) { + const stack = response.items[index] + expect(stack.name).to.not.equal(null) + expect(stack.uid).to.not.equal(null) + expect(stack.owner_uid).to.not.equal(null) + } + done() + }) + .catch(done) + }) + + it('should get query stack', done => { + client.stack() + .query({ query: { name: 'My New Stack Update Name' } }) + .find() + .then((response) => { + expect(response.items.length).to.be.equal(1) + for (const index in response.items) { + const stack = response.items[index] + expect(stack.name).to.be.equal('My New Stack Update Name') + } + done() + }) + .catch(done) + }) + + it('should find one stack', done => { + client.stack() + .query({ query: { name: 'My New Stack Update Name' } }) + .findOne() + .then((response) => { + const stack = response.items[0] + expect(response.items.length).to.be.equal(1) + expect(stack.name).to.be.equal('My New Stack Update Name') + done() + }) + .catch(done) + }) +}) diff --git a/test/sanity-check/api/user-test.js b/test/sanity-check/api/user-test.js index d47bdf73..aa7e21f2 100644 --- a/test/sanity-check/api/user-test.js +++ b/test/sanity-check/api/user-test.js @@ -10,7 +10,7 @@ var authtoken = '' var loggedinUserID = '' var client = contentstackClient() describe('Contentstack User Session api Test', () => { - it('User login wrong credentials', done => { + it('should check user login with wrong credentials', done => { contentstackClient().login({ email: process.env.EMAIL, password: process.env.PASSWORD }) .then((response) => { done() @@ -26,7 +26,7 @@ describe('Contentstack User Session api Test', () => { }) }) - it('User Login test', done => { + it('should Login user', done => { client.login({ email: process.env.EMAIL, password: process.env.PASSWORD }, { include_orgs: true, include_orgs_roles: true, include_stack_roles: true, include_user_settings: true }).then((response) => { jsonWrite(response.user, 'loggedinuser.json') expect(response.notice).to.be.equal('Login Successful.', 'Login success messsage does not match.') @@ -35,7 +35,7 @@ describe('Contentstack User Session api Test', () => { .catch(done) }) - it('User logout test', done => { + it('should logout user', done => { client.logout() .then((response) => { expect(axios.defaults.headers.common.authtoken).to.be.equal(undefined) @@ -45,7 +45,7 @@ describe('Contentstack User Session api Test', () => { .catch(done) }) - it('User login with credentials', done => { + it('should login with credentials', done => { client.login({ email: process.env.EMAIL, password: process.env.PASSWORD }, { include_orgs: true, include_orgs_roles: true, include_stack_roles: true, include_user_settings: true }).then((response) => { loggedinUserID = response.user.uid jsonWrite(response.user, 'loggedinuser.json') @@ -55,7 +55,7 @@ describe('Contentstack User Session api Test', () => { .catch(done) }) - it('Get Current user info test', done => { + it('should get Current user info test', done => { client.getUser().then((user) => { authtoken = user.authtoken expect(user.uid).to.be.equal(loggedinUserID) @@ -64,7 +64,7 @@ describe('Contentstack User Session api Test', () => { .catch(done) }) - it('Get user info from authtoken', done => { + it('should get user info from authtoken', done => { contentstackClient(authtoken) .getUser() .then((user) => { diff --git a/test/sanity-check/mock/berries.jfif b/test/sanity-check/mock/berries.jfif new file mode 100644 index 00000000..f0e4c1a0 Binary files /dev/null and b/test/sanity-check/mock/berries.jfif differ diff --git a/test/sanity-check/mock/customUpload.html b/test/sanity-check/mock/customUpload.html new file mode 100644 index 00000000..cfeb9844 --- /dev/null +++ b/test/sanity-check/mock/customUpload.html @@ -0,0 +1,28 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/test/sanity-check/mock/entry.js b/test/sanity-check/mock/entry.js new file mode 100644 index 00000000..16249e58 --- /dev/null +++ b/test/sanity-check/mock/entry.js @@ -0,0 +1,7 @@ +const entryFirst = { title: 'First page', url: '', single_line: 'First Single Line', multi_line: 'First Multi line', markdown: 'Mark Down list\n 1. List item\n 2. List item 2', modular_blocks: [], tags: [] } + +const entrySecond = { title: 'Second page', url: '', single_line: 'Second Single Line', multi_line: 'Second Multi line', markdown: 'Mark Down list\n 1. List item\n 2. List item 2', modular_blocks: [], tags: ['second'] } + +const entryThird = { title: 'Third page', url: '', single_line: 'Third Single Line', multi_line: 'Third Multi line', markdown: 'Mark Down list\n 1. List item\n 2. List item 2', modular_blocks: [], tags: ['third'] } + +export { entryFirst, entrySecond, entryThird } diff --git a/test/sanity-check/mock/entry.json b/test/sanity-check/mock/entry.json new file mode 100644 index 00000000..60515666 --- /dev/null +++ b/test/sanity-check/mock/entry.json @@ -0,0 +1 @@ +{ "title": "First page json", "url": "", "single_line": "First Single Line", "multi_line": "First Multi line", "markdown": "Mark Down list\n 1. List item\n 2. List item 2", "modular_blocks": [], "tags": [] } \ No newline at end of file diff --git a/test/sanity-check/mock/upload.html b/test/sanity-check/mock/upload.html new file mode 100644 index 00000000..cfeb9844 --- /dev/null +++ b/test/sanity-check/mock/upload.html @@ -0,0 +1,28 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/test/sanity-check/sanity.js b/test/sanity-check/sanity.js index 8faf2378..26273528 100644 --- a/test/sanity-check/sanity.js +++ b/test/sanity-check/sanity.js @@ -1,3 +1,7 @@ require('./api/user-test') +require('./api/organization-test') +require('./api/stack-test') require('./api/contentType-test') +require('./api/asset-test') +require('./api/entry-test') require('./api/contentType-delete-test')