mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
refactor: init cloud ui tests
This commit is contained in:
parent
08e7b6c6c2
commit
ac065ac60c
7 changed files with 51 additions and 12 deletions
15
.github/workflows/integration-test.yml
vendored
15
.github/workflows/integration-test.yml
vendored
|
@ -38,7 +38,7 @@ jobs:
|
|||
|
||||
strategy:
|
||||
matrix:
|
||||
test_target: [api, ui]
|
||||
test_target: [api, ui, ui-cloud]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
|
@ -78,7 +78,11 @@ jobs:
|
|||
- name: Extract
|
||||
working-directory: tests
|
||||
run: |
|
||||
npm run cli init -- -p ../logto --db postgres://postgres:postgres@localhost:5432/postgres --du ../logto.tar.gz
|
||||
npm run cli init -- \
|
||||
-p ../logto \
|
||||
--db postgres://postgres:postgres@localhost:5432/postgres \
|
||||
--du ../logto.tar.gz \
|
||||
${{ contains(matrix.test_target, 'cloud') && '--cloud' || '' }}
|
||||
|
||||
- name: Check and add mock connectors
|
||||
working-directory: tests
|
||||
|
@ -92,6 +96,13 @@ jobs:
|
|||
env:
|
||||
INTEGRATION_TEST: true
|
||||
|
||||
- name: Run Logto Cloud
|
||||
working-directory: logto/
|
||||
if: contains(matrix.test_target, 'cloud')
|
||||
run: nohup npm start:cloud > nohup-cloud.out 2> nohup-cloud.err < /dev/null &
|
||||
env:
|
||||
INTEGRATION_TEST: true
|
||||
|
||||
- name: Sleep for 5 seconds
|
||||
run: sleep 5
|
||||
|
||||
|
|
|
@ -18,11 +18,11 @@ import {
|
|||
export type InstallArgs = {
|
||||
path?: string;
|
||||
skipSeed: boolean;
|
||||
officialConnectors?: boolean;
|
||||
cloud: boolean;
|
||||
downloadUrl?: string;
|
||||
};
|
||||
|
||||
const installLogto = async ({ path, skipSeed, officialConnectors, downloadUrl }: InstallArgs) => {
|
||||
const installLogto = async ({ path, skipSeed, downloadUrl, cloud }: InstallArgs) => {
|
||||
validateNodeVersion();
|
||||
|
||||
// Get instance path
|
||||
|
@ -44,7 +44,7 @@ const installLogto = async ({ path, skipSeed, officialConnectors, downloadUrl }:
|
|||
)} command to seed database when ready.\n`
|
||||
);
|
||||
} else {
|
||||
await seedDatabase(instancePath);
|
||||
await seedDatabase(instancePath, cloud);
|
||||
}
|
||||
|
||||
// Save to dot env
|
||||
|
@ -59,7 +59,7 @@ const install: CommandModule<
|
|||
{
|
||||
p?: string;
|
||||
ss: boolean;
|
||||
oc?: boolean;
|
||||
cloud: boolean;
|
||||
du?: string;
|
||||
}
|
||||
> = {
|
||||
|
@ -78,10 +78,11 @@ const install: CommandModule<
|
|||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
oc: {
|
||||
alias: 'official-connectors',
|
||||
describe: 'Add official connectors after downloading Logto',
|
||||
cloud: {
|
||||
describe: 'Init Logto for cloud',
|
||||
type: 'boolean',
|
||||
hidden: true,
|
||||
default: false,
|
||||
},
|
||||
du: {
|
||||
alias: 'download-url',
|
||||
|
@ -90,8 +91,8 @@ const install: CommandModule<
|
|||
hidden: true,
|
||||
},
|
||||
}),
|
||||
handler: async ({ p, ss, oc, du }) => {
|
||||
await installLogto({ path: p, skipSeed: ss, officialConnectors: oc, downloadUrl: du });
|
||||
handler: async ({ p, ss, cloud, du }) => {
|
||||
await installLogto({ path: p, skipSeed: ss, cloud, downloadUrl: du });
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ export const decompress = async (toPath: string, tarPath: string) => {
|
|||
);
|
||||
};
|
||||
|
||||
export const seedDatabase = async (instancePath: string) => {
|
||||
export const seedDatabase = async (instancePath: string, cloud: boolean) => {
|
||||
try {
|
||||
const pool = await createPoolAndDatabaseIfNeeded();
|
||||
await seedByPool(pool);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
"test": "pnpm build && pnpm test:api && pnpm test:ui",
|
||||
"test:api": "pnpm test:only -i ./lib/tests/api",
|
||||
"test:ui": "pnpm test:only -i --config=jest.config.ui.js ./lib/tests/ui",
|
||||
"test:ui-cloud": "pnpm test:only -i --config=jest.config.ui.js ./lib/tests/ui-cloud",
|
||||
"lint": "eslint --ext .ts src",
|
||||
"lint:report": "pnpm lint --format json --output-file report.json",
|
||||
"start": "pnpm test"
|
||||
|
|
|
@ -6,6 +6,7 @@ export const logtoConsoleUrl = getEnv(
|
|||
'INTEGRATION_TESTS_LOGTO_CONSOLE_URL',
|
||||
'http://localhost:3002'
|
||||
);
|
||||
export const logtoCloudUrl = getEnv('INTEGRATION_TESTS_LOGTO_CLOUD_URL', 'http://localhost:3003');
|
||||
|
||||
export const discoveryUrl = `${logtoUrl}/oidc/.well-known/openid-configuration`;
|
||||
|
||||
|
|
21
packages/integration-tests/src/tests/ui-cloud/smoke.test.ts
Normal file
21
packages/integration-tests/src/tests/ui-cloud/smoke.test.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { logtoCloudUrl, logtoConsoleUrl } from '#src/constants.js';
|
||||
import { generatePassword } from '#src/utils.js';
|
||||
|
||||
/**
|
||||
* NOTE: This test suite assumes test cases will run sequentially (which is Jest default).
|
||||
* Parallel execution will lead to errors.
|
||||
*/
|
||||
describe('smoke testing for cloud', () => {
|
||||
const consoleUsername = 'admin';
|
||||
const consolePassword = generatePassword();
|
||||
const adminTenantUrl = logtoConsoleUrl; // In dev mode, the console URL is actually for admin tenant
|
||||
|
||||
it('opens with app element and navigates to sign-in page', async () => {
|
||||
const navigation = page.waitForNavigation({ waitUntil: 'networkidle0' });
|
||||
await page.goto(logtoCloudUrl);
|
||||
await navigation;
|
||||
|
||||
await expect(page.waitForSelector('#app')).resolves.not.toBeNull();
|
||||
expect(page.url()).toBe(new URL('sign-in', adminTenantUrl).href);
|
||||
});
|
||||
});
|
|
@ -1,6 +1,10 @@
|
|||
import { logtoConsoleUrl } from '#src/constants.js';
|
||||
import { generatePassword } from '#src/utils.js';
|
||||
|
||||
/**
|
||||
* NOTE: This test suite assumes test cases will run sequentially (which is Jest default).
|
||||
* Parallel execution will lead to errors.
|
||||
*/
|
||||
describe('smoke testing', () => {
|
||||
const consoleUsername = 'admin';
|
||||
const consolePassword = generatePassword();
|
||||
|
|
Loading…
Reference in a new issue