| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386 |
- context('Access to page', () => {
- const ssPrefix = 'access-to-page-';
- beforeEach(() => {
- // login
- cy.fixture("user-admin.json").then(user => {
- cy.login(user.username, user.password);
- });
- });
- it('/Sandbox is successfully loaded', () => {
- cy.visit('/Sandbox');
- cy.waitUntilSkeletonDisappear();
- // for check download toc data
- // https://redmine.weseek.co.jp/issues/111384
- // cy.get('.toc-link').should('be.visible');
- cy.collapseSidebar(true, true);
- cy.screenshot(`${ssPrefix}-sandbox`);
- });
- // TODO: https://redmine.weseek.co.jp/issues/109939
- it('/Sandbox with anchor hash is successfully loaded', () => {
- cy.visit('/Sandbox#headers');
- cy.waitUntilSkeletonDisappear();
- // for check download toc data
- // https://redmine.weseek.co.jp/issues/111384
- // cy.get('.toc-link').should('be.visible');
- // hide fab
- cy.getByTestid('grw-fab-container').invoke('attr', 'style', 'display: none');
- // remove animation for screenshot
- // remove 'blink' class because ::after element cannot be operated
- // https://stackoverflow.com/questions/5041494/selecting-and-manipulating-css-pseudo-elements-such-as-before-and-after-usin/21709814#21709814
- cy.get('#headers').invoke('removeClass', 'blink');
- cy.collapseSidebar(true);
- cy.screenshot(`${ssPrefix}-sandbox-headers`);
- });
- it('/Sandbox/Math is successfully loaded', () => {
- cy.visit('/Sandbox/Math');
- cy.waitUntilSkeletonDisappear();
- // for check download toc data
- // https://redmine.weseek.co.jp/issues/111384
- // cy.get('.toc-link').should('be.visible');
- cy.get('.math').should('be.visible');
- cy.collapseSidebar(true);
- cy.screenshot(`${ssPrefix}-sandbox-math`);
- });
- it('/Sandbox with edit is successfully loaded', () => {
- cy.visit('/Sandbox#edit');
- cy.waitUntilSkeletonDisappear();
- cy.getByTestid('navbar-editor').should('be.visible');
- cy.get('.grw-editor-navbar-bottom').should('be.visible');
- cy.getByTestid('save-page-btn').should('be.visible');
- cy.get('.grw-grant-selector').should('be.visible');
- cy.collapseSidebar(true);
- cy.screenshot(`${ssPrefix}-Sandbox-edit-page`);
- })
- it('View and Edit contents are successfully loaded', () => {
- const body1 = 'hello';
- cy.visit('/Sandbox/testForUseEditingMarkdown');
- cy.get('#grw-page-editor-mode-manager').as('pageEditorModeManager').should('be.visible');
- cy.waitUntil(() => {
- // do
- cy.get('@pageEditorModeManager').within(() => {
- cy.get('button:nth-child(2)').click();
- });
- // until
- return cy.get('.layout-root').then($elem => $elem.hasClass('editing'));
- })
- cy.get('.grw-editor-navbar-bottom').should('be.visible');
- // check edited contents after save
- cy.get('.CodeMirror').type(body1);
- cy.get('.CodeMirror').contains(body1);
- cy.get('.page-editor-preview-body').contains(body1);
- cy.getByTestid('page-editor').should('be.visible');
- cy.getByTestid('save-page-btn').click();
- cy.get('.wiki').should('be.visible');
- cy.get('.wiki').children().first().should('have.text', body1);
- })
- it('Editing contents are successfully loaded with shortcut key', () => {
- const body2 = ' world!';
- const savePageShortcutKey = '{ctrl+s}';
- cy.visit('/Sandbox/testForUseEditingMarkdown');
- cy.get('#grw-page-editor-mode-manager').as('pageEditorModeManager').should('be.visible');
- cy.waitUntil(() => {
- // do
- cy.get('@pageEditorModeManager').within(() => {
- cy.get('button:nth-child(2)').click();
- });
- // until
- return cy.get('.layout-root').then($elem => $elem.hasClass('editing'));
- })
- cy.get('.grw-editor-navbar-bottom').should('be.visible');
- // check editing contents with shortcut key
- cy.get('.CodeMirror-line').children().first().invoke('text').then((text) => {
- cy.get('.CodeMirror').type(body2);
- cy.get('.CodeMirror').contains(text+body2);
- cy.get('.page-editor-preview-body').contains(text+body2);
- cy.get('.CodeMirror').type(savePageShortcutKey);
- cy.get('.CodeMirror').contains(text+body2);
- cy.get('.page-editor-preview-body').contains(text+body2);
- })
- })
- it('/user/admin is successfully loaded', () => {
- cy.visit('/user/admin');
- cy.waitUntilSkeletonDisappear();
- // for check download toc data
- // https://redmine.weseek.co.jp/issues/111384
- // cy.get('.toc-link').should('be.visible');
- // eslint-disable-next-line cypress/no-unnecessary-waiting
- cy.wait(2000); // wait for calcViewHeight and rendering
- cy.collapseSidebar(true);
- cy.screenshot(`${ssPrefix}-user-admin`);
- });
- });
- context('Access to /me page', () => {
- const ssPrefix = 'access-to-me-page-';
- beforeEach(() => {
- // login
- cy.fixture("user-admin.json").then(user => {
- cy.login(user.username, user.password);
- });
- });
- it('/me is successfully loaded', () => {
- cy.visit('/me');
- cy.getByTestid('grw-user-settings').should('be.visible');
- cy.collapseSidebar(true);
- cy.screenshot(`${ssPrefix}-me`);
- });
- // it('Draft page is successfully shown', () => {
- // cy.visit('/me/drafts');
- // cy.screenshot(`${ssPrefix}-draft-page`);
- // });
- });
- context('Access to special pages', () => {
- const ssPrefix = 'access-to-special-pages-';
- beforeEach(() => {
- // login
- cy.fixture("user-admin.json").then(user => {
- cy.login(user.username, user.password);
- });
- });
- it('/trash is successfully loaded', () => {
- cy.visit('/trash');
- cy.getByTestid('trash-page-list').contains('There are no pages under this page.');
- cy.collapseSidebar(true);
- cy.screenshot(`${ssPrefix}-trash`);
- });
- it('/tags is successfully loaded', { scrollBehavior: false } ,() => {
- // open sidebar
- // cy.collapseSidebar(false);
- cy.visit('/tags');
- // cy.getByTestid('grw-sidebar-content-tags').within(() => {
- // cy.getByTestid('grw-tags-list').should('be.visible');
- // cy.getByTestid('grw-tags-list').contains('You have no tag, You can set tags on pages');
- // })
- cy.getByTestid('tags-page').within(() => {
- cy.getByTestid('grw-tags-list').should('be.visible');
- cy.getByTestid('grw-tags-list').contains('You have no tag, You can set tags on pages');
- });
- cy.collapseSidebar(true);
- cy.screenshot(`${ssPrefix}-tags`);
- });
- });
- context('Access to Template Editing Mode', () => {
- const ssPrefix = 'access-to-template-page-';
- const templateBody1 = 'Template for children';
- const templateBody2 = 'Template for descendants';
- const createPageFromPageTreeTest = (newPagePath: string, parentPagePath: string, expectedBody: string) => {
- cy.visit('/');
- cy.waitUntilSkeletonDisappear();
- // Open sidebar
- cy.collapseSidebar(false);
- cy.getByTestid('grw-contextual-navigation-sub').should('be.visible');
- cy.waitUntilSkeletonDisappear();
- // If PageTree is not active when the sidebar is opened, make it active
- cy.getByTestid('grw-sidebar-nav-primary-page-tree').should('be.visible')
- .then($elem => {
- if (!$elem.hasClass('active')) {
- cy.getByTestid('grw-sidebar-nav-primary-page-tree').click();
- }
- });
- // Create page (/{parentPath}}/{newPagePath}) from PageTree
- cy.getByTestid('grw-contextual-navigation-sub').within(() => {
- cy.get('.grw-pagetree-item-children').first().as('pagetreeItem').within(() => {
- cy.get('#page-create-button-in-page-tree').first().click({force: true})
- });
- });
- cy.get('@pagetreeItem').within(() => {
- cy.getByTestid('closable-text-input').type(newPagePath).type('{enter}');
- })
- cy.visit(`/${parentPagePath}/${newPagePath}`);
- cy.waitUntilSkeletonDisappear();
- cy.collapseSidebar(true);
- // Check if the template is applied
- cy.get('.content-main').within(() => {
- cy.get('.wiki').should('be.visible');
- cy.get('.wiki').children().first().should('have.text', expectedBody);
- })
- cy.screenshot(`${ssPrefix}-page(${newPagePath})-to-which-template-is-applied`)
- }
- beforeEach(() => {
- // login
- cy.fixture("user-admin.json").then(user => {
- cy.login(user.username, user.password);
- });
- });
- it("Successfully created template for children", () => {
- cy.visit('/Sandbox');
- cy.waitUntilSkeletonDisappear();
- cy.waitUntil(() => {
- // do
- cy.get('#grw-subnav-container').within(() => {
- cy.getByTestid('open-page-item-control-btn').find('button').click({force: true});
- });
- // wait until
- return cy.getByTestid('page-item-control-menu').then($elem => $elem.is(':visible'))
- });
- cy.getByTestid('open-page-template-modal-btn').filter(':visible').click({force: true});
- cy.getByTestid('page-template-modal').should('be.visible');
- cy.screenshot(`${ssPrefix}-open-page-template-modal`);
- cy.getByTestid('template-button-children').click(({force: true}))
- cy.waitUntilSkeletonDisappear();
- cy.getByTestid('navbar-editor').should('be.visible').then(()=>{
- cy.url().should('include', '/_template#edit');
- cy.screenshot(`${ssPrefix}-open-template-page-for-children-in-editor-mode`);
- });
- cy.get('.CodeMirror').type(templateBody1);
- cy.get('.CodeMirror').contains(templateBody1);
- cy.get('.page-editor-preview-body').contains(templateBody1);
- cy.getByTestid('page-editor').should('be.visible');
- cy.getByTestid('save-page-btn').click();
- });
- it('Template is applied to pages created from PageTree (template for children 1)', () => {
- createPageFromPageTreeTest('template-test-page1', '/Sandbox' ,templateBody1);
- });
- it('Successfully created template for descendants', () => {
- cy.visit('/Sandbox');
- cy.waitUntilSkeletonDisappear();
- cy.waitUntil(() => {
- // do
- cy.get('#grw-subnav-container').within(() => {
- cy.getByTestid('open-page-item-control-btn').find('button').click({force: true});
- });
- // Wait until
- return cy.getByTestid('page-item-control-menu').then($elem => $elem.is(':visible'))
- });
- cy.getByTestid('open-page-template-modal-btn').filter(':visible').click({force: true});
- cy.getByTestid('page-template-modal').should('be.visible');
- cy.getByTestid('template-button-decendants').click(({force: true}))
- cy.waitUntilSkeletonDisappear();
- cy.getByTestid('navbar-editor').should('be.visible').then(()=>{
- cy.url().should('include', '/__template#edit');
- cy.screenshot(`${ssPrefix}-open-template-page-for-descendants-in-editor-mode`);
- })
- cy.get('.CodeMirror').type(templateBody2);
- cy.get('.CodeMirror').contains(templateBody2);
- cy.get('.page-editor-preview-body').contains(templateBody2);
- cy.getByTestid('page-editor').should('be.visible');
- cy.getByTestid('save-page-btn').click();
- });
- it('Template is applied to pages created from PageTree (template for children 2)', () => {
- createPageFromPageTreeTest('template-test-page2','Sandbox',templateBody1);
- });
- it('Template is applied to pages created from PageTree (template for descendants)', () => {
- // delete /Sandbox/_template
- cy.visit('/Sandbox/_template');
- cy.waitUntil(() => {
- //do
- cy.get('#grw-subnav-container').within(() => {
- cy.getByTestid('open-page-item-control-btn').find('button').click({force: true});
- });
- // wait until
- return cy.getByTestid('page-item-control-menu').then($elem => $elem.is(':visible'))
- });
- cy.getByTestid('open-page-delete-modal-btn').filter(':visible').click({force: true});
- cy.getByTestid('page-delete-modal').should('be.visible').within(() => {
- cy.intercept('POST', '/_api/pages.remove').as('remove');
- cy.getByTestid('delete-page-button').click();
- cy.wait('@remove')
- });
- createPageFromPageTreeTest('template-test-page3','Sandbox',`${templateBody1}\n${templateBody2}`);
- })
- });
- context('Access to /me/all-in-app-notifications', () => {
- const ssPrefix = 'in-app-notifications-';
- beforeEach(() => {
- // login
- cy.fixture("user-admin.json").then(user => {
- cy.login(user.username, user.password);
- });
- });
- it('All In-App Notification list is successfully loaded', { scrollBehavior: false },() => {
- cy.visit('/');
- cy.get('.notification-wrapper').click();
- cy.get('.notification-wrapper > .dropdown-menu > a').click();
- cy.getByTestid('grw-in-app-notification-page').should('be.visible');
- cy.getByTestid('grw-in-app-notification-page-spinner').should('not.exist');
- cy.collapseSidebar(true);
- cy.screenshot(`${ssPrefix}-see-all`);
- cy.get('.grw-custom-nav-tab > div > ul > li:nth-child(2) > a').click();
- cy.getByTestid('grw-in-app-notification-page-spinner').should('not.exist');
- cy.collapseSidebar(true);
- cy.screenshot(`${ssPrefix}-see-unread`);
- });
- })
|