Skip to content

Commit

Permalink
refactor: update test
Browse files Browse the repository at this point in the history
  • Loading branch information
gao-sun committed Sep 9, 2024
1 parent 9cc32f0 commit e2ea69f
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 32 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,21 @@ jobs:
DB_URL: postgres://postgres:postgres@localhost:5432/postgres

steps:
- uses: FedericoCarboni/setup-ffmpeg@v3
- uses: logto-io/actions-run-logto-integration-tests@v4
with:
logto-artifact: integration-test-${{ github.sha }}-dev-features-${{ env.DEV_FEATURES_ENABLED }}
test-target: ${{ matrix.target }}
pnpm-version: 9

- name: Upload test results
if: failure() && matrix.target == 'console'
uses: actions/upload-artifact@v4
with:
name: test-results-${{ github.sha }}-dev-features-${{ env.DEV_FEATURES_ENABLED }}
path: logto/packages/integration-tests/screencasts
retention-days: 7

# Automatically rerun the workflow since the integration tests are moody
# From this genius: https://github.com/orgs/community/discussions/67654#discussioncomment-8038649
rerun-on-failure:
Expand Down
2 changes: 1 addition & 1 deletion packages/integration-tests/FailFastEnvironment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// https://github.com/jestjs/jest/issues/6527#issuecomment-1463950981
import { TestEnvironment } from 'jest-environment-node';
import { TestEnvironment } from 'jest-environment-puppeteer';

class FailFastEnvironment extends TestEnvironment {
failedTest = false;
Expand Down
2 changes: 1 addition & 1 deletion packages/integration-tests/jest-puppeteer.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const config = {
launch: {
headless: Boolean(process.env.CI),
headless: true,
args: ['--accept-lang="en"'],
},
};
Expand Down
1 change: 0 additions & 1 deletion packages/integration-tests/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/** @type {import('jest').Config} */
const config = {
testEnvironment: './FailFastEnvironment.js',
transform: {},
testPathIgnorePatterns: ['/node_modules/'],
coverageProvider: 'v8',
Expand Down
1 change: 1 addition & 0 deletions packages/integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"eslint": "^8.56.0",
"expect-puppeteer": "^10.0.0",
"jest": "^29.7.0",
"jest-environment-puppeteer": "^10.1.1",
"jest-matcher-specific-error": "^1.0.0",
"jest-puppeteer": "^10.0.1",
"jose": "^5.6.3",
Expand Down
15 changes: 15 additions & 0 deletions packages/integration-tests/src/tests/console/bootstrap.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import fs from 'node:fs/promises';

import { type User } from '@logto/schemas';
import { appendPath } from '@silverhand/essentials';

Expand Down Expand Up @@ -63,6 +65,9 @@ describe('smoke testing for console admin account creation and sign-in', () => {
});

it('can register a new admin account and automatically sign in', async () => {
await fs.mkdir('screencasts');
const recorder = await page.screencast({ path: 'screencasts/register.webm' });

await expectNavigation(expect(page).toClick('button', { text: 'Create account' }));

expect(page.url()).toBe(new URL('register', logtoConsoleUrl).href);
Expand All @@ -77,8 +82,18 @@ describe('smoke testing for console admin account creation and sign-in', () => {
confirmPassword: consolePassword,
});

// TODO: Remove this line after fixing the issue
console.log('Page content 1');
console.log(await page.content());

await expectNavigation(expect(page).toClick('button[name=submit]'));

// TODO: Remove this line after fixing the issue
console.log('Page content 2');
console.log(await page.content());

await recorder.stop();

expect(page.url()).toBe(new URL('console/get-started', logtoConsoleUrl).href);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import fs from 'node:fs/promises';

import { appendPath } from '@silverhand/essentials';

import ExpectConsole from '#src/ui-helpers/expect-console.js';
import { Trace } from '#src/ui-helpers/trace.js';
import { devFeatureTest } from '#src/utils.js';

describe('error handling', () => {
const trace = new Trace();

devFeatureTest.it('should handle dynamic import errors', async () => {
it('should handle dynamic import errors', async () => {
const expectConsole = new ExpectConsole(await browser.newPage());

const path = appendPath(expectConsole.options.endpoint, 'console/__internal__/import-error');

trace.reset(expectConsole.page);
await fs.mkdir('screencasts');
const recorder = await expectConsole.page.screencast({ path: 'screencasts/err.webm' });
await trace.start();
await expectConsole.navigateTo(path);
await trace.stop();
await recorder.stop();

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
const traceData: { traceEvents: any[] } = await trace.read();
Expand Down
45 changes: 18 additions & 27 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e2ea69f

Please sign in to comment.