mirror of
https://github.com/logto-io/logto.git
synced 2024-12-30 20:33:54 -05:00
refactor(console,experience,test): decouple isDevFeatureEnabled with isIntegrationTest (#6012)
* refactor(console,experience,test): decouple isDevFeatureEnabled with isIntegrationTest decouple isDevFeatureEnabled with isIntegrationTest ENV variables * chore: update environment variable get method update environment variable get method
This commit is contained in:
parent
a02c20a664
commit
ed37356ee3
7 changed files with 17 additions and 8 deletions
|
@ -50,6 +50,7 @@ jobs:
|
||||||
if: ${{needs.check-alteration-changes.outputs.has-alteration-changes == 'true'}}
|
if: ${{needs.check-alteration-changes.outputs.has-alteration-changes == 'true'}}
|
||||||
env:
|
env:
|
||||||
INTEGRATION_TEST: true
|
INTEGRATION_TEST: true
|
||||||
|
DEV_FEATURES_ENABLED: true
|
||||||
steps:
|
steps:
|
||||||
- uses: logto-io/actions-package-logto-artifact@v2
|
- uses: logto-io/actions-package-logto-artifact@v2
|
||||||
with:
|
with:
|
||||||
|
@ -66,6 +67,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
INTEGRATION_TEST: true
|
INTEGRATION_TEST: true
|
||||||
|
DEV_FEATURES_ENABLED: true
|
||||||
DB_URL: postgres://postgres:postgres@localhost:5432/postgres
|
DB_URL: postgres://postgres:postgres@localhost:5432/postgres
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
2
.github/workflows/integration-test.yml
vendored
2
.github/workflows/integration-test.yml
vendored
|
@ -16,6 +16,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
INTEGRATION_TEST: true
|
INTEGRATION_TEST: true
|
||||||
|
DEV_FEATURES_ENABLED: true
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: logto-io/actions-package-logto-artifact@v2
|
- uses: logto-io/actions-package-logto-artifact@v2
|
||||||
|
@ -32,6 +33,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
INTEGRATION_TEST: true
|
INTEGRATION_TEST: true
|
||||||
|
DEV_FEATURES_ENABLED: true
|
||||||
DB_URL: postgres://postgres:postgres@localhost:5432/postgres
|
DB_URL: postgres://postgres:postgres@localhost:5432/postgres
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
|
@ -9,5 +9,4 @@ export const adminEndpoint = process.env.ADMIN_ENDPOINT;
|
||||||
export const isDevFeaturesEnabled =
|
export const isDevFeaturesEnabled =
|
||||||
!isProduction ||
|
!isProduction ||
|
||||||
yes(process.env.DEV_FEATURES_ENABLED) ||
|
yes(process.env.DEV_FEATURES_ENABLED) ||
|
||||||
yes(process.env.INTEGRATION_TEST) ||
|
|
||||||
yes(localStorage.getItem(storageKeys.isDevFeaturesEnabled));
|
yes(localStorage.getItem(storageKeys.isDevFeaturesEnabled));
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import { yes } from '@silverhand/essentials';
|
import { yes } from '@silverhand/essentials';
|
||||||
|
|
||||||
export const isDevFeaturesEnabled =
|
export const isDevFeaturesEnabled =
|
||||||
process.env.NODE_ENV !== 'production' ||
|
process.env.NODE_ENV !== 'production' || yes(process.env.DEV_FEATURES_ENABLED);
|
||||||
yes(process.env.DEV_FEATURES_ENABLED) ||
|
|
||||||
yes(process.env.INTEGRATION_TEST);
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import {
|
import {
|
||||||
type CreateSsoConnector,
|
|
||||||
SignInIdentifier,
|
SignInIdentifier,
|
||||||
SsoProviderName,
|
SsoProviderName,
|
||||||
demoAppApplicationId,
|
demoAppApplicationId,
|
||||||
|
type CreateSsoConnector,
|
||||||
} from '@logto/schemas';
|
} from '@logto/schemas';
|
||||||
import { appendPath, getEnv } from '@silverhand/essentials';
|
import { appendPath, getEnv, yes } from '@silverhand/essentials';
|
||||||
|
|
||||||
export const logtoUrl = getEnv('INTEGRATION_TESTS_LOGTO_URL', 'http://localhost:3001');
|
export const logtoUrl = getEnv('INTEGRATION_TESTS_LOGTO_URL', 'http://localhost:3001');
|
||||||
export const logtoOidcUrl = appendPath(new URL(logtoUrl), 'oidc').toString();
|
export const logtoOidcUrl = appendPath(new URL(logtoUrl), 'oidc').toString();
|
||||||
|
@ -47,3 +47,5 @@ export const newOidcSsoConnectorPayload = {
|
||||||
issuer: `${logtoUrl}/oidc`,
|
issuer: `${logtoUrl}/oidc`,
|
||||||
},
|
},
|
||||||
} satisfies Partial<CreateSsoConnector>;
|
} satisfies Partial<CreateSsoConnector>;
|
||||||
|
|
||||||
|
export const isDevFeaturesEnabled = yes(getEnv('DEV_FEATURES_ENABLED'));
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { authedAdminTenantApi } from '#src/api/api.js';
|
||||||
import {
|
import {
|
||||||
consolePassword,
|
consolePassword,
|
||||||
consoleUsername,
|
consoleUsername,
|
||||||
|
isDevFeaturesEnabled,
|
||||||
logtoConsoleUrl as logtoConsoleUrlString,
|
logtoConsoleUrl as logtoConsoleUrlString,
|
||||||
} from '#src/constants.js';
|
} from '#src/constants.js';
|
||||||
import { appendPathname, cls, dcls, expectNavigation, waitFor } from '#src/utils.js';
|
import { appendPathname, cls, dcls, expectNavigation, waitFor } from '#src/utils.js';
|
||||||
|
@ -135,4 +136,10 @@ describe('smoke testing for console admin account creation and sign-in', () => {
|
||||||
);
|
);
|
||||||
await expect(page).toMatchElement(activeSelector, { text: 'Dashboard', visible: true });
|
await expect(page).toMatchElement(activeSelector, { text: 'Dashboard', visible: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it(`should ${isDevFeaturesEnabled ? '' : 'not '}show the dev features label`, async () => {
|
||||||
|
await (isDevFeaturesEnabled
|
||||||
|
? expect(page).toMatchElement('div', { text: 'Dev features enabled' })
|
||||||
|
: expect(page).not.toMatchElement('div', { text: 'Dev features enabled' }));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
3
packages/shared/src/node/env/GlobalValues.ts
vendored
3
packages/shared/src/node/env/GlobalValues.ts
vendored
|
@ -7,8 +7,7 @@ export default class GlobalValues {
|
||||||
public readonly isProduction = getEnv('NODE_ENV') === 'production';
|
public readonly isProduction = getEnv('NODE_ENV') === 'production';
|
||||||
public readonly isIntegrationTest = yes(getEnv('INTEGRATION_TEST'));
|
public readonly isIntegrationTest = yes(getEnv('INTEGRATION_TEST'));
|
||||||
public readonly isUnitTest = getEnv('NODE_ENV') === 'test';
|
public readonly isUnitTest = getEnv('NODE_ENV') === 'test';
|
||||||
public readonly isDevFeaturesEnabled =
|
public readonly isDevFeaturesEnabled = !this.isProduction || yes(getEnv('DEV_FEATURES_ENABLED'));
|
||||||
!this.isProduction || yes(getEnv('DEV_FEATURES_ENABLED')) || this.isIntegrationTest;
|
|
||||||
|
|
||||||
public readonly httpsCert = process.env.HTTPS_CERT_PATH;
|
public readonly httpsCert = process.env.HTTPS_CERT_PATH;
|
||||||
public readonly httpsKey = process.env.HTTPS_KEY_PATH;
|
public readonly httpsKey = process.env.HTTPS_KEY_PATH;
|
||||||
|
|
Loading…
Reference in a new issue