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

feat(server): improved subscription testing DX + tests for common subs + new subs #3554

Merged
merged 18 commits into from
Nov 27, 2024

Conversation

fabis94
Copy link
Contributor

@fabis94 fabis94 commented Nov 26, 2024

Description & motivation

Changes:

To-do before merge:

Screenshots:

Validation of changes:

Checklist:

  • My pull request follows the guidelines in the Contributing guide?
  • My pull request does not duplicate any other open Pull Requests for the same update/change?
  • My commits are related to the pull request and do not amend unrelated code or documentation.
  • My code follows a similar style to existing code.
  • I have added appropriate tests.
  • I have updated or added relevant documentation.

References

Copy link

linear bot commented Nov 26, 2024

q.leftJoin(UserEmails.name, UserEmails.col.userId, Users.col.id).where({
[UserEmails.col.primary]: true
q.leftJoin(UserEmails.name, (j1) => {
j1.on(UserEmails.col.userId, Users.col.id).andOnVal(UserEmails.col.primary, true)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was causing getUser(s) to return null, even if the user was there, because user_emails is not synced to the region db

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we querying users from the region db?

Copy link
Contributor Author

@fabis94 fabis94 Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gjedlicska test prep. even outside of that, the query is invalid - it should not filter out users just because they dont have a UserEmails entry

edit: i suppose in theory you could also want to omit users w/o user_emails, but I still believe that in practice in shouldn't

) => {
const { db } = deps
const { owner, stream } = options || {}
export async function createTestCommits(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes more sense for these to autoresolve the projectdb, instead of test writers having to do that manually beforehand

})
let id: string
if (streamObj.workspaceId) {
const createWorkspaceProject = createWorkspaceProjectFactory({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if u want a multiregion project, do createTestStream w/ workspaceId set AND run tests in multiregion mode

Copy link
Contributor

📸 Preview service has generated an image.

Copy link
Contributor

📸 Preview service has generated an image.

Copy link
Contributor

📸 Preview service has generated an image.

const useRegion = isMultiRegionTestMode() && regionKey

if (!FF_WORKSPACES_MODULE_ENABLED) {
// Just skip creation and set id to undefined - this allows this to be invoked the same way if FFs are on or off
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can see how this is kinda hacky, but this allows me to write the same test code that works in both no-workspaces/with workspaces but not multiregion/with workspaces and multiregion mode

if there's better options, i'm open to it

Copy link
Contributor

📸 Preview service has generated an image.

totalCount: await getUserStreamsCount(filter)
totalCount: await getUserStreamsCount({
...filter,
searchQuery: filter.search || undefined
Copy link
Contributor Author

@fabis94 fabis94 Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workspace.projects.totalCount when filter was applied was busted until now

@fabis94 fabis94 marked this pull request as ready for review November 27, 2024 10:48
@fabis94 fabis94 changed the title feat(server): improved subscription testing DX + tests for common subs feat(server): improved subscription testing DX + tests for common subs + new subs Nov 27, 2024
@@ -108,7 +108,8 @@ const {
filter: {
search: (search.value || '').trim() || null,
onlyWithRoles: selectedRoles.value?.length ? selectedRoles.value : null
}
},
cursor: null as Nullable<string>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ts error from previous code, @Mikehrn @andrewwallacespeckle plz check that TS linting works on ur end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabis94 Generally my linting is working as expected, but this never threw an error 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mikehrn it appears that vue-tsc, the CI linter doesn't pick up on this, which explains why it got through to main. in VSCode I definitely see squiggly lines in Dashboard.vue due to the type not being valid 🤔

@@ -451,9 +490,9 @@ export async function init() {
}

export async function shutdown(params: {
graphqlServer: ApolloServer<GraphQLContext>
graphqlServer: Optional<ApolloServer<GraphQLContext>>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

server will be undefined if test beforeAll hook fails

import { BasicTestStream, createTestStreams } from '@/test/speckle-helpers/streamHelper'
import { expect } from 'chai'

describe('Core GraphQL Subscriptions (New)', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NEW PATTERN FOR SUBSCRIPTION TESTING - EASY AND FAST

@@ -24,6 +24,7 @@
"dev:server:test": "cross-env DISABLE_NOTIFICATIONS_CONSUMPTION=true NODE_ENV=test LOG_LEVEL=silent LOG_PRETTY=true node ./bin/ts-www",
"test": "cross-env NODE_ENV=test LOG_LEVEL=silent LOG_PRETTY=true mocha",
"test:multiregion": "cross-env RUN_TESTS_IN_MULTIREGION_MODE=true FF_WORKSPACES_MODULE_ENABLED=true FF_WORKSPACES_MULTI_REGION_ENABLED=true yarn test",
"test:no-ff": "cross-env DISABLE_ALL_FFS=true yarn test",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new easy way to run all tests w/ FFs off, even locally

@fabis94 fabis94 requested a review from cdriesler November 27, 2024 10:54
Copy link
Contributor

📸 Preview service has generated an image.

Copy link
Contributor

📸 Preview service has generated an image.

Copy link
Contributor

@Mikehrn Mikehrn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FE looks good 🚀

@fabis94 fabis94 merged commit 1800dbb into main Nov 27, 2024
28 of 30 checks passed
@fabis94 fabis94 deleted the fabians/web-2168 branch November 27, 2024 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants