})
cy.viewport(1024, 1024)
- cy.visit('/documents/1/')
+ cy.visit('/documents/1/').wait('@ui-settings')
})
it('should activate / deactivate save button when changes are saved', () => {
cy.contains('You have unsaved changes').should('not.exist')
})
+ it('should show a mobile preview', () => {
+ cy.viewport(440, 1000)
+ cy.get('a')
+ .contains('Preview')
+ .scrollIntoView({ offset: { top: 150, left: 0 } })
+ .click()
+ cy.get('pdf-viewer').should('be.visible')
+ })
+
it('should show a list of comments', () => {
- cy.wait(1000).get('a').contains('Comments').click().wait(1000)
+ cy.wait(1000)
+ .get('a')
+ .contains('Comments')
+ .click({ force: true })
+ .wait(1000)
cy.get('app-document-comments').find('.card').its('length').should('eq', 3)
})
req.reply(response)
})
+
+ cy.intercept('http://localhost:8000/api/documents/selection_data/', {
+ fixture: 'documents/selection_data.json',
+ }).as('selection-data')
})
cy.viewport(1280, 1024)
cy.get('app-document-card-large')
})
+ it('should show partial tag selection', () => {
+ cy.get('app-document-card-small:nth-child(1)').click()
+ cy.get('app-document-card-small:nth-child(4)').click()
+ cy.get('app-bulk-editor button')
+ .contains('Tags')
+ .click()
+ .wait('@selection-data')
+ cy.get('svg.bi-dash').should('be.visible')
+ cy.get('svg.bi-check').should('be.visible')
+ })
+
+ it('should allow bulk removal', () => {
+ cy.get('app-document-card-small:nth-child(1)').click()
+ cy.get('app-document-card-small:nth-child(4)').click()
+ cy.get('app-bulk-editor').within(() => {
+ cy.get('button').contains('Tags').click().wait('@selection-data')
+ cy.get('button').contains('Another Sample Tag').click()
+ cy.get('button').contains('Apply').click()
+ })
+ cy.contains('operation will remove the tag')
+ })
+
it('should filter tags', () => {
cy.get('app-filter-editor app-filterable-dropdown[title="Tags"]').within(
() => {
req.reply(response)
}
).as('savedViews')
+ })
- cy.intercept('http://localhost:8000/api/mail_accounts/*', {
- fixture: 'mail_accounts/mail_accounts.json',
- })
- cy.intercept('http://localhost:8000/api/mail_rules/*', {
- fixture: 'mail_rules/mail_rules.json',
- }).as('mailRules')
- cy.intercept('http://localhost:8000/api/tasks/', {
- fixture: 'tasks/tasks.json',
- })
+ this.newMailAccounts = []
+
+ cy.intercept(
+ 'POST',
+ 'http://localhost:8000/api/mail_accounts/',
+ (req) => {
+ const newRule = req.body
+ newRule.id = 3
+ this.newMailAccounts.push(newRule) // store this for later
+ req.reply({ result: 'OK' })
+ }
+ ).as('saveAccount')
+
+ cy.fixture('mail_accounts/mail_accounts.json').then(
+ (mailAccountsJson) => {
+ cy.intercept(
+ 'GET',
+ 'http://localhost:8000/api/mail_accounts/*',
+ (req) => {
+ console.log(req, this.newMailAccounts)
+
+ let response = { ...mailAccountsJson }
+ if (this.newMailAccounts.length) {
+ response.results = response.results.concat(this.newMailAccounts)
+ }
+
+ req.reply(response)
+ }
+ ).as('getAccounts')
+ }
+ )
+
+ this.newMailRules = []
+
+ cy.intercept('POST', 'http://localhost:8000/api/mail_rules/', (req) => {
+ const newRule = req.body
+ newRule.id = 2
+ this.newMailRules.push(newRule) // store this for later
+ req.reply({ result: 'OK' })
+ }).as('saveRule')
+
+ cy.fixture('mail_rules/mail_rules.json').then((mailRulesJson) => {
+ cy.intercept('GET', 'http://localhost:8000/api/mail_rules/*', (req) => {
+ let response = { ...mailRulesJson }
+ if (this.newMailRules.length) {
+ response.results = response.results.concat(this.newMailRules)
+ }
+
+ req.reply(response)
+ }).as('getRules')
})
cy.fixture('documents/documents.json').then((documentsJson) => {
cy.visit('/dashboard')
cy.get('app-saved-view-widget').contains('Inbox').should('not.exist')
})
+
+ it('should show a list of mail accounts & rules & support creation', () => {
+ cy.contains('a', 'Mail').click()
+ cy.get('app-settings .tab-content ul li').its('length').should('eq', 5) // 2 headers, 2 accounts, 1 rule
+ cy.contains('button', 'Add Account').click()
+ cy.contains('Create new mail account')
+ cy.get('app-input-text[formcontrolname="name"]').type(
+ 'Example Mail Account'
+ )
+ cy.get('app-input-text[formcontrolname="imap_server"]').type(
+ 'mail.example.com'
+ )
+ cy.get('app-input-text[formcontrolname="imap_port"]').type('993')
+ cy.get('app-input-text[formcontrolname="username"]').type('username')
+ cy.get('app-input-password[formcontrolname="password"]').type('pass')
+ cy.contains('app-mail-account-edit-dialog button', 'Save')
+ .click()
+ .wait('@saveAccount')
+ .wait('@getAccounts')
+ cy.contains('Saved account')
+
+ cy.wait(1000)
+ cy.contains('button', 'Add Rule').click()
+ cy.contains('Create new mail rule')
+ cy.get('app-input-text[formcontrolname="name"]').type('Example Rule')
+ cy.get('app-input-select[formcontrolname="account"]').type('Example{enter}')
+ cy.get('app-input-number[formcontrolname="maximum_age"]').type('30')
+ cy.get('app-input-text[formcontrolname="filter_subject"]').type(
+ '[paperless]'
+ )
+ cy.contains('app-mail-rule-edit-dialog button', 'Save')
+ .click()
+ .wait('@saveRule')
+ .wait('@getRules')
+ cy.contains('Saved rule').wait(1000)
+
+ cy.get('app-settings .tab-content ul li').its('length').should('eq', 7)
+ })
})
beforeEach(() => {
cy.intercept('http://localhost:8000/api/ui_settings/', {
fixture: 'ui_settings/settings.json',
- })
+ }).as('ui-settings')
cy.intercept('http://localhost:8000/api/remote_version/', {
fixture: 'remote_version/remote_version.json',
fixture: 'storage_paths/storage_paths.json',
})
+ cy.intercept('http://localhost:8000/api/tasks/', {
+ fixture: 'tasks/tasks.json',
+ })
+
cy.intercept('http://localhost:8000/api/documents/1/metadata/', {
fixture: 'documents/1/metadata.json',
})