-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(Next): update next.sh script and index page, add end-to-end test
- Loading branch information
1 parent
e8cff10
commit 2fd836c
Showing
4 changed files
with
89 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
#!/bin/bash | ||
|
||
rm -rf test-next-app | ||
FOLDER_NAME="test-next-app" | ||
PACKAGE_PATH="../../stream-chat-react.tgz" | ||
|
||
yarn create next-app --typescript test-next-app | ||
rm -rf $FOLDER_NAME | ||
|
||
yarn create next-app --typescript $FOLDER_NAME --no-eslint | ||
|
||
# Apply a hello-world chat page to the project. | ||
cp ./next-page.tsx test-next-app/pages/index.tsx | ||
cp ./next-page.tsx $FOLDER_NAME/pages/index.tsx | ||
|
||
# install the lib... | ||
yarn --cwd ./test-next-app add --dev ../../stream-chat-react.tgz | ||
yarn --cwd ./$FOLDER_NAME add --dev $PACKAGE_PATH stream-chat | ||
|
||
echo NEXT_USER_ID=$USER_ID >> $FOLDER_NAME/.env.local | ||
echo NEXT_USER_TOKEN=$USER_TOKEN >> $FOLDER_NAME/.env.local | ||
echo NEXT_STREAM_API_KEY=$STREAM_API_KEY >> $FOLDER_NAME/.env.local | ||
|
||
# and build - $? should be 0 | ||
yarn --cwd ./test-next-app build | ||
yarn --cwd ./test-next-app build --no-lint | ||
|
||
npx playwright test --config ./playwright.config.ts ./next.test.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* eslint-disable jest/require-top-level-describe */ | ||
/* eslint-disable jest/no-done-callback */ | ||
|
||
import { expect, test } from '@playwright/test'; | ||
|
||
test.describe('Next', () => { | ||
test('MessageList rendered', async ({ page }) => { | ||
page.on('console', (message) => console.log('NEXT_LOGS: ', message.text())); | ||
|
||
await Promise.all([ | ||
page.waitForSelector('#root'), | ||
page.waitForLoadState('networkidle'), | ||
page.goto('/'), | ||
]); | ||
|
||
const list = page.locator('.str-chat__list'); | ||
await expect(list).toBeVisible(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { PlaywrightTestConfig } from '@playwright/test'; | ||
|
||
export default { | ||
timeout: 15 * 1000, | ||
use: { | ||
baseURL: 'http://localhost:3000', | ||
browserName: 'chromium', | ||
headless: true, | ||
}, | ||
webServer: { | ||
command: 'yarn --cwd ./test-next-app dev', | ||
port: 3000, | ||
reuseExistingServer: !process.env.CI, | ||
timeout: 15 * 1000, | ||
}, | ||
} as PlaywrightTestConfig; |