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

Test project instance after leaving #585

Closed
EvanHahn opened this issue Apr 25, 2024 · 1 comment
Closed

Test project instance after leaving #585

EvanHahn opened this issue Apr 25, 2024 · 1 comment
Assignees
Labels
mvp Requirement for MVP

Comments

@EvanHahn
Copy link
Contributor

EvanHahn commented Apr 25, 2024

We don't test what happens when someone leaves a project, then tries to perform certain operations on it. This test may uncover bugs or missing features, which we should fix.

@EvanHahn
Copy link
Contributor Author

This looks like it was mostly done already:

test('Data access after leaving project', async (t) => {
const managers = await createManagers(3, t)
connectPeers(managers)
await waitForPeers(managers)
const [creator, coordinator, member] = managers
const projectId = await creator.createProject({ name: 'mapeo' })
await Promise.all([
invite({
invitor: creator,
invitees: [coordinator],
projectId,
roleId: COORDINATOR_ROLE_ID,
}),
invite({
invitor: creator,
invitees: [member],
projectId,
roleId: MEMBER_ROLE_ID,
}),
])
const projects = await Promise.all(
managers.map((m) => m.getProject(projectId))
)
const [, coordinatorProject, memberProject] = projects
await memberProject.observation.create({
schemaName: 'observation',
attachments: [],
tags: {},
refs: [],
metadata: {},
})
t.ok(
(await memberProject.observation.getMany()).length >= 1,
'Test is set up correctly'
)
await waitForSync(projects, 'initial')
await Promise.all([
coordinator.leaveProject(projectId),
member.leaveProject(projectId),
])
await waitForSync(projects, 'initial')
await t.exception(async () => {
await memberProject.observation.create({
schemaName: 'observation',
attachments: [],
tags: {},
refs: [],
metadata: {},
})
}, 'member cannot create new data after leaving')
await t.exception(
() => memberProject.observation.getMany(),
"Shouldn't be able to fetch observations after leaving"
)
t.alike(
await memberProject.$getProjectSettings(),
MapeoProject.EMPTY_PROJECT_SETTINGS,
'member getting project settings returns empty settings'
)
t.alike(
await coordinatorProject.$getProjectSettings(),
MapeoProject.EMPTY_PROJECT_SETTINGS,
'coordinator getting project settings returns empty settings'
)
await t.exception(async () => {
await coordinatorProject.$setProjectSettings({ name: 'foo' })
}, 'coordinator cannot update project settings after leaving')
await disconnectPeers(managers)
})

I'm sure there's more we can test but I think this is done for now.

@EvanHahn EvanHahn closed this as not planned Won't fix, can't repro, duplicate, stale May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mvp Requirement for MVP
Projects
None yet
Development

No branches or pull requests

1 participant