Fix: disable toggle for share link creation without archive version, fix auto-copy in Safari (#4885)

* Fix: disable share link archive switch if archive version doesnt exist

* Fix: Add brief timeout before copy after share link creation for Safari, only show if succeeded

* Update messages.xlf
This commit is contained in:
shamoon
2023-12-07 13:48:33 -08:00
committed by GitHub
parent 7337792e61
commit 082df8b886
6 changed files with 65 additions and 39 deletions

View File

@@ -19,6 +19,7 @@ import { ToastService } from 'src/app/services/toast.service'
import { environment } from 'src/environments/environment'
import { ShareLinksDropdownComponent } from './share-links-dropdown.component'
import { Clipboard } from '@angular/cdk/clipboard'
import { By } from '@angular/platform-browser'
describe('ShareLinksDropdownComponent', () => {
let component: ShareLinksDropdownComponent
@@ -88,7 +89,7 @@ describe('ShareLinksDropdownComponent', () => {
.mockReturnValueOnce(throwError(() => new Error('Unable to get links')))
component.documentId = 99
component.refresh()
component.ngOnInit()
fixture.detectChanges()
expect(toastSpy).toHaveBeenCalled()
})
@@ -97,12 +98,13 @@ describe('ShareLinksDropdownComponent', () => {
const createSpy = jest.spyOn(shareLinkService, 'createLinkForDocument')
component.documentId = 99
component.expirationDays = 7
component.archiveVersion = false
component.useArchiveVersion = false
const expiration = new Date()
expiration.setDate(expiration.getDate() + 7)
const copySpy = jest.spyOn(clipboard, 'copy')
copySpy.mockReturnValue(true)
const refreshSpy = jest.spyOn(component, 'refresh')
component.createLink()
@@ -117,8 +119,10 @@ describe('ShareLinksDropdownComponent', () => {
fixture.detectChanges()
tick(3000)
expect(copySpy).toHaveBeenCalled()
expect(refreshSpy).toHaveBeenCalled()
expect(copySpy).toHaveBeenCalled()
expect(component.copied).toEqual(1)
tick(100) // copy timeout
}))
it('should show error on link creation if needed', () => {
@@ -212,4 +216,16 @@ describe('ShareLinksDropdownComponent', () => {
'http://example.domainwithapiinit.com:1234/subpath/share/123abc123'
)
})
it('should disable archive switch & option if no archive available', () => {
component.hasArchiveVersion = false
component.ngOnInit()
fixture.detectChanges()
expect(component.useArchiveVersion).toBeFalsy()
expect(
fixture.debugElement.query(By.css("input[type='checkbox']")).attributes[
'ng-reflect-is-disabled'
]
).toBeTruthy()
})
})