Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app-shell): Fix flaky file system test #17212

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 55 additions & 54 deletions app-shell/src/protocol-storage/__tests__/file-system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,66 +109,67 @@ describe('protocol storage directory utilities', () => {
})

describe('parseProtocolDirs', () => {
it('reads and parses directories', () => {
it('reads and parses directories', async () => {
const protocolsDir = makeEmptyDir()

const firstProtocolDirName = 'protocol_item_1'
const secondProtocolDirName = 'protocol_item_2'

const firstDirPath = path.join(protocolsDir, firstProtocolDirName)
const secondDirPath = path.join(protocolsDir, secondProtocolDirName)

return Promise.all([
fs.emptyDir(path.join(protocolsDir, firstProtocolDirName)),
fs.emptyDir(path.join(protocolsDir, firstProtocolDirName, 'src')),
fs.createFile(
path.join(protocolsDir, firstProtocolDirName, 'src', 'main.py')
),
fs.emptyDir(path.join(protocolsDir, firstProtocolDirName, 'analysis')),
fs.createFile(
path.join(
protocolsDir,
firstProtocolDirName,
'analysis',
'fake_timestamp0.json'
)
),
fs.emptyDir(path.join(protocolsDir, secondProtocolDirName)),
fs.emptyDir(path.join(protocolsDir, secondProtocolDirName, 'src')),
fs.createFile(
path.join(protocolsDir, secondProtocolDirName, 'src', 'main.json')
),
fs.emptyDir(path.join(protocolsDir, secondProtocolDirName, 'analysis')),
fs.createFile(
path.join(
protocolsDir,
secondProtocolDirName,
'analysis',
'fake_timestamp1.json'
)
),
]).then(() => {
return expect(
parseProtocolDirs([firstDirPath, secondDirPath])
).resolves.toEqual([
{
dirPath: firstDirPath,
modified: expect.any(Number),
srcFilePaths: [path.join(firstDirPath, 'src', 'main.py')],
analysisFilePaths: [
path.join(firstDirPath, 'analysis', 'fake_timestamp0.json'),
],
},
{
dirPath: secondDirPath,
modified: expect.any(Number),
srcFilePaths: [path.join(secondDirPath, 'src', 'main.json')],
analysisFilePaths: [
path.join(secondDirPath, 'analysis', 'fake_timestamp1.json'),
],
},
])
})
await fs.emptyDir(path.join(protocolsDir, firstProtocolDirName))
await fs.emptyDir(path.join(protocolsDir, firstProtocolDirName, 'src'))
await fs.emptyDir(
path.join(protocolsDir, firstProtocolDirName, 'analysis')
)
await fs.createFile(
path.join(protocolsDir, firstProtocolDirName, 'src', 'main.py')
)
await fs.createFile(
path.join(
protocolsDir,
firstProtocolDirName,
'analysis',
'fake_timestamp0.json'
)
)

await fs.emptyDir(path.join(protocolsDir, secondProtocolDirName))
await fs.emptyDir(path.join(protocolsDir, secondProtocolDirName, 'src'))
await fs.emptyDir(
path.join(protocolsDir, secondProtocolDirName, 'analysis')
)
await fs.createFile(
path.join(protocolsDir, secondProtocolDirName, 'src', 'main.json')
)
await fs.createFile(
path.join(
protocolsDir,
secondProtocolDirName,
'analysis',
'fake_timestamp1.json'
)
)

const result = await parseProtocolDirs([firstDirPath, secondDirPath])

expect(result).toEqual([
{
dirPath: firstDirPath,
modified: expect.any(Number),
srcFilePaths: [path.join(firstDirPath, 'src', 'main.py')],
analysisFilePaths: [
path.join(firstDirPath, 'analysis', 'fake_timestamp0.json'),
],
},
{
dirPath: secondDirPath,
modified: expect.any(Number),
srcFilePaths: [path.join(secondDirPath, 'src', 'main.json')],
analysisFilePaths: [
path.join(secondDirPath, 'analysis', 'fake_timestamp1.json'),
],
},
])
})
})

Expand Down
Loading