-
-
Notifications
You must be signed in to change notification settings - Fork 287
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
App renaming integration test #820
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a77802d
Add integration test for app renaming
Janpot cd6902b
fix db restore
Janpot 88e24da
locators
Janpot cbf5b4f
add test command in ci
Janpot 8e280ea
fix
Janpot e566e15
node 14 compat
Janpot 968714b
fix some things
Janpot 149a8e4
remove execa
Janpot 51a545a
one integration test
Janpot 13d43dd
Merge branch 'master' into integration-test-rename
Janpot 5acb551
Adapt new menu
Janpot 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 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
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { test, expect, Request, Page } from '@playwright/test'; | ||
import generateId from '../utils/generateId'; | ||
import * as locators from '../utils/locators'; | ||
|
||
async function createApp(page: Page, name: string) { | ||
await page.locator('button:has-text("create new")').click(); | ||
|
||
await page.fill('[role="dialog"] label:has-text("name")', name); | ||
|
||
await page.click('[role="dialog"] button:has-text("create")'); | ||
|
||
await page.waitForNavigation({ url: /\/_toolpad\/app\/[^/]+\/editor\/pages\/[^/]+/ }); | ||
} | ||
|
||
test('app create/rename flow', async ({ page }) => { | ||
const appName1 = `App ${generateId()}`; | ||
const appName2 = `App ${generateId()}`; | ||
const appName3 = `App ${generateId()}`; | ||
|
||
await page.goto('/'); | ||
await createApp(page, appName1); | ||
|
||
await page.goto('/'); | ||
await createApp(page, appName2); | ||
|
||
await page.goto('/'); | ||
|
||
await page.click(`${locators.toolpadHomeAppRow(appName1)} >> [aria-label="Application menu"]`); | ||
|
||
await page.click('[role="menuitem"]:has-text("Rename"):visible'); | ||
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. Should all the locators used in this test also be present in 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. no, just the hacky ones that we want to reuse |
||
|
||
await page.keyboard.type(appName2); | ||
await page.keyboard.press('Enter'); | ||
|
||
await expect(page.locator(`text=An app named "${appName2}" already exists`)).toBeVisible(); | ||
|
||
await page.keyboard.type(appName3); | ||
|
||
await expect(page.locator(locators.toolpadHomeAppRow(appName3))).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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as devDb from '../utils/devDb'; | ||
|
||
async function globalSetup() { | ||
// eslint-disable-next-line no-underscore-dangle | ||
(globalThis as any).__toolpadTestDbDump = null; | ||
|
||
if (!(await devDb.isRunning())) { | ||
return; | ||
} | ||
|
||
// eslint-disable-next-line no-console | ||
console.log('Creating a backup of the dev database'); | ||
|
||
// eslint-disable-next-line no-underscore-dangle | ||
(globalThis as any).__toolpadTestDbDump = await devDb.dump(); | ||
} | ||
|
||
export default globalSetup; |
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,17 @@ | ||
import * as devDb from '../utils/devDb'; | ||
|
||
async function globalTeardown() { | ||
// eslint-disable-next-line no-underscore-dangle | ||
const pgDump = (globalThis as any).__toolpadTestDbDump; | ||
|
||
if (pgDump) { | ||
// eslint-disable-next-line no-console | ||
console.log('Restoring the dev database'); | ||
|
||
await devDb.restore(pgDump); | ||
} else if (pgDump !== null) { | ||
throw new Error(`global-setup didn't run correctly`); | ||
} | ||
} | ||
|
||
export default globalTeardown; |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we leave the accessibility issue link in there (assuming the issue persists of course)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the comment. Isn't this how
MenuItem
is supposed to be used? If it's forcing us to do a workaround in another part of the code then I wouldn't the comment rather belong at that location?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was intended to be a reference to the bug report which talks about how
MenuItem
doesn't work as a button when used with a keyboard; we can remove it since we aren't doing anything specifically to tackle it