-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9549 from weseek/master
Release v7.1.8
- Loading branch information
Showing
13 changed files
with
368 additions
and
383 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
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,49 +1,55 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test('Create comment page', async({ page }) => { | ||
await page.goto('/comment'); | ||
await page.getByTestId('editor-button').click(); | ||
await page.getByTestId('save-page-btn').click(); | ||
await expect(page.locator('.page-meta')).toBeVisible(); | ||
}); | ||
test.describe('Comment', () => { | ||
|
||
test('Successfully add comments', async({ page }) => { | ||
const commentText = 'add comment'; | ||
await page.goto('/comment'); | ||
// make tests run in serial | ||
test.describe.configure({ mode: 'serial' }); | ||
|
||
// Add comment | ||
await page.getByTestId('page-comment-button').click(); | ||
await page.getByTestId('open-comment-editor-button').click(); | ||
await page.locator('.cm-content').fill(commentText); | ||
await page.getByTestId('comment-submit-button').first().click(); | ||
test('Create comment page', async({ page }) => { | ||
await page.goto('/comment'); | ||
await page.getByTestId('editor-button').click(); | ||
await page.getByTestId('save-page-btn').click(); | ||
await expect(page.locator('.page-meta')).toBeVisible(); | ||
}); | ||
|
||
await expect(page.locator('.page-comment-body')).toHaveText(commentText); | ||
await expect(page.getByTestId('page-comment-button').locator('.grw-count-badge')).toHaveText('1'); | ||
}); | ||
test('Successfully add comments', async({ page }) => { | ||
const commentText = 'add comment'; | ||
await page.goto('/comment'); | ||
|
||
test('Successfully reply comments', async({ page }) => { | ||
const commentText = 'reply comment'; | ||
await page.goto('/comment'); | ||
// Add comment | ||
await page.getByTestId('page-comment-button').click(); | ||
await page.getByTestId('open-comment-editor-button').click(); | ||
await page.locator('.cm-content').fill(commentText); | ||
await page.getByTestId('comment-submit-button').first().click(); | ||
|
||
// Reply comment | ||
await page.getByTestId('page-comment-button').click(); | ||
await page.getByTestId('comment-reply-button').click(); | ||
await page.locator('.cm-content').fill(commentText); | ||
await page.getByTestId('comment-submit-button').first().click(); | ||
await expect(page.locator('.page-comment-body')).toHaveText(commentText); | ||
await expect(page.getByTestId('page-comment-button').locator('.grw-count-badge')).toHaveText('1'); | ||
}); | ||
|
||
await expect(page.locator('.page-comment-body').nth(1)).toHaveText(commentText); | ||
await expect(page.getByTestId('page-comment-button').locator('.grw-count-badge')).toHaveText('2'); | ||
}); | ||
test('Successfully reply comments', async({ page }) => { | ||
const commentText = 'reply comment'; | ||
await page.goto('/comment'); | ||
|
||
// Reply comment | ||
await page.getByTestId('comment-reply-button').click(); | ||
await page.locator('.cm-content').fill(commentText); | ||
await page.getByTestId('comment-submit-button').first().click(); | ||
|
||
// test('Successfully delete comments', async({ page }) => { | ||
// await page.goto('/comment'); | ||
await expect(page.locator('.page-comment-body').nth(1)).toHaveText(commentText); | ||
await expect(page.getByTestId('page-comment-button').locator('.grw-count-badge')).toHaveText('2'); | ||
}); | ||
|
||
// await page.getByTestId('page-comment-button').click(); | ||
// await page.getByTestId('comment-delete-button').first().click({ force: true }); | ||
// await expect(page.getByTestId('page-comment-delete-modal')).toBeVisible(); | ||
// await page.getByTestId('delete-comment-button').click(); | ||
// test('Successfully delete comments', async({ page }) => { | ||
// await page.goto('/comment'); | ||
|
||
// await expect(page.getByTestId('page-comment-button').locator('.grw-count-badge')).toHaveText('0'); | ||
// }); | ||
// await page.getByTestId('page-comment-button').click(); | ||
// await page.getByTestId('comment-delete-button').first().click({ force: true }); | ||
// await expect(page.getByTestId('page-comment-delete-modal')).toBeVisible(); | ||
// await page.getByTestId('delete-comment-button').click(); | ||
|
||
// TODO: https://redmine.weseek.co.jp/issues/139520 | ||
// await expect(page.getByTestId('page-comment-button').locator('.grw-count-badge')).toHaveText('0'); | ||
// }); | ||
|
||
// TODO: https://redmine.weseek.co.jp/issues/139520 | ||
|
||
}); |
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
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
55 changes: 55 additions & 0 deletions
55
packages/core/src/utils/page-path-utils/generate-children-regexp.spec.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,55 @@ | ||
import { describe, expect, test } from 'vitest'; | ||
|
||
import { generateChildrenRegExp } from './generate-children-regexp'; | ||
|
||
describe('generateChildrenRegExp', () => { | ||
describe.each([ | ||
{ | ||
path: '/', | ||
expected: '^\\/[^/]+$', | ||
validPaths: ['/child', '/test'], | ||
invalidPaths: ['/', '/child/grandchild'], | ||
}, | ||
{ | ||
path: '/parent', | ||
expected: '^\\/parent(\\/[^/]+)\\/?$', | ||
validPaths: ['/parent/child', '/parent/test'], | ||
invalidPaths: ['/parent', '/parent/child/grandchild', '/other/path'], | ||
}, | ||
{ | ||
path: '/parent (with brackets)', | ||
expected: '^\\/parent \\(with brackets\\)(\\/[^/]+)\\/?$', | ||
validPaths: ['/parent (with brackets)/child', '/parent (with brackets)/test'], | ||
invalidPaths: ['/parent (with brackets)', '/parent (with brackets)/child/grandchild'], | ||
}, | ||
{ | ||
path: '/parent[with square]', | ||
expected: '^\\/parent\\[with square\\](\\/[^/]+)\\/?$', | ||
validPaths: ['/parent[with square]/child', '/parent[with square]/test'], | ||
invalidPaths: ['/parent[with square]', '/parent[with square]/child/grandchild'], | ||
}, | ||
{ | ||
path: '/parent*with+special?chars', | ||
expected: '^\\/parent\\*with\\+special\\?chars(\\/[^/]+)\\/?$', | ||
validPaths: ['/parent*with+special?chars/child', '/parent*with+special?chars/test'], | ||
invalidPaths: ['/parent*with+special?chars', '/parent*with+special?chars/child/grandchild'], | ||
}, | ||
])('with path: $path', ({ | ||
path, expected, validPaths, invalidPaths, | ||
}) => { | ||
test('should generate correct regexp pattern', () => { | ||
const result = generateChildrenRegExp(path); | ||
expect(result.source).toBe(expected); | ||
}); | ||
|
||
test.each(validPaths)('should match valid path: %s', (validPath) => { | ||
const result = generateChildrenRegExp(path); | ||
expect(validPath).toMatch(result); | ||
}); | ||
|
||
test.each(invalidPaths)('should not match invalid path: %s', (invalidPath) => { | ||
const result = generateChildrenRegExp(path); | ||
expect(invalidPath).not.toMatch(result); | ||
}); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
packages/core/src/utils/page-path-utils/generate-children-regexp.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,16 @@ | ||
import escapeStringRegexp from 'escape-string-regexp'; | ||
|
||
import { isTopPage } from './is-top-page'; | ||
|
||
/** | ||
* Generate RegExp instance for one level lower path | ||
*/ | ||
export const generateChildrenRegExp = (path: string): RegExp => { | ||
// https://regex101.com/r/laJGzj/1 | ||
// ex. /any_level1 | ||
if (isTopPage(path)) return new RegExp(/^\/[^/]+$/); | ||
|
||
// https://regex101.com/r/mrDJrx/1 | ||
// ex. /parent/any_child OR /any_level1 | ||
return new RegExp(`^${escapeStringRegexp(path)}(\\/[^/]+)\\/?$`); | ||
}; |
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
Oops, something went wrong.