2
0
Mao 4 жил өмнө
parent
commit
b029d8d924

+ 1 - 0
packages/app/src/components/Navbar/GrowiNavbar.tsx

@@ -44,6 +44,7 @@ const NavbarRight: FC<NavbarRightProps> = memo((props: NavbarRightProps) => {
         <button
           className="px-md-3 nav-link btn-create-page border-0 bg-transparent"
           type="button"
+          data-testid="newPageBtn"
           onClick={() => openCreateModal(currentPagePath || '')}
         >
           <i className="icon-pencil mr-2"></i>

+ 14 - 2
packages/app/src/components/PageCreateModal.jsx

@@ -148,6 +148,7 @@ const PageCreateModal = (props) => {
                     className="page-today-input1 form-control text-center mx-2"
                     value={todayInput1}
                     onChange={e => onChangeTodayInput1Handler(e.target.value)}
+                    data-testid="createTodaysPageInput"
                   />
                 </form>
                 <span className="page-today-suffix">/{now}/</span>
@@ -165,7 +166,12 @@ const PageCreateModal = (props) => {
             </div>
 
             <div className="d-flex justify-content-end mt-1 mt-sm-0">
-              <button type="button" className="grw-btn-create-page btn btn-outline-primary rounded-pill text-nowrap ml-3" onClick={createTodayPage}>
+              <button
+                data-testid="createTodaysPageBtn"
+                type="button"
+                className="grw-btn-create-page btn btn-outline-primary rounded-pill text-nowrap ml-3"
+                onClick={createTodayPage}
+              >
                 <i className="icon-fw icon-doc"></i>{t('Create')}
               </button>
             </div>
@@ -205,13 +211,19 @@ const PageCreateModal = (props) => {
                       placeholder={t('Input page name')}
                       onChange={e => onChangePageNameInputHandler(e.target.value)}
                       required
+                      data-testid="createPageInput"
                     />
                   </form>
                 )}
             </div>
 
             <div className="d-flex justify-content-end mt-1 mt-sm-0">
-              <button type="button" className="grw-btn-create-page btn btn-outline-primary rounded-pill text-nowrap ml-3" onClick={createInputPage}>
+              <button
+                data-testid="createPageBtn"
+                type="button"
+                className="grw-btn-create-page btn btn-outline-primary rounded-pill text-nowrap ml-3"
+                onClick={createInputPage}
+              >
                 <i className="icon-fw icon-doc"></i>{t('Create')}
               </button>
             </div>

+ 42 - 0
packages/app/test/cypress/integration/2-basic-features/create-page.spec.ts

@@ -0,0 +1,42 @@
+context('Create page', () => {
+
+  const ssPrefix = 'create-page';
+
+  let connectSid: string | undefined;
+
+  before(() => {
+    // login
+    cy.fixture("user-admin.json").then(user => {
+      cy.login(user.username, user.password);
+    });
+    cy.getCookie('connect.sid').then(cookie => {
+      connectSid = cookie?.value;
+    });
+  });
+
+  beforeEach(() => {
+    if (connectSid != null) {
+      cy.setCookie('connect.sid', connectSid);
+      cy.visit('/');
+    }
+  });
+
+  // it("/Page Hello under today's page is successfully created", () => {
+  //   cy.getByTestid('newPageBtn').click();
+  //   cy.screenshot(`${ssPrefix}-opne-modal`)
+  //   cy.getByTestid('createTodaysPageInput').type("Hello");
+  //   cy.screenshot('input Hello');
+  //   cy.getByTestid('createTodaysPageBtn').click();
+
+  // });
+
+  it("/Page Hola under / is successfully created", ()=>{
+    cy.getByTestid('newPageBtn').click();
+    cy.screenshot(`${ssPrefix}-opne-modal`)
+    cy.getByTestid('createPageInput').type('Hola');
+    cy.screenshot('input Hola');
+    cy.getByTestid('createPageBtn');
+
+  })
+
+});