Skip to content
Merged
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
5 changes: 4 additions & 1 deletion src/commands/actors/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ export class ActorsPushCommand extends ApifyCommand<typeof ActorsPushCommand> {
DEFAULT_RUN_OPTIONS) as ActorDefaultRunOptions;
const newActor: ActorCollectionCreateOptions = {
name: actorConfig!.name as string,
title: actorConfig!.title as string | undefined,
description: actorConfig!.description as string | undefined,
defaultRunOptions,
versions: [
{
Expand All @@ -203,10 +205,11 @@ export class ActorsPushCommand extends ApifyCommand<typeof ActorsPushCommand> {
}
}

const actorClient = apifyClient.actor(actorId);

info({ message: `Deploying Actor '${actorConfig!.name}' to Apify.` });

const filesSize = await sumFilesSizeInBytes(filePathsToPush, cwd);
const actorClient = apifyClient.actor(actorId);

let sourceType;
let sourceFiles;
Expand Down
58 changes: 58 additions & 0 deletions test/api/commands/push.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,70 @@ describe('[api] apify push', () => {
await testActorClient.version(actorJson.version).update({ buildTag: 'beta' });

await testRunCommand(ActorsPushCommand, { args_actorId: testActor.id, flags_noPrompt: true });
if (testActor) await testActorClient.delete();

expect(lastErrorMessage()).to.includes('is already on the platform');
},
TEST_TIMEOUT,
);

it(
'should set title and description when creating a new actor',
async () => {
const actorJson = JSON.parse(readFileSync(joinPath(LOCAL_CONFIG_PATH), 'utf8'));

actorJson.name = `${actorJson.name}-title-test`;
actorJson.title = 'My Custom Actor Title';
actorJson.description = 'This is a custom description for the actor.';

writeFileSync(joinPath(LOCAL_CONFIG_PATH), JSON.stringify(actorJson, null, '\t'), { flag: 'w' });
await testRunCommand(ActorsPushCommand, { flags_noPrompt: true, flags_force: true });

const userInfo = await getLocalUserInfo();
const actorId = `${userInfo.username}/${actorJson.name}`;
actorsForCleanup.add(actorId);
const createdActorClient = testUserClient.actor(actorId);
const createdActor = await createdActorClient.get();

expect(createdActor?.title).to.be.eql('My Custom Actor Title');
expect(createdActor?.description).to.be.eql('This is a custom description for the actor.');

if (createdActor) await createdActorClient.delete();
},
TEST_TIMEOUT,
);

it(
'should not rewrite current Actor title and description',
async () => {
const testActorWithTitleDesc = {
...TEST_ACTOR,
title: 'Original Title',
description: 'Original description.',
};
let testActor = await testUserClient.actors().create(testActorWithTitleDesc);
actorsForCleanup.add(testActor.id);
const testActorClient = testUserClient.actor(testActor.id);

// Remove title and description from local actor.json
const actorJson = JSON.parse(readFileSync(joinPath(LOCAL_CONFIG_PATH), 'utf8'));
delete actorJson.title;
delete actorJson.description;
writeFileSync(joinPath(LOCAL_CONFIG_PATH), JSON.stringify(actorJson, null, '\t'), { flag: 'w' });

await testRunCommand(ActorsPushCommand, { args_actorId: testActor.id, flags_noPrompt: true });

testActor = (await testActorClient.get())!;

if (testActor) await testActorClient.delete();

// Title and description should be preserved from the original actor
expect(testActor.title).to.be.eql('Original Title');
expect(testActor.description).to.be.eql('Original description.');
},
TEST_TIMEOUT,
);

it(
'should not push Actor when there are no files to push',
async () => {
Expand Down