Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions packages/cypress/src/integration/library/write.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,34 @@ describe('[Library]', () => {
cy.url().should('match', /\/library?/);
});

it('[By Admin]', () => {
const project = MOCK_DATA.projects[0];

cy.signIn('demo_admin@example.com', 'demo_admin');

cy.step('Project is not authored by the admin');
cy.visit(`/library/${project.slug}`);
cy.get('[data-cy=Username]').should('not.contain', 'demo_admin');

cy.step("Admin can see the edit button on another user's project");
cy.get('[data-cy=edit]').should('be.visible');

cy.step('Admin can access the edit page');
cy.get('[data-cy=edit]').click();
cy.url().should('include', `/library/${project.slug}/edit`);

cy.step('Admin can edit the project description');
cy.get('[data-cy=intro-description]').should('be.visible');

const adminEdit = ' [edited by admin]';
cy.get('[data-cy=intro-description]').type(adminEdit, { delay: 5 });
cy.get('[data-cy=submit]').click();

cy.step('Updated content is visible');
cy.url().should('include', `/library/${project.slug}`);
cy.contains(adminEdit);
});

it('[Edit project - Replace images]', () => {
const randomId = generateAlphaNumeric(8).toLowerCase();
const initialTitle = `${randomId} Project for image edit`;
Expand Down
31 changes: 28 additions & 3 deletions packages/cypress/src/integration/news/write.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { users } from 'oa-shared/mocks/data';

import { MOCK_DATA } from '../../data';
import { generateAlphaNumeric } from '../../utils/TestUtils';

let initialRandomId;
Expand Down Expand Up @@ -198,8 +199,32 @@ describe('[News.Write]', () => {
cy.url().should('contain', '/sign-in?returnUrl=%2Fnews%2Fcreate');
});

// it('[Admin]', () => {
// Should check an admin can edit other's content
// })
it('[By Admin]', () => {
const newsItem = MOCK_DATA.news[0];

cy.signIn('demo_admin@example.com', 'demo_admin');

cy.step('News is not authored by the admin');
cy.visit(`/news/${newsItem.slug}`);
cy.get('[data-cy=Username]').should('not.contain', 'demo_admin');

cy.step("Admin can see the edit button on another user's news");
cy.get('[data-cy=edit]').should('be.visible');

cy.step('Admin can access the edit page');
cy.get('[data-cy=edit]').click();
cy.url().should('include', `/news/${newsItem.slug}/edit`);

cy.step('Admin can edit the news title');
cy.get('[data-cy=field-title]').should('be.visible');

const adminEdit = ' [edited by admin]';
cy.get('[data-cy=field-title]').type(adminEdit, { delay: 5 });
cy.get('[data-cy=submit]').click();

cy.step('Updated content is visible');
cy.url().should('include', `/news/${newsItem.slug}`);
cy.contains(adminEdit);
});
});
});
32 changes: 28 additions & 4 deletions packages/cypress/src/integration/research/write.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,34 @@ describe('[Research]', () => {
});
});

it('[By Admin]', () => {
const researchItem = MOCK_DATA.research[0];

cy.signIn('demo_admin@example.com', 'demo_admin');

cy.step('Research is not authored by the admin');
cy.visit(`/research/${researchItem.slug}`);
cy.get('[data-cy=Username]').should('not.contain', 'demo_admin');

cy.step("Admin can see the edit button on another user's research");
cy.get('[data-cy=edit]').should('be.visible');

cy.step('Admin can access the edit page');
cy.get('[data-cy=edit]').click();
cy.url().should('include', `/research/${researchItem.slug}/edit`);

cy.step('Admin can edit the research description');
cy.get('[data-cy=intro-description]').should('be.visible');

const adminEdit = ' [edited by admin]';
cy.get('[data-cy=intro-description]').type(adminEdit, { delay: 5 });
cy.get('[data-cy=submit]').click();

cy.step('Updated content is visible');
cy.url().should('include', `/research/${researchItem.slug}`);
cy.contains(adminEdit);
});

it('[Edit published update - Replace images and files]', () => {
const randomId = generateAlphaNumeric(8).toLowerCase();
const researchTitle = `${randomId} Research with update`;
Expand Down Expand Up @@ -410,9 +438,5 @@ describe('[Research]', () => {
cy.contains(updatedDescription);
cy.get('[data-cy=downloadButton]').should('be.visible');
});

// it('[By Admin]', () => {
// Should check an admin can edit other's content
// })
});
});
Loading