Skip to content
Closed
Show file tree
Hide file tree
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
80 changes: 80 additions & 0 deletions e2e/api-email.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { test, expect } from "@playwright/test";
import { purgeE2eTestData } from "@services/e2e";

// Annotate entire file as serial.
test.describe.configure({ mode: "serial" });

Check failure on line 5 in e2e/api-email.spec.ts

View workflow job for this annotation

GitHub Actions / static-analytics

e2e/api-email.spec.ts

Error: Playwright Test did not expect test.describe.configure() to be called here. Most common reasons include: - You are calling test.describe.configure() in a configuration file. - You are calling test.describe.configure() in a file that is imported by the configuration file. - You have two different versions of @playwright/test. This usually happens when one of the dependencies in your package.json depends on @playwright/test. ❯ TestTypeImpl._currentSuite node_modules/playwright/lib/common/testType.js:74:13 ❯ TestTypeImpl._configure node_modules/playwright/lib/common/testType.js:161:24 ❯ Function.configure node_modules/playwright/lib/transform/transform.js:288:12 ❯ e2e/api-email.spec.ts:5:15

Check failure on line 5 in e2e/api-email.spec.ts

View workflow job for this annotation

GitHub Actions / static-analytics

e2e/api-email.spec.ts

Error: Playwright Test did not expect test.describe.configure() to be called here. Most common reasons include: - You are calling test.describe.configure() in a configuration file. - You are calling test.describe.configure() in a file that is imported by the configuration file. - You have two different versions of @playwright/test. This usually happens when one of the dependencies in your package.json depends on @playwright/test. ❯ TestTypeImpl._currentSuite node_modules/playwright/lib/common/testType.js:74:13 ❯ TestTypeImpl._configure node_modules/playwright/lib/common/testType.js:161:24 ❯ Function.configure node_modules/playwright/lib/transform/transform.js:288:12 ❯ e2e/api-email.spec.ts:5:15

const adminCredentials = {
email: "demo@demo.com",
password: "sonicjs!",
};
var token = "";

test.beforeAll(async ({ request }) => {
token = await loginAsAdmin(request);
await cleanup(request, token);
});

async function loginAsAdmin(request) {
const response = await request.post(`/api/v1/auth/login`, {
data: adminCredentials,
headers: {
"Content-Type": "application/json",
},
});
const { bearer } = await response.json();
return bearer;
}

test("should allow admin to send email /api/v1/email", async ({ request }) => {
const emailBody = {
to: "z@z.com",
subject: "Hello World",
template: "magic-link",
templateData: {
otp: "123456",
},
};

const responseLogout = await request.post(`/api/v1/email`, {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
data: emailBody,
});
expect(responseLogout.status()).toBe(200);
const { message } = await responseLogout.json();
});

test.afterEach(async ({ request }) => {
await cleanup(request, token);
});

const cleanup = async (request, token) => {
const response = await request.post(`/api/v1/test/e2e/cleanup`, {
headers: {
Authorization: `Bearer ${token}`,
},
});

expect(response.status()).toBe(200);
};

const createTestUser = async (request, token) => {
const response = await request.post(`/api/v1/users`, {
headers: {
Authorization: `Bearer ${token}`,
},
data: {
data: {
email: "e2e!!@test.com",
password: "newpassword123abc",
firstName: "Demo",
lastName: "User",
},
},
});

return response;
};
23 changes: 22 additions & 1 deletion migrations/meta/0004_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "6",
"dialect": "sqlite",
"id": "fd55772a-df1f-4f61-8b86-826ec29bc08b",
"id": "deac16e6-75b5-4d75-b11e-2253eef5532c",
"prevId": "55960a79-2c24-44ef-aae1-d5fd67d24442",
"tables": {
"cacheRequests": {
Expand Down Expand Up @@ -101,6 +101,8 @@
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
<<<<<<< HEAD
=======
"categories": {
"name": "categories",
"columns": {
Expand Down Expand Up @@ -484,6 +486,7 @@
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
>>>>>>> main
"userSessions": {
"name": "userSessions",
"columns": {
Expand Down Expand Up @@ -594,6 +597,24 @@
"notNull": true,
"autoincrement": false
},
<<<<<<< HEAD
"passwordExpired": {
"name": "passwordExpired",
"type": "boolean",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": false
},
"passwordOTP": {
"name": "passwordOTP",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
=======
>>>>>>> main
"role": {
"name": "role",
"type": "text",
Expand Down
Loading
Loading