Skip to content

Commit

Permalink
Merge pull request #277 from shopware/7.0.1
Browse files Browse the repository at this point in the history
7.0.1
  • Loading branch information
jleifeld authored Jan 11, 2023
2 parents 3f5b1d6 + 14ae788 commit 5b0386b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 35 deletions.
39 changes: 24 additions & 15 deletions cypress/support/commands/api-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,20 @@ Cypress.Commands.add('authenticate', () => {
},
}).then(() => true);
});
}
},
}
);

return cy.getBearerAuth();
});

/**
* Get current Bearer token
* @memberOf Cypress.Chainable#
* @name getBearerAuth
* @function
*/
Cypress.Commands.add('getBearerAuth', () => {
return cy.getCookie('bearerAuth').then((cookie) => {
return JSON.parse(decodeURIComponent(cookie && cookie.value));
});
Expand All @@ -68,8 +78,8 @@ Cypress.Commands.add('authenticate', () => {
* @param {Object} data - Necessary data for the API request
*/
Cypress.Commands.add('searchViaAdminApi', (data) => {
return cy.authenticate().then((authInformation) => {
const fixture = new Fixture(authInformation);
return cy.getBearerAuth().then((authData) => {
const fixture = new Fixture(authData);

return fixture.search(data.endpoint, {
field: data.data.field,
Expand All @@ -89,7 +99,7 @@ Cypress.Commands.add('searchViaAdminApi', (data) => {
* @function
*/
Cypress.Commands.add('requestAdminApi', (method, url, requestData = {}) => {
return cy.authenticate().then((result) => {
return cy.getBearerAuth().then((result) => {
const requestConfig = {
headers: {
Accept: 'application/vnd.api+json',
Expand Down Expand Up @@ -133,17 +143,16 @@ Cypress.Commands.add('requestAdminApi', (method, url, requestData = {}) => {
* @function
*/
Cypress.Commands.add('clearCacheAdminApi', (method, url) => {
return cy.authenticate().then((result) => {
return cy.getCookie('bearerAuth').then((cookie) => {
const requestConfig = {
headers: {
Authorization: `Bearer ${JSON.parse(cookie.value).access}`
},
method: method,
url: url
};
return cy.request(requestConfig);
})
return cy.getBearerAuth().then((bearerToken) => {
const requestConfig = {
headers: {
Authorization: `Bearer ${bearerToken.access}`
},
method: method,
url: url
};

return cy.request(requestConfig);
});
});

Expand Down
34 changes: 17 additions & 17 deletions cypress/support/commands/fixture-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Fixture = require('../service/administration/fixture.service');
* @param {String} jsonPath - Path to JSON if it's deviating from endpoint
*/
Cypress.Commands.add('createDefaultFixture', (endpoint, data = {}, jsonPath) => {
return cy.authenticate().then((authInformation) => {
return cy.getBearerAuth().then((authInformation) => {
const fixture = new Fixture(authInformation);
let finalRawData = {};

Expand All @@ -45,7 +45,7 @@ Cypress.Commands.add('createDefaultFixture', (endpoint, data = {}, jsonPath) =>
* @param {Object} [userData={}] - Options concerning creation
*/
Cypress.Commands.add('createProductFixture', (userData = {}) => {
return cy.authenticate().then((authInformation) => {
return cy.getBearerAuth().then((authInformation) => {
const fixture = new ProductFixture(authInformation);

return cy.fixture('product').then((result) => {
Expand All @@ -64,7 +64,7 @@ Cypress.Commands.add('createProductFixture', (userData = {}) => {
* @param {object} [userData={}] - Additional category data
*/
Cypress.Commands.add('createCategoryFixture', (userData = {}) => {
return cy.authenticate().then((authInformation) => {
return cy.getBearerAuth().then((authInformation) => {
const fixture = new CategoryFixture(authInformation);

return cy.fixture('category').then((result) => {
Expand All @@ -83,7 +83,7 @@ Cypress.Commands.add('createCategoryFixture', (userData = {}) => {
* @param {Object} [userData={}] - Options concerning creation
*/
Cypress.Commands.add('createSalesChannelFixture', (userData = {}) => {
return cy.authenticate().then((authInformation) => {
return cy.getBearerAuth().then((authInformation) => {
const fixture = new AdminSalesChannelFixture(authInformation);

return cy.fixture('sales-channel').then((result) => {
Expand All @@ -102,7 +102,7 @@ Cypress.Commands.add('createSalesChannelFixture', (userData = {}) => {
* @param {String} [salesChannelName=Storefront] - Name of the sales channel to work on
*/
Cypress.Commands.add('setSalesChannelDomain', (salesChannelName = 'Storefront') => {
return cy.authenticate().then((authInformation) => {
return cy.getBearerAuth().then((authInformation) => {
const fixture = new AdminSalesChannelFixture(authInformation);
return fixture.setSalesChannelDomain(salesChannelName)
});
Expand All @@ -116,7 +116,7 @@ Cypress.Commands.add('setSalesChannelDomain', (salesChannelName = 'Storefront')
* @param {Object} [userData={}] - Options concerning creation
*/
Cypress.Commands.add('createCustomerFixture', (userData = {}) => {
return cy.authenticate().then((authInformation) => {
return cy.getBearerAuth().then((authInformation) => {
const fixture = new CustomerFixture(authInformation);
let customerJson = null;

Expand All @@ -137,7 +137,7 @@ Cypress.Commands.add('createCustomerFixture', (userData = {}) => {
* @param {Object} [userData={}] - Options concerning creation
*/
Cypress.Commands.add('createCmsFixture', (userData = {}) => {
return cy.authenticate().then((authInformation) => {
return cy.getBearerAuth().then((authInformation) => {
const fixture = new CmsFixture(authInformation);
let pageJson = null;

Expand Down Expand Up @@ -165,7 +165,7 @@ Cypress.Commands.add('createCmsFixture', (userData = {}) => {
* @param {Object} [userData={}] - Options concerning creation
*/
Cypress.Commands.add('createPropertyFixture', (options = {}, userData = {}) => {
return cy.authenticate().then((authInformation) => {
return cy.getBearerAuth().then((authInformation) => {
let json = {};
const fixture = new Fixture(authInformation);

Expand All @@ -186,7 +186,7 @@ Cypress.Commands.add('createPropertyFixture', (options = {}, userData = {}) => {
* @function
*/
Cypress.Commands.add('createLanguageFixture', () => {
return cy.authenticate().then((authInformation) => {
return cy.getBearerAuth().then((authInformation) => {
let json = {};
const fixture = new Fixture(authInformation);

Expand Down Expand Up @@ -218,7 +218,7 @@ Cypress.Commands.add('createLanguageFixture', () => {
* @param {Object} [userData={}] - Options concerning creation
*/
Cypress.Commands.add('createShippingFixture', (userData = {}) => {
return cy.authenticate().then((authInformation) => {
return cy.getBearerAuth().then((authInformation) => {
const fixture = new ShippingFixture(authInformation);

return cy.fixture('shipping-method').then((result) => {
Expand All @@ -237,7 +237,7 @@ Cypress.Commands.add('createShippingFixture', (userData = {}) => {
* @param {Object} [userData={}] - Options concerning creation
*/
Cypress.Commands.add('createPaymentMethodFixture', (userData = {}) => {
return cy.authenticate().then((authInformation) => {
return cy.getBearerAuth().then((authInformation) => {
const fixture = new PaymentMethodFixture(authInformation);

return cy.fixture('payment-method').then((result) => {
Expand All @@ -256,7 +256,7 @@ Cypress.Commands.add('createPaymentMethodFixture', (userData = {}) => {
* @param {Object} [recipient={}] - Options concerning creation
*/
Cypress.Commands.add('createNewsletterRecipientFixture', (recipient = {}) => {
return cy.authenticate().then((authInformation) => {
return cy.getBearerAuth().then((authInformation) => {
const fixture = new NewsletterRecipientFixture(authInformation);

return cy.fixture('customer').then((result) => {
Expand All @@ -274,7 +274,7 @@ Cypress.Commands.add('createNewsletterRecipientFixture', (recipient = {}) => {
* @function
*/
Cypress.Commands.add('createSnippetFixture', () => {
return cy.authenticate().then((authInformation) => {
return cy.getBearerAuth().then((authInformation) => {
let json = {};
const fixture = new Fixture(authInformation);

Expand Down Expand Up @@ -317,7 +317,7 @@ Cypress.Commands.add('createSnippetFixture', () => {
* @param {Object} [customer={}] - Options concerning customer
*/
Cypress.Commands.add('createOrder', (productId, customer = {}) => {
return cy.authenticate().then((authInformation) => {
return cy.getBearerAuth().then((authInformation) => {
const fixture = new OrderFixture(authInformation);

return fixture.createOrder(productId, customer);
Expand All @@ -333,7 +333,7 @@ Cypress.Commands.add('createOrder', (productId, customer = {}) => {
* @param {Object} [userData={}] - Options concerning creation
*/
Cypress.Commands.add('createGuestOrder', (productId, userData = {}) => {
return cy.authenticate().then((authInformation) => {
return cy.getBearerAuth().then((authInformation) => {
const fixture = new OrderFixture(authInformation);

return cy.fixture('storefront-customer').then((result) => {
Expand All @@ -352,7 +352,7 @@ Cypress.Commands.add('createGuestOrder', (productId, userData = {}) => {
* @param {Object} [userData={}] - Data proved for this order to be created
*/
Cypress.Commands.add('createAdminOrder', (userData = {}) => {
return cy.authenticate().then((authInformation) => {
return cy.getBearerAuth().then((authInformation) => {
const fixture = new OrderAdminFixture(authInformation);

return cy.fixture('order').then((result) => {
Expand All @@ -371,7 +371,7 @@ Cypress.Commands.add('createAdminOrder', (userData = {}) => {
* @param {Object} [userData={}] - Options concerning creation
*/
Cypress.Commands.add('createPromotionFixture', (userData = {}) => {
return cy.authenticate().then((authInformation) => {
return cy.getBearerAuth().then((authInformation) => {
const fixture = new OrderFixture(authInformation);
let promotionId = '';

Expand Down
4 changes: 2 additions & 2 deletions cypress/support/commands/storefront-api-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Cypress.Commands.add('createViaAdminApi', (data) => {
* @function
*/
Cypress.Commands.add('getSalesChannelId', () => {
return cy.authenticate().then((result) => {
return cy.getBearerAuth().then((result) => {
const parameters = {
data: {
headers: {
Expand Down Expand Up @@ -359,7 +359,7 @@ Cypress.Commands.add('setAnalyticsFixtureToSalesChannel', (state) => {
* @param {String} [shippingMethodName="Standard"] - NAme of the shipping method
*/
Cypress.Commands.add('createRuleFixtureStorefront', (userData = {}, shippingMethodName = 'Standard') => {
return cy.authenticate().then((authInformation) => {
return cy.getBearerAuth().then((authInformation) => {
const fixture = new RuleBuilderFixture(authInformation);

return cy.fixture('rule-builder-shipping-payment.json').then((result) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shopware-ag/e2e-testsuite-platform",
"version": "7.0.0",
"version": "7.0.1",
"description": "E2E Testsuite for Shopware 6 using Cypress.js",
"keywords": [
"e2e",
Expand Down

0 comments on commit 5b0386b

Please sign in to comment.