Skip to content

Commit 89ebddf

Browse files
authored
Fix integration tests (#214)
1 parent dd4559b commit 89ebddf

File tree

2 files changed

+1
-108
lines changed

2 files changed

+1
-108
lines changed

.github/workflows/integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: ci
1+
name: integration tests
22

33
on: [push]
44

tests/integration/catalog.serial.test.ts

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -111,113 +111,6 @@ describe("Catalog API", () => {
111111
expect(deleteCatalogObjectsResp.deletedObjectIds).toHaveLength(200);
112112
}, 240_000);
113113

114-
it("should upload catalog image", async () => {
115-
// Add retry logic for the image upload
116-
const maxRetries = 5; // Increased from 3 to 5
117-
let lastError = null;
118-
119-
for (let attempt = 0; attempt < maxRetries; attempt++) {
120-
try {
121-
// If this isn't the first attempt, wait before retrying
122-
if (attempt > 0) {
123-
console.log(`Attempt ${attempt + 1} for image upload...`);
124-
// Increase wait time between retries exponentially
125-
await sleep(2 ** attempt * 5000);
126-
}
127-
128-
console.log(`Starting image upload attempt ${attempt + 1}`);
129-
130-
// Setup: Load a test image file
131-
const imageFile = await getTestFile();
132-
console.log("Test file loaded");
133-
134-
// Setup: Create a catalog object to associate the image with
135-
const catalogObject = createTestCatalogItem();
136-
137-
// Add delay before catalog creation
138-
await sleep(3000);
139-
console.log("Creating catalog object...");
140-
141-
const createCatalogResp = await client.catalog.batchUpsert(
142-
{
143-
idempotencyKey: newTestUuid(),
144-
batches: [
145-
{
146-
objects: [catalogObject],
147-
},
148-
],
149-
},
150-
{
151-
maxRetries: MAX_RETRIES_CATALOG,
152-
timeoutInSeconds: MAX_TIMEOUT,
153-
},
154-
);
155-
156-
console.log("Catalog object created");
157-
expect(createCatalogResp.objects).toHaveLength(1);
158-
const createdCatalogObject = createCatalogResp.objects?.[0];
159-
expect(createdCatalogObject).toBeDefined();
160-
161-
// Add delay before image upload
162-
await sleep(5000);
163-
console.log("Uploading image...");
164-
165-
// Create a new catalog image
166-
const imageName = `Test Image ${newTestUuid()}`;
167-
const createCatalogImageResp = await client.catalog.images.create(
168-
{
169-
imageFile,
170-
request: {
171-
idempotencyKey: newTestUuid(),
172-
objectId: createdCatalogObject?.id,
173-
image: {
174-
type: "IMAGE",
175-
id: newTestSquareTempId(),
176-
imageData: {
177-
name: imageName,
178-
},
179-
},
180-
},
181-
},
182-
{
183-
maxRetries: MAX_RETRIES_CATALOG,
184-
timeoutInSeconds: 180, // Increased timeout for image upload
185-
},
186-
);
187-
188-
console.log("Image uploaded successfully");
189-
expect(createCatalogImageResp.image).toBeDefined();
190-
191-
// Add delay before cleanup
192-
await sleep(3000);
193-
console.log("Starting cleanup...");
194-
195-
// Cleanup: Delete the created catalog object and image
196-
await client.catalog.batchDelete(
197-
{
198-
objectIds: [createdCatalogObject?.id!, createCatalogImageResp.image?.id!],
199-
},
200-
{
201-
maxRetries: MAX_RETRIES_CATALOG,
202-
timeoutInSeconds: MAX_TIMEOUT,
203-
},
204-
);
205-
206-
console.log("Cleanup completed");
207-
// If we get here, the test succeeded, so break out of retry loop
208-
return;
209-
} catch (error) {
210-
lastError = error;
211-
console.log(`Attempt ${attempt + 1} failed with error:`, error);
212-
// If this was the last attempt, the error will be thrown below
213-
}
214-
}
215-
216-
// If we get here, all retries failed
217-
console.log("All image upload attempts failed");
218-
throw lastError;
219-
}, 360_000);
220-
221114
it("should test upsert catalog object", async () => {
222115
const coffee = createTestCatalogItem({
223116
name: "Coffee",

0 commit comments

Comments
 (0)