Skip to content

Commit

Permalink
Test platform swithed from
Browse files Browse the repository at this point in the history
  • Loading branch information
MrRefactoring committed Aug 17, 2024
1 parent 0d76aad commit ad74bc8
Show file tree
Hide file tree
Showing 66 changed files with 2,231 additions and 3,111 deletions.
4,010 changes: 1,556 additions & 2,454 deletions package-lock.json

Large diffs are not rendered by default.

38 changes: 12 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"lint:fix": "npm run lint:tests -- --fix && npm run lint:examples -- --fix && npm run lint:src:agile -- --fix && npm run lint:src:clients -- --fix && npm run lint:src:services -- --fix && npm run lint:src:version2 -- --fix && npm run lint:src:version3 -- --fix && npm run lint:src:serviceDesk -- --fix && npm run lint:src:files -- --fix",
"doc": "typedoc --name \"Jira.js - Jira Cloud API library\" --out docs ./src/index.ts --plugin typedoc-plugin-extras --footerDate --footerTime --footerTypedocVersion --favicon https://svgshare.com/i/bHF.svg",
"test": "npm run test:unit && npm run test:integration",
"test:unit": "ava tests/unit --timeout=2m -с 8",
"test:integration": "ava --timeout=2m --fail-fast --no-worker-threads -c 1 -s tests/integration/**/*.test.ts",
"test:unit": "vitest run tests/unit --maxWorkers=8 --sequence.concurrent",
"test:integration": "avitest --bail=1 --no-file-parallelism --max-concurrency 1 tests/integration",
"replace:all": "npm run replace:permissions:version2 && npm run replace:permissions:version3 && npm run replace:pagination:version2 && npm run replace:pagination:version3 && npm run replace:async:version2 && npm run replace:async:version3 && npm run replace:expansion:version2 && npm run replace:expansion:version3 && npm run replace:ordering:version2 && npm run replace:ordering:version3 && npm run replace:groupMember:version2 && npm run replace:workflowPaginated:version2",
"replace:permissions:version2": "grep -rl \"(#permissions)\" ./src/version2 | xargs sed -i '' 's/(#permissions)/(https:\\/\\/developer.atlassian.com\\/cloud\\/jira\\/platform\\/rest\\/v2\\/intro\\/#permissions)/g'",
"replace:permissions:version3": "grep -rl \"(#permissions)\" ./src/version3 | xargs sed -i '' 's/(#permissions)/(https:\\/\\/developer.atlassian.com\\/cloud\\/jira\\/platform\\/rest\\/v3\\/intro\\/#permissions)/g'",
Expand All @@ -52,41 +52,27 @@
"replace:workflowPaginated:version2": "grep -rl \"(#api-rest-api-2-workflow-search-get)\" ./src/version2 | xargs sed -i '' 's/(#api-rest-api-2-workflow-search-get)/(https:\\/\\/developer.atlassian.com\\/cloud\\/jira\\/platform\\/rest\\/v2\\/api-group-workflows\\/#api-rest-api-2-workflow-search-get)/g'",
"code:formatting": "npm run replace:all && npm run prettier && npm run lint:fix"
},
"ava": {
"extensions": [
"ts"
],
"require": [
"@swc-node/register",
"dotenv/config"
],
"environmentVariables": {
"SWC_NODE_PROJECT": "./tsconfig.lint.json"
}
},
"devDependencies": {
"@swc-node/register": "^1.9.2",
"@swc/helpers": "^0.5.11",
"@types/node": "^18.19.38",
"@types/node": "^18.19.44",
"@types/sinon": "^17.0.3",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "^7.13.1",
"ava": "^6.1.3",
"@typescript-eslint/eslint-plugin": "^8.1.0",
"@typescript-eslint/parser": "^8.1.0",
"dotenv": "^16.4.5",
"eslint": "^8.57.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"prettier": "^3.3.2",
"prettier": "^3.3.3",
"prettier-plugin-jsdoc": "^1.3.0",
"sinon": "^18.0.0",
"ts-node": "^10.9.2",
"typedoc": "^0.25.13",
"typedoc-plugin-extras": "^3.0.0",
"typescript": "^5.4.5"
"typedoc": "^0.26.5",
"typedoc-plugin-extras": "^3.1.0",
"typescript": "^5.5.4",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^2.0.5"
},
"dependencies": {
"axios": "^1.7.2",
"axios": "^1.7.4",
"form-data": "^4.0.0",
"tslib": "^2.6.3"
}
Expand Down
49 changes: 24 additions & 25 deletions tests/integration/agile/sprint.test.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import test from 'ava';
import { AgileModels } from '../../../src';
import { Constants } from '../constants';
import { afterAll, beforeAll, test } from 'vitest';
import { AgileModels } from '@jirajs';
import { Constants } from '@tests/constants';
import {
createAgileProject, deleteAgileProject, getAgileClient, getVersion3Client,
} from '../utils';
createAgileProject,
deleteAgileProject,
getAgileClient,
getVersion3Client,
} from '@tests/utils';

const client = getAgileClient();

let board: any;
let sprint: AgileModels.Sprint;

test.before(async () => {
beforeAll(async () => {
await createAgileProject();
});

test.after(async () => {
afterAll(async () => {
await deleteAgileProject();
});

test.serial('should create new sprint', async t => {
test.sequential('should create new sprint', async ({ expect }) => {
const boards = await client.board.getAllBoards({ name: Constants.testAgileProjectKey });

t.is(boards.total, 1);
expect(boards.total).toBe(1);

[board] = boards.values;

Expand All @@ -30,12 +33,12 @@ test.serial('should create new sprint', async t => {
originBoardId: board.id,
});

t.truthy(!!sprint);
t.is(sprint.name, 'New sprint');
t.is(sprint.state, 'future');
expect(!!sprint).toBeTruthy();
expect(sprint.name).toBe('New sprint');
expect(sprint.state).toBe('future');
});

test.serial('should create and move task to sprint', async t => {
test.sequential('should create and move task to sprint', async ({ expect }) => {
const issue = await getVersion3Client().issues.createIssue({
fields: {
summary: 'Test task',
Expand All @@ -57,33 +60,29 @@ test.serial('should create and move task to sprint', async t => {
issues: [issue.key],
});

t.truthy(!!issue);
expect(!!issue).toBeTruthy();
});

test.serial('should return issues for sprint', async t => {
test.sequential('should return issues for sprint', async ({ expect }) => {
const { issues } = await client.sprint.getIssuesForSprint({
sprintId: sprint.id,
});

t.truthy(!!issues);
t.is(issues[0].fields?.summary, 'Test task');
expect(!!issues).toBeTruthy();
expect(issues[0].fields?.summary).toBe('Test task');
});

test.serial('should partially update sprint', async t => {
test.sequential('should partially update sprint', async ({ expect }) => {
const newSprint = await client.sprint.partiallyUpdateSprint({
sprintId: sprint.id,
state: 'active',
startDate: new Date(),
endDate: new Date(Date.now() + 1000),
});

t.is(newSprint.state, 'active');
expect(newSprint.state).toBe('active');
});

test.serial('should remove sprint', async t => {
await client.sprint.deleteSprint({
sprintId: sprint.id,
});

t.pass();
test.sequential('should remove sprint', async ({ expect }) => {
await client.sprint.deleteSprint({ sprintId: sprint.id });
});
4 changes: 2 additions & 2 deletions tests/integration/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './constants';
export * as Utils from './utils';
export * from '@tests/constants';
export * as Utils from '@tests/utils';
2 changes: 1 addition & 1 deletion tests/integration/utils/createAgileProject.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Constants } from '../constants';
import { Constants } from '@tests/constants';
import { getVersion3Client } from './getClient';

export const createAgileProject = async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/utils/createIssue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Constants } from '../constants';
import { Constants } from '@tests/constants';
import { getVersion2Client } from './getClient';

export const createIssue = async () => {
Expand Down
7 changes: 5 additions & 2 deletions tests/integration/utils/createSoftwareProject.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { AxiosError } from 'axios';
import { Constants } from '../constants';
import { Constants } from '@tests/constants';
import { getVersion2Client } from './getClient';

export const createSoftwareProject = async () => {
const client = getVersion2Client();
const currentUser = await client.myself.getCurrentUser();

if (!currentUser.accountId) throw new Error("Couldn't get the current user's account ID", { cause: { currentUser } });

return client.projects
.createProject({
key: Constants.testProjectKey,
name: Constants.testProjectName,
leadAccountId: '5b6d7f20e6dba529eefdbad9',
leadAccountId: currentUser.accountId,
projectTypeKey: 'software',
})
.catch((error: AxiosError) => {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/utils/deleteAgileProject.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Constants } from '../constants';
import { Constants } from '@tests/constants';
import { getVersion3Client } from './getClient';

export const deleteAgileProject = async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/utils/deleteSoftwareProject.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AxiosError } from 'axios';
import { Constants } from '../constants';
import { Constants } from '@tests/constants';
import { getVersion2Client } from './getClient';

export const deleteSoftwareProject = async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/utils/getClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ClientType, Config, createClient } from '../../../src';
import { ClientType, type Config, createClient } from '@jirajs';

const config = {
host: process.env.HOST!,
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/version2/avatars.test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import test from 'ava';
import { Avatar } from '../../../src/version3/models';
import { test } from 'vitest';
import type { Avatar } from '@jirajs/version3/models';
import { getVersion2Client } from '../utils';

const client = getVersion2Client();

let avatar: Avatar | undefined;

test.serial('should get all system avatars', async t => {
test.sequential('should get all system avatars', async ({ expect }) => {
const systemAvatars = await client.avatars.getAllSystemAvatars({ type: 'project' });

avatar = systemAvatars.system?.[0];

t.truthy(!!avatar);
expect(!!avatar).toBeTruthy();
});

test.serial('should return avatar image with contentType', async t => {
test.sequential('should return avatar image with contentType', async ({ expect }) => {
const avatarWithDetails = await client.avatars.getAvatarImageByID({ id: avatar!.id, type: 'project' });

t.is(avatarWithDetails.contentType, 'image/svg+xml');
t.truthy(avatarWithDetails.avatar instanceof Uint8Array);
expect(avatarWithDetails.contentType).toBe('image/svg+xml');
expect(avatarWithDetails.avatar instanceof Uint8Array).toBeTruthy();
});
22 changes: 11 additions & 11 deletions tests/integration/version2/dashboards.test.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import test from 'ava';
import { Constants } from '../constants';
import { getVersion2Client } from '../utils';
import { Version2Models } from '../../../src';
import { test } from 'vitest';
import { Version2Models } from '@jirajs';
import { Constants } from '@tests/constants';
import { getVersion2Client } from '@tests/utils';

let dashboard: Version2Models.Dashboard;
const client = getVersion2Client();

test.serial('should create dashboard', async t => {
test.sequential('should create dashboard', async ({ expect }) => {
dashboard = await client.dashboards.createDashboard({
name: Constants.testDashboardName,
sharePermissions: [],
});

t.truthy(!!dashboard);
t.is(dashboard.name, Constants.testDashboardName);
t.deepEqual(dashboard.sharePermissions, []);
expect(!!dashboard).toBeTruthy();
expect(dashboard.name).toBe(Constants.testDashboardName);
expect(dashboard.sharePermissions).toStrictEqual([]);
});

test.serial('should remove dashboard', async t => {
test.sequential('should remove dashboard', async ({ expect }) => {
const response = await client.dashboards.deleteDashboard({
id: dashboard.id,
});

t.is(typeof response, 'string');
t.is<string | void, string>(response, '');
expect(typeof response).toBe('string');
expect(response).toBe('');
});
18 changes: 9 additions & 9 deletions tests/integration/version2/groups.test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import test from 'ava';
import { Constants } from '..';
import { getVersion2Client } from '../utils';
import { test } from 'vitest';
import { Constants } from '@tests';
import { getVersion2Client } from '@tests/utils';

const client = getVersion2Client();

test.serial('should create a group', async t => {
test.sequential('should create a group', async ({ expect }) => {
const group = await client.groups.createGroup({
name: Constants.testGroupName,
});

t.truthy(!!group);
t.is(group.name, Constants.testGroupName);
expect(!!group).toBeTruthy();
expect(group.name).toBe(Constants.testGroupName);
});

test.serial('should remove a group', async t => {
test.sequential('should remove a group', async ({ expect }) => {
const response = await client.groups.removeGroup({
groupname: Constants.testGroupName,
});

t.is(typeof response, 'string');
t.is(response.trim(), '');
expect(typeof response).toBe('string');
expect(response.trim()).toBe('');
});
34 changes: 15 additions & 19 deletions tests/integration/version2/issueAttachments.test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import * as fs from 'fs';
import test from 'ava';
import { Constants } from '../constants';
import { Attachment, Issue } from '../../../src/version2/models';
import { cleanupEnvironment, getVersion2Client, prepareEnvironment } from '../utils';
import { afterAll, beforeAll, test } from 'vitest';
import type { Attachment, Issue } from '@jirajs/version2/models';
import { Constants } from '@tests/constants';
import { cleanupEnvironment, getVersion2Client, prepareEnvironment } from '@tests/utils';

const client = getVersion2Client({ noCheckAtlassianToken: true });

let issue: Issue;
let attachments: Attachment[];

test.before(async () => {
beforeAll(async () => {
await prepareEnvironment();
});

test.after(async () => {
afterAll(async () => {
await cleanupEnvironment();
});

test.skip('should add attachment', async t => {
test.sequential('should add attachment', async ({ expect }) => {
issue = await client.issues.createIssue({
fields: {
summary: 'Issue with attachment',
Expand All @@ -30,7 +30,7 @@ test.skip('should add attachment', async t => {
},
});

t.truthy(!!issue);
expect(!!issue).toBeTruthy();

attachments = await client.issueAttachments.addAttachment({
issueIdOrKey: issue.key,
Expand All @@ -40,21 +40,17 @@ test.skip('should add attachment', async t => {
},
});

t.truthy(!!attachments);
t.is(attachments[0].filename, 'issueAttachments.test.ts');
t.is(attachments[0].mimeType, 'video/mp2t');
expect(!!attachments).toBeTruthy();
expect(attachments[0].filename).toBe('issueAttachments.test.ts');
expect(attachments[0].mimeType).toBe('video/mp2t');
});

test.skip('should getAttachmentContent', async t => {
test.sequential('should getAttachmentContent', async ({ expect }) => {
const content = await client.issueAttachments.getAttachmentContent({ id: attachments[0].id });

t.truthy(Buffer.isBuffer(content));
expect(Buffer.isBuffer(content)).toBeTruthy();
});

test.skip('should remove attachment', async t => {
await client.issues.deleteIssue({
issueIdOrKey: issue.key,
});

t.pass();
test.sequential('should remove attachment', async ({ expect }) => {
await client.issues.deleteIssue({ issueIdOrKey: issue.key });
});
Loading

0 comments on commit ad74bc8

Please sign in to comment.