Disable the file tree "create file" name input while a request is in flight (#18001)

GitOrigin-RevId: ef505220e8cff1dce4c84483edacd96cc87bb1aa
This commit is contained in:
Alf Eaton
2024-04-25 08:04:33 +00:00
committed by Copybot
parent 2e634e665d
commit a697f9e7b0
6 changed files with 38 additions and 7 deletions
@@ -5,7 +5,7 @@ describe('<FileTreeCreateNameInput/>', function () {
it('renders an empty input', function () {
cy.mount(
<FileTreeCreateNameProvider>
<FileTreeCreateNameInput />
<FileTreeCreateNameInput inFlight={false} />
</FileTreeCreateNameProvider>
)
@@ -19,6 +19,7 @@ describe('<FileTreeCreateNameInput/>', function () {
<FileTreeCreateNameInput
label="File name in this project"
placeholder="Enter a file name…"
inFlight={false}
/>
</FileTreeCreateNameProvider>
)
@@ -30,7 +31,7 @@ describe('<FileTreeCreateNameInput/>', function () {
it('uses an initial name', function () {
cy.mount(
<FileTreeCreateNameProvider initialName="test.tex">
<FileTreeCreateNameInput />
<FileTreeCreateNameInput inFlight={false} />
</FileTreeCreateNameProvider>
)
@@ -42,7 +43,7 @@ describe('<FileTreeCreateNameInput/>', function () {
cy.mount(
<FileTreeCreateNameProvider initialName="test.tex">
<FileTreeCreateNameInput focusName />
<FileTreeCreateNameInput focusName inFlight={false} />
</FileTreeCreateNameProvider>
)
@@ -66,4 +67,26 @@ describe('<FileTreeCreateNameInput/>', function () {
expect(element.get(0).selectionEnd).to.equal(4)
})
})
it('disables the input when in flight', function () {
cy.mount(
<FileTreeCreateNameProvider initialName="test.tex">
<FileTreeCreateNameInput inFlight={false} />
</FileTreeCreateNameProvider>
).then(({ rerender }) => {
cy.findByLabelText('File Name').should('not.be.disabled')
rerender(
<FileTreeCreateNameProvider initialName="test.tex">
<FileTreeCreateNameInput inFlight />
</FileTreeCreateNameProvider>
)
cy.findByLabelText('File Name').should('be.disabled')
rerender(
<FileTreeCreateNameProvider initialName="test.tex">
<FileTreeCreateNameInput inFlight={false} />
</FileTreeCreateNameProvider>
)
cy.findByLabelText('File Name').should('not.be.disabled')
})
})
})