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

chore(dashboard): user journey smoke tests #7124

Open
wants to merge 10 commits into
base: next
Choose a base branch
from

Conversation

LetItRock
Copy link
Contributor

What changed? Why was the change needed?

Dashboard - the core user journeys smoke tests that cover:

  • dashboard-created workflow
  • code-created workflow

TODO (in the future):

  • we have one drawback: we need to establish independent clerk and api sessions for the tests, I left a comment about it in the code

Screenshots

Screenshot 2024-11-25 at 13 59 28

@LetItRock LetItRock self-assigned this Nov 25, 2024
Copy link

linear bot commented Nov 25, 2024

Copy link

netlify bot commented Nov 25, 2024

Deploy Preview for novu-stg-vite-dashboard-poc ready!

Name Link
🔨 Latest commit 934a828
🔍 Latest deploy log https://app.netlify.com/sites/novu-stg-vite-dashboard-poc/deploys/674510c3c5d7f80008c20b95
😎 Deploy Preview https://deploy-preview-7124--novu-stg-vite-dashboard-poc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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",
Copy link
Contributor Author

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

Comment on lines +91 to +92
"@novu/dal": "workspace:*",
"@novu/testing": "workspace:*",
Copy link
Contributor Author

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

Comment on lines +19 to +43
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,
});
Copy link
Contributor Author

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);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

should be removed

Comment on lines +10 to +15
/**
* 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.
*/
Copy link
Contributor Author

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"
Copy link
Contributor Author

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 } = {}) {
Copy link
Contributor Author

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.

Copy link

pkg-pr-new bot commented Nov 25, 2024

Open in Stackblitz

@novu/client

npm i https://pkg.pr.new/novuhq/novu/@novu/client@7124

@novu/framework

npm i https://pkg.pr.new/novuhq/novu/@novu/framework@7124

@novu/js

npm i https://pkg.pr.new/novuhq/novu/@novu/js@7124

@novu/nest

npm i https://pkg.pr.new/novuhq/novu/@novu/nest@7124

@novu/headless

npm i https://pkg.pr.new/novuhq/novu/@novu/headless@7124

@novu/nextjs

npm i https://pkg.pr.new/novuhq/novu/@novu/nextjs@7124

@novu/node

npm i https://pkg.pr.new/novuhq/novu/@novu/node@7124

@novu/notification-center

npm i https://pkg.pr.new/novuhq/novu/@novu/notification-center@7124

novu

npm i https://pkg.pr.new/novuhq/novu@7124

@novu/providers

npm i https://pkg.pr.new/novuhq/novu/@novu/providers@7124

@novu/react

npm i https://pkg.pr.new/novuhq/novu/@novu/react@7124

@novu/react-native

npm i https://pkg.pr.new/novuhq/novu/@novu/react-native@7124

@novu/shared

npm i https://pkg.pr.new/novuhq/novu/@novu/shared@7124

@novu/stateless

npm i https://pkg.pr.new/novuhq/novu/@novu/stateless@7124

commit: 934a828

@github-actions github-actions bot added the CI/CD label Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant