Просмотр исходного кода

update test for isCreatablePage

Yuki Takei 9 месяцев назад
Родитель
Сommit
8ecca66117
1 измененных файлов с 56 добавлено и 0 удалено
  1. 56 0
      packages/core/src/utils/page-path-utils/is-creatable-page.spec.ts

+ 56 - 0
packages/core/src/utils/page-path-utils/is-creatable-page.spec.ts

@@ -62,4 +62,60 @@ describe('isCreatablePage', () => {
       expect(isCreatablePage(path)).toBe(false);
     });
   });
+
+  describe('special characters restriction', () => {
+    it.each([
+      '/path^with^caret', // ^ character
+      '/path$with$dollar', // $ character
+      '/path*with*asterisk', // * character
+      '/path+with+plus', // + character
+    ])('should return false for "%s"', (path) => {
+      expect(isCreatablePage(path)).toBe(false);
+    });
+  });
+
+  describe('URL patterns restriction', () => {
+    it.each([
+      '/http://example.com/page', // HTTP URL
+      '/https://example.com/page', // HTTPS URL
+    ])('should return false for "%s"', (path) => {
+      expect(isCreatablePage(path)).toBe(false);
+    });
+  });
+
+  describe('relative path restriction', () => {
+    it.each([
+      '/..', // Parent directory reference
+      '/path/../other', // Relative path with parent reference
+    ])('should return false for "%s"', (path) => {
+      expect(isCreatablePage(path)).toBe(false);
+    });
+  });
+
+  describe('backslash restriction', () => {
+    it.each([
+      '/path\\with\\backslash', // Backslash in path
+      '/folder\\file', // Backslash separator
+    ])('should return false for "%s"', (path) => {
+      expect(isCreatablePage(path)).toBe(false);
+    });
+  });
+
+  describe('space and slash restriction', () => {
+    it.each([
+      '/ path / with / spaces', // Spaces around slashes
+      '/path / with / bad / formatting', // Mixed spacing
+    ])('should return false for "%s"', (path) => {
+      expect(isCreatablePage(path)).toBe(false);
+    });
+  });
+
+  describe('system path restriction', () => {
+    it.each([
+      '/_r/some/path', // _r system path
+      '/_private-legacy-pages/old', // Private legacy pages
+    ])('should return false for "%s"', (path) => {
+      expect(isCreatablePage(path)).toBe(false);
+    });
+  });
 });