Skip to content

Commit

Permalink
Merge pull request #9549 from weseek/master
Browse files Browse the repository at this point in the history
Release v7.1.8
  • Loading branch information
mergify[bot] authored Jan 21, 2025
2 parents 04f63f1 + 43a239b commit 35786a7
Show file tree
Hide file tree
Showing 13 changed files with 368 additions and 383 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/reusable-app-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ jobs:
container:
# Match the Playwright version
# https://github.com/microsoft/playwright/issues/20010
image: mcr.microsoft.com/playwright:v1.46.0-jammy
image: mcr.microsoft.com/playwright:v1.49.1-jammy

strategy:
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion apps/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@growi/app",
"version": "7.1.7",
"version": "7.1.8-RC.0",
"license": "MIT",
"private": "true",
"scripts": {
Expand Down
80 changes: 43 additions & 37 deletions apps/app/playwright/20-basic-features/comments.spec.ts
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

});
2 changes: 1 addition & 1 deletion apps/app/src/server/service/page/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4391,7 +4391,7 @@ class PageService implements IPageService {
const Page = mongoose.model('Page') as unknown as PageModel;

const ancestorPaths = isTopPage(path) ? ['/'] : collectAncestorPaths(path); // root path is necessary for rendering
const regexps = ancestorPaths.map(path => new RegExp(generateChildrenRegExp(path))); // cannot use re2
const regexps = ancestorPaths.map(path => generateChildrenRegExp(path)); // cannot use re2

// get pages at once
const queryBuilder = new PageQueryBuilder(Page.find({ path: { $in: regexps } }), true);
Expand Down
2 changes: 1 addition & 1 deletion apps/slackbot-proxy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@growi/slackbot-proxy",
"version": "7.1.7-slackbot-proxy.0",
"version": "7.1.8-slackbot-proxy.0",
"license": "MIT",
"private": "true",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "growi",
"version": "7.1.7",
"version": "7.1.8-RC.0",
"description": "Team collaboration software using markdown",
"license": "MIT",
"private": "true",
Expand Down Expand Up @@ -46,7 +46,7 @@
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.3",
"@faker-js/faker": "^9.0.1",
"@playwright/test": "^1.46.0",
"@playwright/test": "^1.49.1",
"@swc-node/register": "^1.9.1",
"@swc/core": "^1.5.25",
"@swc/helpers": "^0.5.11",
Expand Down
6 changes: 6 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @growi/core

## 1.3.1

### Patch Changes

- [#9550](https://github.com/weseek/growi/pull/9550) [`acd3787`](https://github.com/weseek/growi/commit/acd3787fc4b8c8630ba9fa5a06d837639da8d10a) Thanks [@yuki-takei](https://github.com/yuki-takei)! - Fix generateChildrenRegExp method

## 1.3.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@growi/core",
"version": "1.3.0",
"version": "1.3.1",
"description": "GROWI Core Libraries",
"license": "MIT",
"keywords": [
Expand Down
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);
});
});
});
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)}(\\/[^/]+)\\/?$`);
};
14 changes: 1 addition & 13 deletions packages/core/src/utils/page-path-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { addTrailingSlash } from '../path-utils';
import { isTopPage as _isTopPage } from './is-top-page';

export const isTopPage = _isTopPage;
export * from './generate-children-regexp';

/**
* Whether path is the top page of users
Expand Down Expand Up @@ -276,19 +277,6 @@ export const hasSlash = (str: string): boolean => {
return str.includes('/');
};

/**
* 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(`^${path}(\\/[^/]+)\\/?$`);
};

/**
* Get username from user page path
* @param path string
Expand Down
3 changes: 1 addition & 2 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
"lint:typecheck": "vue-tsc --noEmit",
"lint": "npm-run-all -p lint:*"
},
"dependencies": {
},
"dependencies": {},
"devDependencies": {
"@growi/core": "workspace:^",
"@growi/core-styles": "workspace:^",
Expand Down
Loading

0 comments on commit 35786a7

Please sign in to comment.