-
Notifications
You must be signed in to change notification settings - Fork 7
chore: rename e2e env vars from CONSOLEAPI_* to CONSOLE_API_* and add missing var check #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shazron
wants to merge
12
commits into
master
Choose a base branch
from
rename-env-vars
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
415054f
refactor: replace axios and form-data with Node built-in fetch and Fo…
shazron a3e0cd3
nit: fix e2e env vars
shazron b53601d
chore: rename e2e env vars from CONSOLEAPI_* to CONSOLE_API_* and add…
shazron 1a39566
remove outdated comment
shazron a1dca6f
e2e tests - moved commented out tests to e2e.credentials.js
shazron f7384bb
cleaned up e2e
shazron fa1c9ae
chore: add global e2e setup/teardown and move common code out of test…
shazron 9f25232
clarified IOC issues in comments
shazron 1ec67b0
chore: refactor e2e response assertions to use shared helper functions
shazron 867b501
chore: expand e2e test regex to all e2e files and skip credentials tests
shazron 71c9d1e
error out if Org not matched with getOrganizations call
shazron 76077b4
removed comment
shazron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| CONSOLEAPI_API_KEY= | ||
| CONSOLEAPI_ACCESS_TOKEN= | ||
| CONSOLEAPI_IMS_ORG_ID= | ||
| CONSOLEAPI_ENV= | ||
| CONSOLE_API_API_KEY= | ||
| CONSOLE_API_ACCESS_TOKEN= | ||
| CONSOLE_API_IMS_ORG_ID= | ||
| CONSOLE_API_ENV= |
This file contains hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| module.exports = { | ||
| testEnvironment: 'node', | ||
| globalSetup: './jest.globalSetup.js', | ||
| setupFilesAfterEnv: [ | ||
| '../test/jest/jest.setup.js' | ||
| './jest.setup.js' | ||
| ], | ||
| testRegex: './e2e/e2e.js' | ||
| testRegex: 'e2e/e2e.*\\.js$' | ||
| } |
This file contains hidden or 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,24 @@ | ||
| /* | ||
| Copyright 2026 Adobe. All rights reserved. | ||
| This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. You may obtain a copy | ||
| of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| Unless required by applicable law or agreed to in writing, software distributed under | ||
| the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| OF ANY KIND, either express or implied. See the License for the specific language | ||
| governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| const path = require('path') | ||
|
|
||
| // Runs once before any test suite. Validates that the required environment | ||
| // variables are present so tests fail fast with a clear error message. | ||
| module.exports = async () => { | ||
| require('dotenv').config({ path: path.join(__dirname, '.env') }) | ||
|
|
||
| const missingEnvVars = ['CONSOLE_API_API_KEY', 'CONSOLE_API_ACCESS_TOKEN', 'CONSOLE_API_IMS_ORG_ID'] | ||
| .filter(v => !process.env[v]?.trim()) | ||
| if (missingEnvVars.length > 0) { | ||
| throw new Error(`Missing required environment variables: ${missingEnvVars.join(', ')}`) | ||
| } | ||
| } |
This file contains hidden or 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,93 @@ | ||
| /* | ||
| Copyright 2023 Adobe. All rights reserved. | ||
| This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. You may obtain a copy | ||
| of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| Unless required by applicable law or agreed to in writing, software distributed under | ||
| the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| OF ANY KIND, either express or implied. See the License for the specific language | ||
| governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| // Runs in each test file's context (setupFilesAfterEnv). | ||
| // Provides shared globals: sdkClient, orgId, apiKey, accessToken, imsOrgId, env, findSDKCode. | ||
|
|
||
| const sdk = require('../src') | ||
| const path = require('path') | ||
| const services = require('../services.json') | ||
|
|
||
| require('dotenv').config({ path: path.join(__dirname, '.env') }) | ||
|
|
||
| jest.setTimeout(120000) | ||
|
|
||
| const { | ||
| CONSOLE_API_API_KEY: apiKey, | ||
| CONSOLE_API_ACCESS_TOKEN: accessToken, | ||
| CONSOLE_API_IMS_ORG_ID: imsOrgId, | ||
| CONSOLE_API_ENV: env = 'prod' | ||
| } = process.env | ||
|
|
||
| Object.assign(global, { apiKey, accessToken, imsOrgId, env }) | ||
|
|
||
| /** | ||
| * Finds the SDK code for a given SDK name from the services registry. | ||
| * | ||
| * @param {string} sdkName - The display name of the SDK service to look up. | ||
| * @returns {string|null} The SDK code if found, or null if no matching service exists. | ||
| */ | ||
| global.findSDKCode = function findSDKCode (sdkName) { | ||
| const service = services.find(service => service.name === sdkName) | ||
| return service ? service.code : null | ||
| } | ||
|
|
||
| /** | ||
| * Asserts that a response represents a successful HTTP 200 OK result. | ||
| * | ||
| * @param {object} res - The response object returned by the SDK client. | ||
| * @param {string} expectedBodyType - The expected typeof value for `res.body` (e.g. `'object'`, `'string'`). | ||
| */ | ||
| /* eslint-disable jest/no-standalone-expect */ | ||
| global.expectOkResponse = function expectOkResponse (res, expectedBodyType) { | ||
| expect(res.ok).toBe(true) | ||
| expect(res.status).toBe(200) | ||
| expect(res.statusText).toBe('OK') | ||
| expect(typeof res.body).toBe(expectedBodyType) | ||
| } | ||
| /* eslint-enable jest/no-standalone-expect */ | ||
|
|
||
| /** | ||
| * Asserts that a response represents a successful HTTP 201 Created result. | ||
| * | ||
| * @param {object} res - The response object returned by the SDK client. | ||
| * @param {string} expectedBodyType - The expected typeof value for `res.body` (e.g. `'object'`, `'string'`). | ||
| */ | ||
| /* eslint-disable jest/no-standalone-expect */ | ||
| global.expectCreatedResponse = function expectCreatedResponse (res, expectedBodyType) { | ||
| expect(res.ok).toBe(true) | ||
| expect(res.status).toBe(201) | ||
| expect(res.statusText).toBe('Created') | ||
| expect(typeof res.body).toBe(expectedBodyType) | ||
| } | ||
| /* eslint-enable jest/no-standalone-expect */ | ||
|
|
||
| /** | ||
| * Initializes the SDK client and resolves the organization ID for the configured IMS org. | ||
| * Runs once before all tests via `beforeAll`. | ||
| * | ||
| * @returns {Promise<void>} | ||
| */ | ||
| async function init () { | ||
| global.sdkClient = await sdk.init(accessToken, apiKey, env) | ||
| console.log(`Initialized SDK client with env ${env} and API key ${apiKey}`) | ||
|
|
||
| const res = await global.sdkClient.getOrganizations() | ||
| const org = res.body.find(item => item.code === imsOrgId) | ||
|
shazron marked this conversation as resolved.
|
||
| if (org) { | ||
| global.orgId = org.id | ||
| console.log(`Found organization with ID ${global.orgId}`) | ||
| } else { | ||
| throw new Error(`Organization with IMS org ID ${imsOrgId} not found in response from getOrganizations`) | ||
| } | ||
| } | ||
|
|
||
| beforeAll(init) | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.