Skip to content

Commit

Permalink
pkp/pkp-lib#7366 API tests updated
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir committed Aug 24, 2022
1 parent e526de2 commit 61e7801
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions cypress/tests/integration/API.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,35 @@ describe('API tests', function() {
cy.get('.app__userNav button').click();
cy.get('a:contains("Edit Profile")').click();
cy.get('a[name="apiSettings"]').click();
cy.get('input[id="apiKeyEnabled"]').check();
cy.get('input[id="generateApiKey"]').check();
cy.get('form[id="apiProfileForm"] button:contains("Save")').click();
cy.get('form[id="apiProfileForm"] button:contains("Create API Key")').click();
cy.waitJQuery();
cy.get('span:contains("Your changes have been saved.")');
cy.get('input[id^="apiKey-"]').invoke('val').as('apiKey').then(function() {
cy.log(this.apiKey);
});
cy.logout();
});

it("Lists submissions using an author's API key", function() {
cy.request('index.php/publicknowledge/api/v1/submissions?apiToken=' + this.apiKey).then(response => {
// The author only has a single submission; submissions from other users should not be included.
expect(response.body.items.length).eq(1);
});
});

it("Delete an author's API key", function() {
cy.login('ccorino', null, 'publicknowledge');
cy.get('.app__userNav button').click();
cy.get('a:contains("Edit Profile")').click();
cy.get('a[name="apiSettings"]').click();
cy.get('form[id="apiProfileForm"] button:contains("Delete")').click();
cy.waitJQuery();
cy.on('window:confirm', (text) => {
return true;
});
cy.waitJQuery();
cy.get('span:contains("Your changes have been saved.")');
cy.get('input[id^="apiKey-"]').invoke('val').should('eq', 'None');
cy.logout();
});
})

0 comments on commit 61e7801

Please sign in to comment.