saleor-dashboard/cypress/plugins/index.js
Karolina Rakoczy f85786f203
Run critical tests after test env deployment (#1902)
* run critical tests after test env deployment

* add cache

* add all branches

* change workflow name

* add run on pull request for testing

* change type

* add run on deployment

* run on copleted

* test critical

* add quote

* change baseUrl

* fix base url

* fix base url

* upload reports

* run in parallel

* save build folder

* remove build from gitignore

* remove build

* update nide version

* last try with parallel

* save build

* save build

* Run critical

* change cypress API url

* run critical in parallel

* check which workflow has lower duration time

* save all reports with container in name

* add reports on failure

* remove reporters

* fix jobs

* merge

* add group name

* run critical

* Refactor critical tests (#1906)

* refactored tag added to purchaseWithProductsTypes, navigation, stocksInCheckout

* homePageAnalitics - refactor

* refactor home page

* refactor creating variants

* refactor adding product without sku to order

* add script to run critical locally

* change tests cases names

* fix names, remove comments, add script to run refactored tests

* remove workflow for parallel

* remove key
2022-03-21 13:17:37 +01:00

69 lines
2.1 KiB
JavaScript

// / <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
/**
* @type {Cypress.PluginConfig}
*/
/* eslint-disable @typescript-eslint/no-var-requires */
const graphql = require("graphql-request");
module.exports = async (on, config) => {
// make env variables visible for cypress
// require("cypress-mochawesome-reporter/plugin")(on); - uncomment to run reports
config.env.API_URI = process.env.API_URI;
config.env.APP_MOUNT_URI = process.env.APP_MOUNT_URI;
config.env.mailHogUrl = process.env.CYPRESS_MAILHOG;
config.env.SHOP = await getShopInfo(process.env);
config.env.STRIPE_SECRET_KEY = process.env.STRIPE_SECRET_KEY;
config.env.STRIPE_PUBLIC_KEY = process.env.STRIPE_PUBLIC_KEY;
on("before:browser:launch", (browser = {}, launchOptions) => {
launchOptions.args.push("--proxy-bypass-list=<-loopback>");
return launchOptions;
});
return config;
};
function getShopInfo(envVariables) {
// envVariables.CYPRESS_USER_NAME
const variables = {
email: envVariables.CYPRESS_USER_NAME,
password: envVariables.CYPRESS_USER_PASSWORD
};
const createTokenMutation = graphql.gql`mutation tokenCreate($email: String!, $password: String!){
tokenCreate(email:$email, password:$password){
token
}
}`;
const getShopInfoQuery = graphql.gql`query{
shop{
version
}
}`;
const client = new graphql.GraphQLClient(envVariables.API_URI, {
headers: {}
});
return client.request(createTokenMutation, variables).then(data => {
const token = data.tokenCreate.token;
client.setHeader("Authorization", `JWT ${token}`);
return client
.request(getShopInfoQuery)
.then(shopInfo => shopInfo.shop.version);
});
}