Skip to content

Commit

Permalink
Restore publish API for backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
remdash authored Jun 6, 2024
1 parent e383b22 commit dc327d9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class APIClient {
return response;
}

async publish({ target = 'default', deployPercentage, token = this.fetchToken() } = {}) {
async publish(target = 'default', token = this.fetchToken(), deployPercentage) {
const { extensionId } = this;

const request = await fetch(publishURI({ extensionId, target, deployPercentage }), {
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ store.uploadExisting(myZipFile, token).then(res => {
const target = 'default'; // optional. Can also be 'trustedTesters'
const token = 'xxxx'; // optional. One will be fetched if not provided
const deployPercentage = 25; // optional. Will default to 100%.
store.publish({ target, deployPercentage, token }).then((res) => {
store.publish(target, token, deployPercentage).then(res => {
// Response is documented here:
// https://developer.chrome.com/webstore/webstore_api/items/publish
});
Expand Down
12 changes: 6 additions & 6 deletions test/publish.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ beforeEach(context => {
test('Publish uses default target when not provided', async ({ client }) => {
fetchMock.postOnce('https://www.googleapis.com/chromewebstore/v1.1/items/foo/publish?publishTarget=default', {});

await client.publish({ token: 'token' });
await client.publish(undefined, 'token');
});

test('Publish uses target when provided', async ({ client }) => {
const target = 'trustedTesters';

fetchMock.postOnce(`https://www.googleapis.com/chromewebstore/v1.1/items/foo/publish?publishTarget=${target}`, {});

await client.publish({ target, token: 'token' });
await client.publish(target, 'token');
});

test('Publish uses deployPercentage when provided', async ({ client }) => {
const deployPercentage = 100;

fetchMock.postOnce(`https://www.googleapis.com/chromewebstore/v1.1/items/foo/publish?publishTarget=default&deployPercentage=${deployPercentage}`, {});

await client.publish({ target: 'default', deployPercentage, token: 'token' });
await client.publish('default', 'token', deployPercentage);
});

test('Publish does not fetch token when provided', async ({ client }) => {
fetchMock.postOnce('https://www.googleapis.com/chromewebstore/v1.1/items/foo/publish?publishTarget=default', {});

await client.publish({ token: 'token' });
await client.publish(undefined, 'token');
});

test('Publish uses token for auth', async ({ client }) => {
Expand All @@ -45,7 +45,7 @@ test('Publish uses token for auth', async ({ client }) => {
},
}, {});

await client.publish({ token });
await client.publish(undefined, token);
});

test('Uses provided extension ID', async ({ client }) => {
Expand All @@ -61,7 +61,7 @@ test('Uses provided extension ID', async ({ client }) => {

fetchMock.postOnce(`https://www.googleapis.com/chromewebstore/v1.1/items/${extensionId}/publish?publishTarget=default`, {});

await client.publish({ token: 'token' });
await client.publish(undefined, 'token');
});

test.todo('Publish only returns response body on success');

0 comments on commit dc327d9

Please sign in to comment.