diff --git a/cypress/e2e/sharing/linkShare.spec.ts b/cypress/e2e/sharing/linkShare.spec.ts index de825f183..99b6fb5a0 100644 --- a/cypress/e2e/sharing/linkShare.spec.ts +++ b/cypress/e2e/sharing/linkShare.spec.ts @@ -2,24 +2,58 @@ import {LinkShareFactory} from '../../factories/link_sharing' import {ProjectFactory} from '../../factories/project' import {TaskFactory} from '../../factories/task' +function prepareLinkShare() { + const projects = ProjectFactory.create(1) + const tasks = TaskFactory.create(10, { + project_id: projects[0].id + }) + const linkShares = LinkShareFactory.create(1, { + project_id: projects[0].id, + right: 0, + }) + + return { + share: linkShares[0], + project: projects[0], + tasks, + } +} + describe('Link shares', () => { it('Can view a link share', () => { - const projects = ProjectFactory.create(1) - const tasks = TaskFactory.create(10, { - project_id: projects[0].id - }) - const linkShares = LinkShareFactory.create(1, { - project_id: projects[0].id, - right: 0, - }) + const {share, project, tasks} = prepareLinkShare() - cy.visit(`/share/${linkShares[0].hash}/auth`) + cy.visit(`/share/${share.hash}/auth`) cy.get('h1.title') - .should('contain', projects[0].title) + .should('contain', project.title) + cy.get('input.input[placeholder="Add a new task..."') + .should('not.exist') + cy.get('.tasks') + .should('contain', tasks[0].title) + + cy.url().should('contain', `/projects/${project.id}/list#share-auth-token=${share.hash}`) + }) + + it('Should work when directly viewing a project with share hash present', () => { + const {share, project, tasks} = prepareLinkShare() + + cy.visit(`/projects/${project.id}/list#share-auth-token=${share.hash}`) + + cy.get('h1.title') + .should('contain', project.title) cy.get('input.input[placeholder="Add a new task..."') .should('not.exist') cy.get('.tasks') .should('contain', tasks[0].title) }) + + it('Should work when directly viewing a task with share hash present', () => { + const {share, project, tasks} = prepareLinkShare() + + cy.visit(`/tasks/${tasks[0].id}#share-auth-token=${share.hash}`) + + cy.get('h1.title') + .should('contain', tasks[0].title) + }) })