Skip to content

Commit

Permalink
[ai-translation-document] Update test and recording (Azure#33280)
Browse files Browse the repository at this point in the history
### Packages impacted by this PR
@azure-rest/ai-translation-document

### Issues associated with this PR
Azure#31948 

### Describe the problem that is addressed by this PR
Add await for test case and update recording

### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?


### Are there test cases added in this PR? _(If not, why?)_


### Provide a list of related PRs _(if any)_


### Command used to generate this PR:**_(Applicable only to SDK release
request PRs)_

### Checklists
- [ ] Added impacted package name to the issue description
- [ ] Does this PR needs any fixes in the SDK Generator?** _(If so,
create an Issue in the
[Autorest/typescript](https://github.com/Azure/autorest.typescript)
repository and link it here)_
- [ ] Added a changelog (if necessary)
  • Loading branch information
Han-msft authored Mar 6, 2025
1 parent 9368b37 commit ad0893a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 37 deletions.
2 changes: 1 addition & 1 deletion sdk/translation/ai-translation-document-rest/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "js",
"TagPrefix": "js/translation/ai-translation-document-rest",
"Tag": "js/translation/ai-translation-document-rest_0d8f04de0a"
"Tag": "js/translation/ai-translation-document-rest_270025ae7e"
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ describe("GetSupportedFormats tests", () => {
});

it("all formats", async () => {
const response = await client.path("/document/formats").get();
const options = {
queryParameters: {
type: "",
},
};

const response = await client.path("/document/formats").get(options);
if (isUnexpected(response)) {
throw response.body;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const testPollingOptions = {
};

// TODO: Re-record test
describe("DocumentTranslation tests", { skip: true }, () => {
describe("DocumentTranslation tests", () => {
const retryCount = 10;
let recorder: Recorder;
let client: DocumentTranslationClient;
Expand All @@ -58,15 +58,21 @@ describe("DocumentTranslation tests", { skip: true }, () => {
await recorder.stop();
});

it.skip("Client Cannot Authenticate With FakeApiKey", async () => {
it("Client Cannot Authenticate With FakeApiKey", async () => {
const testEndpoint = "https://t7d8641d8f25ec940-doctranslation.cognitiveservices.azure.com";
const testApiKey = "fakeApiKey";
const testClient = await createDocumentTranslationClientWithEndpointAndCredentials({
endpointParam: testEndpoint,
credentials: { key: testApiKey },
});

const response = await testClient.path("/document/formats").get();
const options = {
queryParameters: {
type: "",
},
};

const response = await testClient.path("/document/formats").get(options);
if (isUnexpected(response)) {
assert.equal(response.status, "401");
}
Expand All @@ -84,11 +90,10 @@ describe("DocumentTranslation tests", { skip: true }, () => {
const response = await StartTranslationAndWait(batchRequests);

// Validate the response
validateTranslationStatus(response as StartTranslationDefaultResponse, 1);
await validateTranslationStatus(response as StartTranslationDefaultResponse, 1);
});

// TODO: Re-record test
it.skip("Single Source Multiple Targets", async () => {
it("Single Source Multiple Targets", async () => {
const sourceUrl = await createSourceContainer(recorder, ONE_TEST_DOCUMENTS);
const sourceInput = createSourceInput(sourceUrl);

Expand All @@ -115,11 +120,10 @@ describe("DocumentTranslation tests", { skip: true }, () => {
const response = await StartTranslationAndWait(batchRequests);

// Validate the response
validateTranslationStatus(response as StartTranslationDefaultResponse, 3);
await validateTranslationStatus(response as StartTranslationDefaultResponse, 3);
});

// TODO: Re-record test
it.skip("Multiple Sources Single Target", async () => {
it("Multiple Sources Single Target", async () => {
const srcContainerName1 = recorder.variable("sourceContainer1", `source-${getUniqueName()}`);
const sourceUrl1 = await createSourceContainer(recorder, ONE_TEST_DOCUMENTS, srcContainerName1);
const sourceInput1 = createSourceInput(sourceUrl1);
Expand All @@ -144,11 +148,10 @@ describe("DocumentTranslation tests", { skip: true }, () => {
const response = await StartTranslationAndWait(batchRequests);

// Validate the response
validateTranslationStatus(response, 2);
await validateTranslationStatus(response, 2);
});

// TODO: Re-record test
it.skip("Single Source Single Target With Prefix", async () => {
it("Single Source Single Target With Prefix", async () => {
const documentFilter = {
prefix: "File",
};
Expand All @@ -164,11 +167,10 @@ describe("DocumentTranslation tests", { skip: true }, () => {
const response = await StartTranslationAndWait(batchRequests);

// Validate the response
validateTranslationStatus(response as StartTranslationDefaultResponse, 1);
await validateTranslationStatus(response as StartTranslationDefaultResponse, 1);
});

// TODO: Re-record test
it.skip("Single Source Single Target With Suffix", async () => {
it("Single Source Single Target With Suffix", async () => {
const documentFilter = {
suffix: "txt",
};
Expand All @@ -186,11 +188,10 @@ describe("DocumentTranslation tests", { skip: true }, () => {
const response = await StartTranslationAndWait(batchRequests);

// Validate the response
validateTranslationStatus(response as StartTranslationDefaultResponse, 1);
await validateTranslationStatus(response as StartTranslationDefaultResponse, 1);
});

// TODO: Re-record test
it.skip("Single Source Single Target List Documents", async () => {
it("Single Source Single Target List Documents", async () => {
const sourceInput = createSourceInput(
await createSourceContainer(recorder, ONE_TEST_DOCUMENTS),
);
Expand Down Expand Up @@ -247,8 +248,7 @@ describe("DocumentTranslation tests", { skip: true }, () => {
}
});

// TODO: Re-record test
it.skip("Get Document Status", async () => {
it("Get Document Status", async () => {
const sourceInput = createSourceInput(
await createSourceContainer(recorder, ONE_TEST_DOCUMENTS),
);
Expand Down Expand Up @@ -283,8 +283,7 @@ describe("DocumentTranslation tests", { skip: true }, () => {
}
});

// TODO: Re-record test
it.skip("Wrong Source Right Target", async () => {
it("Wrong Source Right Target", async () => {
const sourceInput = createSourceInput("https://idont.ex.ist");
const targetInput = createTargetInput(await createTargetContainer(recorder), "es");
const batchRequest = createBatchRequest(sourceInput, [targetInput]);
Expand Down Expand Up @@ -323,8 +322,7 @@ describe("DocumentTranslation tests", { skip: true }, () => {
);
});

// TODO: Re-record test
it.skip("Right Source Wrong Target", async () => {
it("Right Source Wrong Target", async () => {
const sourceUrl = await createSourceContainer(recorder, ONE_TEST_DOCUMENTS);
const sourceInput = createSourceInput(sourceUrl);
const targetInput = createTargetInput("https://idont.ex.ist", "es");
Expand Down Expand Up @@ -365,8 +363,7 @@ describe("DocumentTranslation tests", { skip: true }, () => {
);
});

// TODO: Re-record test
it.skip("Supported And UnSupported Files", async () => {
it("Supported And UnSupported Files", async () => {
const documents = [
createTestDocument("Document1.txt", "First english test file"),
createTestDocument("File2.jpg", "jpg"),
Expand All @@ -385,11 +382,10 @@ describe("DocumentTranslation tests", { skip: true }, () => {
}

// Validate the response
validateTranslationStatus(response as StartTranslationDefaultResponse, 1);
await validateTranslationStatus(response as StartTranslationDefaultResponse, 1);
});

// TODO: Re-record test
it.skip("Empty Document Error", async () => {
it("Empty Document Error", async () => {
const documents = [createTestDocument("Document1.txt", "")];
const sourceUrl = await createSourceContainer(recorder, documents);
const sourceInput = createSourceInput(sourceUrl);
Expand Down Expand Up @@ -420,8 +416,7 @@ describe("DocumentTranslation tests", { skip: true }, () => {
assert.equal(translationStatusOutput.error?.innerError?.code, "NoTranslatableText");
});

// TODO: Re-record test
it.skip("Existing File In Target Container", async () => {
it("Existing File In Target Container", async () => {
const sourceUrl = await createSourceContainer(recorder, ONE_TEST_DOCUMENTS);
const sourceInput = createSourceInput(sourceUrl);
const targetUrl = await createTargetContainer(recorder, undefined, ONE_TEST_DOCUMENTS);
Expand Down Expand Up @@ -462,8 +457,7 @@ describe("DocumentTranslation tests", { skip: true }, () => {
);
});

// TODO: Re-record test
it.skip("Invalid Document GUID", async () => {
it("Invalid Document GUID", async () => {
const sourceUrl = await createSourceContainer(recorder, ONE_TEST_DOCUMENTS);
const sourceInput = createSourceInput(sourceUrl);
const targetUrl = await createTargetContainer(recorder);
Expand Down Expand Up @@ -491,8 +485,7 @@ describe("DocumentTranslation tests", { skip: true }, () => {
assert.equal(documentResponse.status, "404");
});

// TODO: Re-record test
it.skip("Document Translation With Glossary", async () => {
it("Document Translation With Glossary", async () => {
const sourceUrl = await createSourceContainer(recorder, ONE_TEST_DOCUMENTS);
const sourceInput = createSourceInput(sourceUrl);

Expand Down

0 comments on commit ad0893a

Please sign in to comment.