-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
chore(dashboard): user journey smoke tests #7124
base: next
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for novu-stg-vite-dashboard-poc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
apps/api/.gitignore
Outdated
@@ -121,3 +121,4 @@ backups/ | |||
|
|||
# Nest.js auto-generated metadata (https://docs.nestjs.com/recipes/swc#monorepo-and-cli-plugins) | |||
src/metadata.ts | |||
src/.env.test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the .env.test
file from git, because the local file that I used for the tests had sensitive clerk credentials
@@ -28,4 +28,6 @@ tsconfig.node.tsbuildinfo | |||
/test-results/ | |||
/playwright-report/ | |||
/blob-report/ | |||
/playwright/.cache/ | |||
/playwright/ | |||
.env.test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.env.test
is the file for the Dashboard env variables
/playwright/.cache/ | ||
/playwright/ | ||
.env.test | ||
.env.playwright |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.env.playwright
is the file for the playwright that has all env variables to setup the clerk and api session
@@ -5,6 +5,7 @@ | |||
"type": "module", | |||
"scripts": { | |||
"start": "vite", | |||
"start:test": "vite --mode test", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run dashboard and use .env.test
file
"@novu/dal": "workspace:*", | ||
"@novu/testing": "workspace:*", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
used to initialize the api session
bridgeServer = new BridgeServer({ secretKey: session.environment.apiKeys[0].key, apiUrl: process.env.API_URL }); | ||
|
||
const newWorkflow = workflow(workflowId, async ({ step }) => { | ||
await step.inApp( | ||
inAppStepId, | ||
async (controls) => { | ||
return { | ||
subject: `Hi ${controls.name}! You've been invited to join the Novu project`, | ||
body, | ||
}; | ||
}, | ||
{ | ||
controlSchema: { | ||
type: 'object', | ||
properties: { | ||
name: { type: 'string', default: 'John' }, | ||
}, | ||
} as const, | ||
} | ||
); | ||
}); | ||
await bridgeServer.start({ workflows: [newWorkflow] }); | ||
await session.testAgent.post(`/v1/bridge/sync`).send({ | ||
bridgeUrl: bridgeServer.serverPath, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run the bridge server and sync the workflow
await session.testAgent.post(`/v1/bridge/sync`).send({ | ||
bridgeUrl: bridgeServer.serverPath, | ||
}); | ||
await page.waitForTimeout(2000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be removed
/** | ||
* TODO: Currently we are running tests with a single Clerk user and organization. | ||
* This approach has a drawback that the tests are not independent from each other and write the data to the same organization. | ||
* We should consider creating a new Clerk user and organization for each test using the @clerk/backend package. | ||
* Then initialize the BE session with the new Clerk user and organization and update Clerk user metadata from the newly created session. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hopefully, it explains the problem well
@@ -0,0 +1,3 @@ | |||
{ | |||
"type": "commonjs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dal
and testing
packages are CJS modules which can't be imported by the ESM modules.
So this is the trick (together with tsconfig.json) to say "please allow me to import" in my test files :D
private memberRepository = getEERepository<MemberRepository>('MemberRepository'); | ||
private memberRepository: MemberRepository; | ||
|
||
constructor({ mockClerkClient = true }: { mockClerkClient?: boolean } = {}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the Dashboard E2E tests we don't want to mock the Clerk client, because we initialize the Clerk session with a real user that has the org and metadata that is used by the Dashboard code.
@novu/client
@novu/framework
@novu/js
@novu/nest
@novu/headless
@novu/nextjs
@novu/node
@novu/notification-center
novu
@novu/providers
@novu/react
@novu/react-native
@novu/shared
@novu/stateless
commit: |
c9552fd
to
31ced54
Compare
31ced54
to
934a828
Compare
What changed? Why was the change needed?
Dashboard - the core user journeys smoke tests that cover:
TODO (in the future):
Screenshots