#6457 Disable sharing for multi-file AST (#6583)

* disable ShareButton if AST uses import statement

* remove unused code

* add e2e test for ShareButton disabled in multi-file projects
This commit is contained in:
Andrew Varga
2025-05-01 20:01:08 +02:00
committed by GitHub
parent ad975152c1
commit e8e7c22b95
3 changed files with 47 additions and 45 deletions

View File

@ -1,4 +1,6 @@
import { expect, test } from '@e2e/playwright/zoo-test'
import { join } from 'path'
import * as fsp from 'fs/promises'
test.describe('Electron app header tests', () => {
test(
@ -43,4 +45,33 @@ test.describe('Electron app header tests', () => {
await expect(userSettingsButton).toHaveText(text)
}
)
test('Share button is disabled when imports are present', async ({
page,
context,
homePage,
toolbar,
}) => {
const projectName = 'share-disabled-for-imports'
await context.folderSetupFn(async (dir) => {
const testDir = join(dir, projectName)
await fsp.mkdir(testDir, { recursive: true })
await fsp.writeFile(join(testDir, 'deps.kcl'), 'export x = 42')
await fsp.writeFile(join(testDir, 'main.kcl'), 'import x from "deps.kcl"')
})
await page.setBodyDimensions({ width: 1200, height: 500 })
await homePage.openProject(projectName)
const shareButton = page.getByTestId('share-button')
// Open deps.kcl (which has no imports) and verify share button is enabled
await toolbar.fileTreeBtn.click()
await toolbar.openFile('deps.kcl')
await expect(shareButton).not.toBeDisabled()
// Open main.kcl (which has an import) and verify share button is disabled
await toolbar.openFile('main.kcl')
await expect(shareButton).toBeDisabled()
})
})