Skip to content

Commit d58c7f9

Browse files
committed
feat: initial e2e setup with first test implemented
1 parent d9524de commit d58c7f9

6 files changed

Lines changed: 108 additions & 11 deletions

File tree

test/e2e/assets/sample_png.png

3.46 KB
Loading

test/e2e/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"@wdio/mocha-framework": "^9.27.0",
1111
"@wdio/spec-reporter": "^9.27.0",
1212
"allure-commandline": "^2.38.1",
13+
"cloudinary": "^2.9.0",
1314
"expect-webdriverio": "^5.6.5",
1415
"wdio-vscode-service": "^6.1.4"
1516
},

test/e2e/pnpm-lock.yaml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,37 @@
1+
import path from 'node:path';
2+
import { CloudinarySDK } from '../src/sdks/cloudinarySDK.js';
13
import { activityBarUtils } from '../src/utils/ActivityBarUtils.js'
24
import { sideBarViewUtils } from '../src/utils/SideBarViewUtils.js'
5+
import crypto from 'node:crypto';
6+
import { pathUtils } from '../src/utils/pathUtils.js';
37

4-
/**
5-
* Asset Explorer:
6-
* Validates that the title and content of the Cloudinary media library are loaded correctly.
7-
*/
8-
it('should load cloudinary media library', async () => {
9-
const expectedTitle = 'CLOUDINARY';
10-
const expectedItems = ['samples', 'sample'];
11-
12-
await activityBarUtils.openView('Cloudinary');
138

14-
await sideBarViewUtils.validateSideBarViewTitle(expectedTitle);
9+
describe('Asset Explorer Tetsts', () => {
1510

16-
await sideBarViewUtils.validateContentItemsExist(expectedItems);
11+
let cloudinarySDK = new CloudinarySDK();
12+
let assetPublicID = `e2e-test-ae-${crypto.randomUUID().substring(0, 8)}`;
13+
14+
beforeEach(async () => {
15+
await cloudinarySDK.V2.uploader.upload(path.join(pathUtils.getTestAssetsPath(), 'sample_png.png'), { public_id: assetPublicID });
16+
});
17+
18+
afterEach(async () => {
19+
await cloudinarySDK.V2.api.delete_resources([assetPublicID]);
20+
});
21+
22+
/**
23+
* Asset Explorer:
24+
* Validates that the title and content of the Cloudinary media library are loaded correctly.
25+
*/
26+
it('should load cloudinary media library', async () => {
27+
const expectedTitle = 'CLOUDINARY';
28+
const expectedItems = [assetPublicID];
29+
30+
await activityBarUtils.openView('Cloudinary');
31+
32+
await sideBarViewUtils.validateSideBarViewTitle(expectedTitle);
33+
34+
await sideBarViewUtils.validateContentItemsExist(expectedItems);
35+
});
1736
});
1837

test/e2e/src/sdks/cloudinarySDK.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import * as cloudinary from 'cloudinary';
2+
3+
/** Optional overrides; values fall back to `E2E_*` environment variables. */
4+
export type CloudinarySDKCredentials = {
5+
cloud_name?: string;
6+
api_key?: string;
7+
api_secret?: string;
8+
};
9+
10+
/**
11+
* Cloudinary sdk, see more here:
12+
* https://cloudinary.com/documentation/node_integration
13+
*/
14+
export class CloudinarySDK {
15+
public constructor(credentials?: CloudinarySDKCredentials) {
16+
const cloud_name = credentials?.cloud_name ?? process.env.E2E_CLOUD;
17+
const api_key = credentials?.api_key ?? process.env.E2E_API_KEY;
18+
const api_secret = credentials?.api_secret ?? process.env.E2E_API_SECRET;
19+
if (!cloud_name || !api_key || !api_secret) {
20+
throw new Error(
21+
'CloudinarySDK requires cloud_name, api_key, and api_secret (via optional parameters or E2E_CLOUD, E2E_API_KEY, E2E_API_SECRET in process.env).'
22+
);
23+
}
24+
cloudinary.v2.config({
25+
cloud_name,
26+
api_key,
27+
api_secret,
28+
upload_prefix: 'https://api.cloudinary.com',
29+
secure: true,
30+
});
31+
}
32+
33+
/**
34+
* Returns cloudinary v2
35+
*/
36+
get V2(): typeof cloudinary.v2 {
37+
return cloudinary.v2;
38+
}
39+
}

test/e2e/src/utils/pathUtils.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import path from 'node:path';
2+
import { fileURLToPath } from 'node:url';
3+
4+
const __filename = fileURLToPath(import.meta.url);
5+
const __dirname = path.dirname(__filename);
6+
7+
/**
8+
* Utility class for working paths.
9+
*/
10+
class PathUtils {
11+
/**
12+
* Gets the root path of the project.
13+
* @returns The root path of the project.
14+
*/
15+
public getProjectRootPath() {
16+
return path.resolve(__dirname, '..', '..', '..');
17+
}
18+
19+
/**
20+
* Gets the path to the test assets.
21+
*/
22+
public getTestAssetsPath() {
23+
return path.join(__dirname, '..', '..', 'assets');
24+
}
25+
}
26+
27+
export const pathUtils = new PathUtils();

0 commit comments

Comments
 (0)