mirror of
https://github.com/logto-io/logto.git
synced 2024-12-30 20:33:54 -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:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
test_target: [api, ui]
|
test_target: [api, ui, ui-cloud]
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
@ -78,7 +78,11 @@ jobs:
|
||||||
- name: Extract
|
- name: Extract
|
||||||
working-directory: tests
|
working-directory: tests
|
||||||
run: |
|
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
|
- name: Check and add mock connectors
|
||||||
working-directory: tests
|
working-directory: tests
|
||||||
|
@ -92,6 +96,13 @@ jobs:
|
||||||
env:
|
env:
|
||||||
INTEGRATION_TEST: true
|
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
|
- name: Sleep for 5 seconds
|
||||||
run: sleep 5
|
run: sleep 5
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,11 @@ import {
|
||||||
export type InstallArgs = {
|
export type InstallArgs = {
|
||||||
path?: string;
|
path?: string;
|
||||||
skipSeed: boolean;
|
skipSeed: boolean;
|
||||||
officialConnectors?: boolean;
|
cloud: boolean;
|
||||||
downloadUrl?: string;
|
downloadUrl?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const installLogto = async ({ path, skipSeed, officialConnectors, downloadUrl }: InstallArgs) => {
|
const installLogto = async ({ path, skipSeed, downloadUrl, cloud }: InstallArgs) => {
|
||||||
validateNodeVersion();
|
validateNodeVersion();
|
||||||
|
|
||||||
// Get instance path
|
// Get instance path
|
||||||
|
@ -44,7 +44,7 @@ const installLogto = async ({ path, skipSeed, officialConnectors, downloadUrl }:
|
||||||
)} command to seed database when ready.\n`
|
)} command to seed database when ready.\n`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
await seedDatabase(instancePath);
|
await seedDatabase(instancePath, cloud);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save to dot env
|
// Save to dot env
|
||||||
|
@ -59,7 +59,7 @@ const install: CommandModule<
|
||||||
{
|
{
|
||||||
p?: string;
|
p?: string;
|
||||||
ss: boolean;
|
ss: boolean;
|
||||||
oc?: boolean;
|
cloud: boolean;
|
||||||
du?: string;
|
du?: string;
|
||||||
}
|
}
|
||||||
> = {
|
> = {
|
||||||
|
@ -78,10 +78,11 @@ const install: CommandModule<
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
oc: {
|
cloud: {
|
||||||
alias: 'official-connectors',
|
describe: 'Init Logto for cloud',
|
||||||
describe: 'Add official connectors after downloading Logto',
|
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
|
hidden: true,
|
||||||
|
default: false,
|
||||||
},
|
},
|
||||||
du: {
|
du: {
|
||||||
alias: 'download-url',
|
alias: 'download-url',
|
||||||
|
@ -90,8 +91,8 @@ const install: CommandModule<
|
||||||
hidden: true,
|
hidden: true,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
handler: async ({ p, ss, oc, du }) => {
|
handler: async ({ p, ss, cloud, du }) => {
|
||||||
await installLogto({ path: p, skipSeed: ss, officialConnectors: oc, downloadUrl: 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 {
|
try {
|
||||||
const pool = await createPoolAndDatabaseIfNeeded();
|
const pool = await createPoolAndDatabaseIfNeeded();
|
||||||
await seedByPool(pool);
|
await seedByPool(pool);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
"test": "pnpm build && pnpm test:api && pnpm test:ui",
|
"test": "pnpm build && pnpm test:api && pnpm test:ui",
|
||||||
"test:api": "pnpm test:only -i ./lib/tests/api",
|
"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": "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": "eslint --ext .ts src",
|
||||||
"lint:report": "pnpm lint --format json --output-file report.json",
|
"lint:report": "pnpm lint --format json --output-file report.json",
|
||||||
"start": "pnpm test"
|
"start": "pnpm test"
|
||||||
|
|
|
@ -6,6 +6,7 @@ export const logtoConsoleUrl = getEnv(
|
||||||
'INTEGRATION_TESTS_LOGTO_CONSOLE_URL',
|
'INTEGRATION_TESTS_LOGTO_CONSOLE_URL',
|
||||||
'http://localhost:3002'
|
'http://localhost:3002'
|
||||||
);
|
);
|
||||||
|
export const logtoCloudUrl = getEnv('INTEGRATION_TESTS_LOGTO_CLOUD_URL', 'http://localhost:3003');
|
||||||
|
|
||||||
export const discoveryUrl = `${logtoUrl}/oidc/.well-known/openid-configuration`;
|
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 { logtoConsoleUrl } from '#src/constants.js';
|
||||||
import { generatePassword } from '#src/utils.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', () => {
|
describe('smoke testing', () => {
|
||||||
const consoleUsername = 'admin';
|
const consoleUsername = 'admin';
|
||||||
const consolePassword = generatePassword();
|
const consolePassword = generatePassword();
|
||||||
|
|
Loading…
Reference in a new issue