Skip to content

Commit d9524de

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

4 files changed

Lines changed: 42 additions & 8 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ temp/
5959
test/e2e/allure-results/
6060
test/e2e/allure-report/
6161
test/e2e/.wdio-vscode-service/
62+
test/e2e/.env

test/e2e/README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ cd test/e2e
99
pnpm install
1010
```
1111

12+
## Environment variables
13+
14+
End-to-end runs require Cloudinary credentials in `process.env`. The `onPrepare` hook in `wdio.conf.ts` reads `E2E_CLOUD`, `E2E_API_KEY`, and `E2E_API_SECRET`, then writes `~/.cloudinary/environments.json` in the shape the extension expects (cloud name as the top-level key, with `apiKey` and `apiSecret`).
15+
16+
| Variable | Description |
17+
|----------|-------------|
18+
| `E2E_CLOUD` | Cloudinary cloud name |
19+
| `E2E_API_KEY` | API key |
20+
| `E2E_API_SECRET` | API secret |
21+
22+
**Local:** add a `test/e2e/.env` file (gitignored) such as:
23+
1224
## Running Tests
1325

1426
```bash
@@ -18,7 +30,7 @@ pnpm test:e2e
1830
This will:
1931
1. Download a VS Code binary (if not already cached in `.wdio-vscode-service/`)
2032
2. Launch VS Code with the extension loaded
21-
3. Run all specs in `test/specs/`
33+
3. Run all specs in `specs/`
2234

2335
## Viewing Reports
2436

@@ -35,8 +47,7 @@ test/e2e/
3547
├── wdio.conf.ts # WebdriverIO configuration
3648
├── tsconfig.json # TypeScript config for e2e tests
3749
├── package.json # Dependencies (separate from root)
38-
├── test/
39-
│ └── specs/ # Test spec files
50+
├── specs/ # Test spec files
4051
├── src/
4152
│ └── utils/ # Page object utilities
4253
```
@@ -46,8 +57,8 @@ test/e2e/
4657
Tests use [Mocha](https://mochajs.org/) as the test framework and the `wdio-vscode-service` page objects to interact with VS Code.
4758

4859
```ts
49-
import { activityBarUtils } from '../../src/utils/ActivityBarUtils'
50-
import { sideBarViewUtils } from '../../src/utils/SideBarViewUtils'
60+
import { activityBarUtils } from '../src/utils/ActivityBarUtils.js'
61+
import { sideBarViewUtils } from '../src/utils/SideBarViewUtils.js'
5162

5263
it('should open the Cloudinary view', async () => {
5364
await activityBarUtils.openView('Cloudinary')

test/e2e/specs/loadMlAssets.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { sideBarViewUtils } from '../src/utils/SideBarViewUtils.js'
77
*/
88
it('should load cloudinary media library', async () => {
99
const expectedTitle = 'CLOUDINARY';
10-
const expectedItems = ['cats', 'dogs'];
10+
const expectedItems = ['samples', 'sample'];
1111

1212
await activityBarUtils.openView('Cloudinary');
1313

test/e2e/wdio.conf.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as fs from 'node:fs';
2+
import * as os from 'node:os';
13
import { fileURLToPath } from 'node:url';
24
import * as path from 'node:path';
35

@@ -169,8 +171,28 @@ export const config: WebdriverIO.Config = {
169171
* @param {object} config wdio configuration object
170172
* @param {Array.<Object>} capabilities list of capabilities details
171173
*/
172-
// onPrepare: function (config, capabilities) {
173-
// },
174+
onPrepare: function () {
175+
/**
176+
* Write the Cloudinary credentials to the global config file.
177+
* the file location is ~/.cloudinary/environments.json
178+
*/
179+
const cloudName = process.env.E2E_CLOUD;
180+
const apiKey = process.env.E2E_API_KEY;
181+
const apiSecret = process.env.E2E_API_SECRET;
182+
if (!cloudName || !apiKey || !apiSecret) {
183+
throw new Error(
184+
'E2E setup requires E2E_CLOUD, E2E_API_KEY, and E2E_API_SECRET in the process environment.'
185+
);
186+
}
187+
188+
const cloudinaryDir = path.join(os.homedir(), '.cloudinary');
189+
fs.mkdirSync(cloudinaryDir, { recursive: true });
190+
const outPath = path.join(cloudinaryDir, 'environments.json');
191+
const environments = {
192+
[cloudName]: { apiKey, apiSecret },
193+
};
194+
fs.writeFileSync(outPath, `${JSON.stringify(environments, null, 2)}\n`, 'utf-8');
195+
},
174196
/**
175197
* Gets executed before a worker process is spawned and can be used to initialize specific service
176198
* for that worker as well as modify runtime environments in an async fashion.

0 commit comments

Comments
 (0)