Skip to content

Commit

Permalink
chore: refactor test structure (heyxyz#3147)
Browse files Browse the repository at this point in the history
* feat: move web test cases to its own

* feat: move prerender test cases to its own

* chore: remove nightly tests

* chore: temp remove global tests folder

* fix: lint errors
  • Loading branch information
bigint authored Jun 20, 2023
1 parent 4c64d5c commit b1eba13
Show file tree
Hide file tree
Showing 71 changed files with 51 additions and 1,122 deletions.
1 change: 0 additions & 1 deletion .deepsource.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ exclude_patterns = [
".github",
".husky",
".vscode",
"tests",
"pnpm-lock.yaml",
"packages/lens/generated.ts",
"packages/workers/snapshot-relay/generated.ts",
Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/nightly.yml

This file was deleted.

2 changes: 2 additions & 0 deletions apps/prerender/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"prettier": "prettier --check \"**/*.{js,ts,tsx,md}\" --cache",
"prettier:fix": "prettier --write \"**/*.{js,ts,tsx,md}\" --cache",
"start": "next start --port 4784",
"test:dev": "playwright test",
"typecheck": "tsc --pretty"
},
"dependencies": {
Expand All @@ -28,6 +29,7 @@
"devDependencies": {
"@lenster/config": "workspace:*",
"@lenster/lens": "workspace:*",
"@playwright/test": "^1.35.1",
"@types/react": "^18.2.13",
"@types/react-dom": "^18.2.6",
"typescript": "^5.1.3"
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions apps/prerender/tests/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const PRERENDER_BASE_URL = 'http://localhost:4784';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { APP_NAME } from '@lenster/data/constants';
import { expect, test } from '@playwright/test';
import { PRERENDER_BASE_URL } from 'test/constants';
import { PRERENDER_BASE_URL } from 'tests/constants';

test.beforeEach(async ({ page }) => {
await page.goto(`${PRERENDER_BASE_URL}/u/yoginth`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { APP_NAME } from '@lenster/data/constants';
import { expect, test } from '@playwright/test';
import { PRERENDER_BASE_URL } from 'test/constants';
import { PRERENDER_BASE_URL } from 'tests/constants';

test.beforeEach(async ({ page }) => {
await page.goto(`${PRERENDER_BASE_URL}/posts/0x0d-0x01`);
Expand Down
2 changes: 2 additions & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"prettier": "prettier --check \"**/*.{js,ts,tsx,md}\" --cache",
"prettier:fix": "prettier --write \"**/*.{js,ts,tsx,md}\" --cache",
"start": "next start --port 4783",
"test:dev": "playwright test",
"typecheck": "tsc --pretty"
},
"dependencies": {
Expand Down Expand Up @@ -90,6 +91,7 @@
"@giphy/js-types": "^4.4.0",
"@lenster/config": "workspace:*",
"@lingui/cli": "^4.2.1",
"@playwright/test": "^1.35.1",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/forms": "^0.5.3",
"@types/node": "^20.3.1",
Expand Down
19 changes: 19 additions & 0 deletions apps/web/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { PlaywrightTestConfig } from '@playwright/test';
import { devices } from '@playwright/test';
import * as os from 'os';

const config: PlaywrightTestConfig = {
testDir: './',
timeout: 50 * 1000,
expect: { timeout: 50000 },
fullyParallel: true,
maxFailures: 3,
forbidOnly: Boolean(process.env.CI),
retries: 3,
workers: os.cpus().length === 1 ? 1 : os.cpus().length - 1,
reporter: 'list',
use: { actionTimeout: 0, trace: 'on-first-retry' },
projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }]
};

export default config;
1 change: 0 additions & 1 deletion apps/web/src/components/Comment/Feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ const Feed: FC<FeedProps> = ({ publication }) => {
).length;
const hiddenRemovedComments = comments?.length - hiddenCount;
const totalComments = hiddenRemovedComments + queuedCount;
const canComment = publication?.canComment?.result;

const { observe } = useInView({
onChange: async ({ inView }) => {
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/components/Messages/Composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ const Composer: FC<ComposerProps> = ({
useEffect(() => {
setMessage(unsentMessage ?? '');
// only run this effect when the conversation changes
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [conversationKey]);

const onChangeCallback = (value: string) => {
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/components/Messages/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const Message: FC<MessageProps> = ({ conversationKey }) => {
}
}
// only run this effect when messages changes
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [messages]);

const fetchNextMessages = useCallback(() => {
Expand Down
1 change: 1 addition & 0 deletions apps/web/tests/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const WEB_BASE_URL = 'http://localhost:4783';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { APP_NAME } from '@lenster/data/constants';
import { expect, test } from '@playwright/test';
import { WEB_BASE_URL } from 'test/constants';
import { WEB_BASE_URL } from 'tests/constants';

test.beforeEach(async ({ page }) => {
await page.goto(`${WEB_BASE_URL}/contact`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { APP_NAME } from '@lenster/data/constants';
import { expect, test } from '@playwright/test';
import { WEB_BASE_URL } from 'test/constants';
import { WEB_BASE_URL } from 'tests/constants';

test.beforeEach(async ({ page }) => {
await page.goto(`${WEB_BASE_URL}/explore`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { APP_NAME } from '@lenster/data/constants';
import { expect, test } from '@playwright/test';
import { WEB_BASE_URL } from 'test/constants';
import { WEB_BASE_URL } from 'tests/constants';

test.beforeEach(async ({ page }) => {
await page.goto(WEB_BASE_URL);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from '@playwright/test';
import { WEB_BASE_URL } from 'test/constants';
import { WEB_BASE_URL } from 'tests/constants';

test.beforeEach(async ({ page }) => {
await page.goto(WEB_BASE_URL);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { APP_NAME } from '@lenster/data/constants';
import { expect, test } from '@playwright/test';
import { WEB_BASE_URL } from 'test/constants';
import { WEB_BASE_URL } from 'tests/constants';

test.beforeEach(async ({ page }) => {
await page.goto(`${WEB_BASE_URL}/privacy`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from '@playwright/test';
import { WEB_BASE_URL } from 'test/constants';
import { WEB_BASE_URL } from 'tests/constants';

test.describe('Profile feeds', () => {
test.beforeEach(async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { APP_NAME } from '@lenster/data/constants';
import { expect, test } from '@playwright/test';
import { WEB_BASE_URL } from 'test/constants';
import { WEB_BASE_URL } from 'tests/constants';

test.describe('Profile', () => {
test.beforeEach(async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from '@playwright/test';
import { WEB_BASE_URL } from 'test/constants';
import { WEB_BASE_URL } from 'tests/constants';

test.describe('Profile sidebar', () => {
test.describe('Profile details', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IPFS_GATEWAY } from '@lenster/data/constants';
import { expect, test } from '@playwright/test';
import { WEB_BASE_URL } from 'test/constants';
import { WEB_BASE_URL } from 'tests/constants';

test.describe('Publication attachments', () => {
test('should have publication image', async ({ page }) => {
Expand Down Expand Up @@ -53,7 +53,7 @@ test.describe('Publication attachments', () => {
});

test.describe('Publication oembed', () => {
test('should have normal oembed', async ({ page }) => {
test.skip('should have normal oembed', async ({ page }) => {
const publicationId = '0x0d-0x0375';
await page.goto(`${WEB_BASE_URL}/posts/${publicationId}`);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { APP_NAME } from '@lenster/data/constants';
import { expect, test } from '@playwright/test';
import { WEB_BASE_URL } from 'test/constants';
import { WEB_BASE_URL } from 'tests/constants';

test.describe('Publication', () => {
test.beforeEach(async ({ page }) => {
Expand Down Expand Up @@ -62,7 +62,7 @@ test.describe('Publication', () => {
const publicationMirrorStats = page
.getByTestId('publication-0x0d-0x01')
.getByTestId('mirror-stats');
await expect(publicationMirrorStats).toContainText('Mirror');
await expect(publicationMirrorStats).toContainText('Mirrors');

// click mirror stats and check if it opens mirror modal
await publicationMirrorStats.click();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from '@playwright/test';
import { WEB_BASE_URL } from 'test/constants';
import { WEB_BASE_URL } from 'tests/constants';

test.describe('Publication sidebar', () => {
test.beforeEach(async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { APP_NAME } from '@lenster/data/constants';
import { expect, test } from '@playwright/test';
import { WEB_BASE_URL } from 'test/constants';
import { WEB_BASE_URL } from 'tests/constants';

test.beforeEach(async ({ page }) => {
await page.goto(`${WEB_BASE_URL}/terms`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { APP_NAME } from '@lenster/data/constants';
import { expect, test } from '@playwright/test';
import { WEB_BASE_URL } from 'test/constants';
import { WEB_BASE_URL } from 'tests/constants';

// Check footer is present
test('should have footer', async ({ page }) => {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"start": "turbo run start --parallel",
"test:dev": "turbo run test:dev",
"test:e2e": "start-server-and-test start '4783|4784|8083|8085|8087' test:dev",
"test:nightly": "turbo run test:nightly",
"typecheck": "turbo run typecheck --parallel",
"typecheck:affected": "turbo run typecheck --parallel --filter=[origin/main]",
"workers:deploy": "turbo run worker:deploy --parallel",
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

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

1 change: 0 additions & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ packages:
- 'apps/*'
- 'packages/*'
- 'packages/workers/*'
- 'tests'
3 changes: 0 additions & 3 deletions tests/.eslintrc.js

This file was deleted.

Empty file removed tests/README.md
Empty file.
13 changes: 0 additions & 13 deletions tests/constants.ts

This file was deleted.

26 changes: 0 additions & 26 deletions tests/package.json

This file was deleted.

31 changes: 0 additions & 31 deletions tests/packages/lib/formatAddress.spec.ts

This file was deleted.

30 changes: 0 additions & 30 deletions tests/packages/lib/formatHandle.spec.ts

This file was deleted.

Loading

0 comments on commit b1eba13

Please sign in to comment.