2024-05-30 03:12:56 -04:00
|
|
|
import { ensureUserExists, login } from './helpers/login'
|
2023-11-23 05:40:13 -05:00
|
|
|
import { createProject } from './helpers/project'
|
2024-05-30 03:12:56 -04:00
|
|
|
import { startWith } from './helpers/config'
|
2024-05-30 03:13:24 -04:00
|
|
|
import { throttledRecompile } from './helpers/compile'
|
2023-11-23 05:40:13 -05:00
|
|
|
|
|
|
|
describe('Project creation and compilation', function () {
|
2024-05-30 03:12:56 -04:00
|
|
|
startWith({})
|
|
|
|
ensureUserExists({ email: 'user@example.com' })
|
|
|
|
ensureUserExists({ email: 'collaborator@example.com' })
|
|
|
|
|
2023-11-23 05:40:13 -05:00
|
|
|
it('users can create project and compile it', function () {
|
|
|
|
login('user@example.com')
|
|
|
|
cy.visit('/project')
|
2024-01-16 04:40:22 -05:00
|
|
|
// this is the first project created, the welcome screen is displayed instead of the project list
|
2024-05-30 03:12:56 -04:00
|
|
|
createProject('test-project')
|
2023-11-23 05:40:13 -05:00
|
|
|
cy.url().should('match', /\/project\/[a-fA-F0-9]{24}/)
|
2024-05-30 03:13:24 -04:00
|
|
|
const recompile = throttledRecompile()
|
2024-02-09 06:27:26 -05:00
|
|
|
cy.findByText('\\maketitle').parent().click()
|
|
|
|
cy.findByText('\\maketitle').parent().type('\n\\section{{}Test Section}')
|
2024-05-30 03:13:24 -04:00
|
|
|
recompile()
|
2023-11-23 05:40:13 -05:00
|
|
|
cy.get('.pdf-viewer').should('contain.text', 'Test Section')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('create and edit markdown file', function () {
|
|
|
|
const fileName = `test-${Date.now()}.md`
|
|
|
|
const markdownContent = '# Markdown title'
|
|
|
|
login('user@example.com')
|
|
|
|
cy.visit('/project')
|
|
|
|
createProject('test-project')
|
|
|
|
// FIXME: Add aria-label maybe? or at least data-test-id
|
2024-05-13 07:56:40 -04:00
|
|
|
cy.findByText('New file').click({ force: true })
|
2023-11-23 05:40:13 -05:00
|
|
|
cy.findByRole('dialog').within(() => {
|
|
|
|
cy.get('input').clear()
|
|
|
|
cy.get('input').type(fileName)
|
|
|
|
cy.findByText('Create').click()
|
|
|
|
})
|
|
|
|
cy.findByText(fileName).click()
|
|
|
|
// wait until we've switched to the newly created empty file
|
|
|
|
cy.get('.cm-line').should('have.length', 1)
|
|
|
|
cy.get('.cm-line').type(markdownContent)
|
|
|
|
cy.findByText('main.tex').click()
|
|
|
|
cy.get('.cm-content').should('contain.text', '\\maketitle')
|
|
|
|
cy.findByText(fileName).click()
|
|
|
|
cy.get('.cm-content').should('contain.text', markdownContent)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('can link and display linked image from other project', function () {
|
|
|
|
const sourceProjectName = `test-project-${Date.now()}`
|
|
|
|
const targetProjectName = `${sourceProjectName}-target`
|
|
|
|
login('user@example.com')
|
|
|
|
|
|
|
|
cy.visit('/project')
|
|
|
|
createProject(sourceProjectName, { type: 'Example Project' }).as(
|
|
|
|
'sourceProjectId'
|
|
|
|
)
|
|
|
|
|
|
|
|
cy.visit('/project')
|
|
|
|
createProject(targetProjectName)
|
|
|
|
|
|
|
|
// link the image from `projectName` into this project
|
2024-05-13 07:56:40 -04:00
|
|
|
cy.findByText('New file').click({ force: true })
|
2023-11-23 05:40:13 -05:00
|
|
|
cy.findByRole('dialog').within(() => {
|
2024-05-13 07:56:40 -04:00
|
|
|
cy.findByText('From another project').click()
|
2023-11-23 05:40:13 -05:00
|
|
|
cy.findByLabelText('Select a Project').select(sourceProjectName)
|
|
|
|
cy.findByLabelText('Select a File').select('frog.jpg')
|
|
|
|
cy.findByText('Create').click()
|
|
|
|
})
|
2024-02-09 06:27:26 -05:00
|
|
|
cy.findByTestId('file-tree').findByText('frog.jpg').click()
|
2023-11-23 05:40:13 -05:00
|
|
|
cy.findByText('Another project')
|
|
|
|
.should('have.attr', 'href')
|
|
|
|
.then(href => {
|
|
|
|
cy.get('@sourceProjectId').then(sourceProjectId => {
|
|
|
|
expect(href).to.equal(`/project/${sourceProjectId}`)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('can refresh linked files as collaborator', function () {
|
|
|
|
const sourceProjectName = `test-project-${Date.now()}`
|
|
|
|
const targetProjectName = `${sourceProjectName}-target`
|
|
|
|
login('user@example.com')
|
|
|
|
|
|
|
|
cy.visit('/project')
|
|
|
|
createProject(sourceProjectName, { type: 'Example Project' }).as(
|
|
|
|
'sourceProjectId'
|
|
|
|
)
|
|
|
|
|
|
|
|
cy.visit('/project')
|
|
|
|
createProject(targetProjectName).as('targetProjectId')
|
|
|
|
|
|
|
|
// link the image from `projectName` into this project
|
2024-05-13 07:56:40 -04:00
|
|
|
cy.findByText('New file').click({ force: true })
|
2023-11-23 05:40:13 -05:00
|
|
|
cy.findByRole('dialog').within(() => {
|
2024-05-13 07:56:40 -04:00
|
|
|
cy.findByText('From another project').click()
|
2023-11-23 05:40:13 -05:00
|
|
|
cy.findByLabelText('Select a Project').select(sourceProjectName)
|
|
|
|
cy.findByLabelText('Select a File').select('frog.jpg')
|
|
|
|
cy.findByText('Create').click()
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.findByText('Share').click()
|
|
|
|
cy.findByRole('dialog').within(() => {
|
|
|
|
cy.get('input').type('collaborator@example.com,')
|
2024-02-08 11:51:26 -05:00
|
|
|
cy.findByText('Share').click({ force: true })
|
2023-11-23 05:40:13 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
cy.visit('/project')
|
|
|
|
cy.findByText('Account').click()
|
|
|
|
cy.findByText('Log Out').click()
|
|
|
|
|
|
|
|
login('collaborator@example.com')
|
|
|
|
cy.visit('/project')
|
|
|
|
cy.findByText(targetProjectName)
|
|
|
|
.parent()
|
|
|
|
.parent()
|
2024-06-21 11:10:05 -04:00
|
|
|
.within(() => {
|
|
|
|
cy.findByText('Join Project').click()
|
|
|
|
})
|
2023-11-23 05:40:13 -05:00
|
|
|
cy.findByText('Open Project').click()
|
|
|
|
cy.url().should('match', /\/project\/[a-fA-F0-9]{24}/)
|
|
|
|
cy.get('@targetProjectId').then(targetProjectId => {
|
|
|
|
cy.url().should('include', targetProjectId)
|
|
|
|
})
|
|
|
|
|
2024-02-09 06:27:26 -05:00
|
|
|
cy.findByTestId('file-tree').findByText('frog.jpg').click()
|
2023-11-23 05:40:13 -05:00
|
|
|
cy.findByText('Another project')
|
|
|
|
.should('have.attr', 'href')
|
|
|
|
.then(href => {
|
|
|
|
cy.get('@sourceProjectId').then(sourceProjectId => {
|
|
|
|
expect(href).to.equal(`/project/${sourceProjectId}`)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|