Skip to content

Commit

Permalink
test: move e2e tests to separate script
Browse files Browse the repository at this point in the history
  • Loading branch information
manast committed Feb 28, 2024
1 parent 5946952 commit bc68a60
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
- run: bun install
- run: bun run tsc
- run: bun test
- run: bun run test:e2e

test-dragonflydb:
runs-on: ubuntu-latest
Expand All @@ -56,3 +57,4 @@ jobs:
- run: bun install
- run: bun run tsc
- run: QUEUE_PREFIX={b} bun test
- run: QUEUE_PREFIX={b} bun run test:e2e
14 changes: 6 additions & 8 deletions src/e2e.test.ts → src/e2e-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe("e2e", () => {
expect(job).toHaveProperty('opts');
expect(token).toBe(token);

const updateProgress = await fetch(`http://127.0.0.1:8080/queues/${queueName}/jobs/${job.id}/progress`, {
const updateProgress = await fetch(`http://localhost:8080/queues/${queueName}/jobs/${job.id}/progress`, {
method: 'POST',
body: JSON.stringify(100),
headers: {
Expand All @@ -71,7 +71,7 @@ describe("e2e", () => {

expect(updateProgress.status).toBe(200);

const addLogs = await fetch(`http://127.0.0.1:8080/queues/${queueName}/jobs/${job.id}/logs`, {
const addLogs = await fetch(`http://localhost:8080/queues/${queueName}/jobs/${job.id}/logs`, {
method: 'POST',
body: JSON.stringify("log message"),
headers: {
Expand All @@ -94,7 +94,7 @@ describe("e2e", () => {
});

// Add a job to a queue
const addJobResponse = await fetch(`http://127.0.0.1:8080/queues/${queueName}/jobs`, {
const addJobResponse = await fetch(`http://localhost:8080/queues/${queueName}/jobs`, {
method: 'POST',
body: JSON.stringify([{ name: "test-job", data: 'test' }]),
headers: {
Expand All @@ -111,7 +111,7 @@ describe("e2e", () => {
expect(jobsAdded[0]).toHaveProperty('opts');

// Register a worker
const workerResponse = await fetch('http://127.0.0.1:8080/workers', {
const workerResponse = await fetch('http://localhost:8080/workers', {
method: 'POST',
body: JSON.stringify({
queue: queueName,
Expand All @@ -135,7 +135,7 @@ describe("e2e", () => {
// Wait so that the job has a chance to return its value
await new Promise(resolve => setTimeout(resolve, 1000));

const getJobResponse = await fetch(`http://127.0.0.1:8080/queues/${queueName}/jobs/${jobsAdded[0].id}`, {
const getJobResponse = await fetch(`http://localhost:8080/queues/${queueName}/jobs/${jobsAdded[0].id}`, {
headers: {
"Authorization": `Bearer ${token}`
}
Expand All @@ -144,16 +144,14 @@ describe("e2e", () => {
expect(getJobResponse.status).toBe(200);
const job = await getJobResponse.json() as JobJson;

console.log(job)

expect(job).toHaveProperty('id', jobsAdded[0].id);
expect(job).toHaveProperty('name', 'test-job');
expect(job).toHaveProperty('data', 'test');
expect(job).toHaveProperty('opts');
expect(job.returnvalue).toBe("foo bar");
expect(job.progress).toBe(100);

const getJobLogsResponse = await fetch(`http://127.0.0.1:8080/queues/${queueName}/jobs/${jobsAdded[0].id}/logs`, {
const getJobLogsResponse = await fetch(`http://localhost:8080/queues/${queueName}/jobs/${jobsAdded[0].id}/logs`, {
headers: {
"Authorization": `Bearer ${token}`
}
Expand Down

0 comments on commit bc68a60

Please sign in to comment.