-
Notifications
You must be signed in to change notification settings - Fork 54
Feat/e2e testing #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Sanketmundada
wants to merge
18
commits into
dicedb:master
Choose a base branch
from
Sanketmundada:feat/e2e-testing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/e2e testing #57
Changes from 7 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
abc829e
chore: playwirght e2e test setup
91f4f96
fix: env for backend service fix in docker compose
a54813f
chore: modified jest file to look for rtl jest test cases only under src
32d764b
fix: fixed existing tc after change in data-testid
b32534b
feat: added e2e test for GET, SET, DEL commands
4bbc9c0
chore: updated readme with commands for e2e test
bf094f2
chore: added github workflow for playwright
b1d6830
chore: workflow renamed
49ae4b8
chore: added webserver configuration to playwright config
7a3e4b1
chore: merged master into feat/e2e-testing
281a5b6
chore: moved playwright related stuff to playground web app
8ea580f
chore: added changes in top level package and turbo project
c00b366
refactor: added integration test in existing workflow
078f694
chore: readme update
d1cda29
fix: ignore playwright test in case of test command run
bd8f0cf
fix: workflow command fixes
6472495
chore: added env variable CI in workflow
54f3150
fix: removed env from workflow
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,28 @@ | ||
| # workflow to check if E2E testing is working properly | ||
|
|
||
| name: Playwright Tests | ||
| on: | ||
| pull_request: | ||
| branches: | ||
| - master | ||
| jobs: | ||
| test: | ||
| timeout-minutes: 60 | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: lts/* | ||
| - name: Install dependencies | ||
| run: npm ci | ||
| - name: Install Playwright Browsers | ||
| run: npx playwright install --with-deps | ||
| - name: Run Playwright tests | ||
| run: npx playwright test | ||
| - uses: actions/upload-artifact@v4 | ||
| if: ${{ !cancelled() }} | ||
| with: | ||
| name: playwright-report | ||
| path: playwright-report/ | ||
| retention-days: 30 | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,41 @@ | ||
| import { defineConfig, devices } from '@playwright/test'; | ||
|
|
||
| export default defineConfig({ | ||
| testDir: './tests', | ||
| /* Run tests in files in parallel */ | ||
| fullyParallel: true, | ||
| /* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
| forbidOnly: !!process.env.CI, | ||
| /* Retry on CI only */ | ||
| retries: process.env.CI ? 2 : 0, | ||
| /* Opt out of parallel tests on CI. */ | ||
| workers: process.env.CI ? 1 : undefined, | ||
| /* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
| reporter: 'html', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets also use GitHub reporter here |
||
| /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
| use: { | ||
| /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
| trace: 'on-first-retry', | ||
| }, | ||
|
|
||
| /* Configure projects for major browsers */ | ||
| projects: [ | ||
| { | ||
| name: 'chromium', | ||
| use: { ...devices['Desktop Chrome'] }, | ||
| timeout: 30000, | ||
| }, | ||
|
|
||
| { | ||
| name: 'firefox', | ||
| use: { ...devices['Desktop Firefox'] }, | ||
| timeout: 30000, | ||
| }, | ||
|
|
||
| { | ||
| name: 'webkit', | ||
| use: { ...devices['Desktop Safari'] }, | ||
| timeout: 30000, | ||
| }, | ||
| ], | ||
| }); | ||
This file contains hidden or 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 hidden or 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 hidden or 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,104 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
| import type { Page } from '@playwright/test'; | ||
|
|
||
| const runCommand = async (page: Page, cmd: string) => { | ||
| const cmdInput = page.getByTestId('shell-input'); | ||
| await cmdInput.fill(cmd); | ||
| await page.keyboard.press('Enter'); | ||
| }; | ||
|
|
||
| test.describe('[Playground Component]', () => { | ||
| test.beforeEach(async ({ page }) => { | ||
| await page.goto('http://localhost:3000'); | ||
| const cmdInput = page.getByTestId('shell-input'); | ||
| await expect(cmdInput).toBeVisible(); | ||
| }); | ||
|
|
||
| test('should execute SET command properly', async ({ page }) => { | ||
| let outputIdx = 0; | ||
|
|
||
| // Happy case | ||
| await runCommand(page, 'SET foo bar'); | ||
| // Adding 2 to outputIndex after each command execution | ||
| // Reason: 2 items are added to output after each execution, 1st is command itself and 2nd is its result | ||
| outputIdx += 2; | ||
| await page.getByTestId(`terminal-output-${outputIdx}`).waitFor(); | ||
| await expect(page.getByTestId(`terminal-output-${outputIdx}`)).toHaveText( | ||
| 'OK', | ||
| ); | ||
|
|
||
| // Error case: SET with wrong number of arguments | ||
| await runCommand(page, 'SET foo'); | ||
| outputIdx += 2; | ||
| await page.getByTestId(`terminal-output-${outputIdx}`).waitFor(); | ||
| await expect(page.getByTestId(`terminal-output-${outputIdx}`)).toHaveText( | ||
| "(error) ERR wrong number of arguments for 'set' command", | ||
| ); | ||
| }); | ||
|
|
||
| test('should execute GET command properly', async ({ page }) => { | ||
| let outputIdx = 0; | ||
|
|
||
| // Happy case | ||
| await runCommand(page, 'SET foo bar'); | ||
| outputIdx += 2; | ||
| await runCommand(page, 'GET foo'); | ||
| outputIdx += 2; | ||
| await page.getByTestId(`terminal-output-${outputIdx}`).waitFor(); | ||
|
|
||
| await expect(page.getByTestId(`terminal-output-${outputIdx}`)).toHaveText( | ||
| 'bar', | ||
| ); | ||
|
|
||
| // Error case for wrong key get | ||
| await runCommand(page, 'GET foo1'); | ||
| outputIdx += 2; | ||
| await page.getByTestId(`terminal-output-${outputIdx}`).waitFor(); | ||
| await expect(page.getByTestId(`terminal-output-${outputIdx}`)).toHaveText( | ||
| '(nil)', | ||
| ); | ||
|
|
||
| // Error case: GET with wrong number of arguments | ||
| await runCommand(page, 'GET foo bar'); | ||
| outputIdx += 2; | ||
| await page.getByTestId(`terminal-output-${outputIdx}`).waitFor(); | ||
| await expect(page.getByTestId(`terminal-output-${outputIdx}`)).toHaveText( | ||
| "(error) ERR wrong number of arguments for 'get' command", | ||
| ); | ||
| }); | ||
|
|
||
| test('should execute DEL command properly', async ({ page }) => { | ||
| let outputIdx = 0; | ||
|
|
||
| // Happy case | ||
| await runCommand(page, 'SET foo bar'); | ||
| outputIdx += 2; | ||
| await runCommand(page, 'GET foo'); | ||
| outputIdx += 2; | ||
| await page.getByTestId(`terminal-output-${outputIdx}`).waitFor(); | ||
| await expect(page.getByTestId(`terminal-output-${outputIdx}`)).toHaveText( | ||
| 'bar', | ||
| ); | ||
| await runCommand(page, 'DEL foo'); | ||
| outputIdx += 2; | ||
| await page.getByTestId(`terminal-output-${outputIdx}`).waitFor(); | ||
| await expect(page.getByTestId(`terminal-output-${outputIdx}`)).toHaveText( | ||
| '1', | ||
| ); | ||
| await runCommand(page, 'GET foo'); | ||
| outputIdx += 2; | ||
| await page.getByTestId(`terminal-output-${outputIdx}`).waitFor(); | ||
| // Getting back the deleted key should return (nil) output | ||
| await expect(page.getByTestId(`terminal-output-${outputIdx}`)).toHaveText( | ||
| '(nil)', | ||
| ); | ||
|
|
||
| // Error case: DEL key which is not present | ||
| await runCommand(page, 'DEL bar'); | ||
| outputIdx += 2; | ||
| await page.getByTestId(`terminal-output-${outputIdx}`).waitFor(); | ||
| await expect(page.getByTestId(`terminal-output-${outputIdx}`)).toHaveText( | ||
| '0', | ||
| ); | ||
| }); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.