From c12cb6ccdfdde977e1697521c8dd6d97609dc2cb Mon Sep 17 00:00:00 2001 From: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com> Date: Mon, 29 Jul 2024 11:51:36 +0100 Subject: [PATCH] [tests] Move API core tests as a suite in e2e-pw (#50024) --- .github/workflows/ci.yml | 2 +- .../changelog/tests-move-api-tests-into-e2e | 4 + plugins/woocommerce/package.json | 26 +- .../tests/api-core-tests/.eslintrc.js | 13 - .../tests/api-core-tests/README.md | 498 ------------------ .../api-core-tests/ci-release.global-setup.js | 122 ----- .../ci-release.playwright.config.js | 26 - .../tests/api-core-tests/data/customer.js | 46 -- .../tests/api-core-tests/data/tax-rate.js | 421 --------------- .../tests/api-core-tests/global-setup.js | 251 --------- .../tests/api-core-tests/playwright.config.js | 71 --- .../tests/reports/reports-crud.test.js | 407 -------------- .../tests/api-core-tests/utils/api.js | 431 --------------- .../tests/api-core-tests/utils/index.js | 6 - .../api-core-tests/utils/plugin-utils.js | 366 ------------- .../tests/api-core-tests/utils/site.js | 304 ----------- .../data/countries/ad.json | 0 .../data/countries/ae.json | 0 .../data/countries/af.json | 0 .../data/countries/ag.json | 0 .../data/countries/ai.json | 0 .../data/countries/al.json | 0 .../data/countries/am.json | 0 .../data/countries/ao.json | 0 .../data/countries/aq.json | 0 .../data/countries/ar.json | 0 .../data/countries/as.json | 0 .../data/countries/at.json | 0 .../data/countries/au.json | 0 .../data/countries/aw.json | 0 .../data/countries/ax.json | 0 .../data/countries/az.json | 0 .../data/countries/ba.json | 0 .../data/countries/bb.json | 0 .../data/countries/bd.json | 0 .../data/countries/be.json | 0 .../data/countries/bf.json | 0 .../data/countries/bg.json | 0 .../data/countries/bh.json | 0 .../data/countries/bi.json | 0 .../data/countries/bj.json | 0 .../data/countries/bl.json | 0 .../data/countries/bm.json | 0 .../data/countries/bn.json | 0 .../data/countries/bo.json | 0 .../data/countries/bq.json | 0 .../data/countries/br.json | 0 .../data/countries/bs.json | 0 .../data/countries/bt.json | 0 .../data/countries/bv.json | 0 .../data/countries/bw.json | 0 .../data/countries/by.json | 0 .../data/countries/bz.json | 0 .../data/countries/ca.json | 0 .../data/countries/cc.json | 0 .../data/countries/cd.json | 0 .../data/countries/cf.json | 0 .../data/countries/cg.json | 0 .../data/countries/ch.json | 0 .../data/countries/ci.json | 0 .../data/countries/ck.json | 0 .../data/countries/cl.json | 0 .../data/countries/cm.json | 0 .../data/countries/cn.json | 0 .../data/countries/co.json | 0 .../data/countries/cr.json | 0 .../data/countries/cu.json | 0 .../data/countries/cv.json | 0 .../data/countries/cw.json | 0 .../data/countries/cx.json | 0 .../data/countries/cy.json | 0 .../data/countries/cz.json | 0 .../data/countries/de.json | 0 .../data/countries/dj.json | 0 .../data/countries/dk.json | 0 .../data/countries/dm.json | 0 .../data/countries/do.json | 0 .../data/countries/dz.json | 0 .../data/countries/ec.json | 0 .../data/countries/ee.json | 0 .../data/countries/eg.json | 0 .../data/countries/eh.json | 0 .../data/countries/er.json | 0 .../data/countries/es.json | 0 .../data/countries/et.json | 0 .../data/countries/fi.json | 0 .../data/countries/fj.json | 0 .../data/countries/fk.json | 0 .../data/countries/fm.json | 0 .../data/countries/fo.json | 0 .../data/countries/fr.json | 0 .../data/countries/ga.json | 0 .../data/countries/gb.json | 0 .../data/countries/gd.json | 0 .../data/countries/ge.json | 0 .../data/countries/gf.json | 0 .../data/countries/gg.json | 0 .../data/countries/gh.json | 0 .../data/countries/gi.json | 0 .../data/countries/gl.json | 0 .../data/countries/gm.json | 0 .../data/countries/gn.json | 0 .../data/countries/gp.json | 0 .../data/countries/gq.json | 0 .../data/countries/gr.json | 0 .../data/countries/gs.json | 0 .../data/countries/gt.json | 0 .../data/countries/gu.json | 0 .../data/countries/gw.json | 0 .../data/countries/gy.json | 0 .../data/countries/hk.json | 0 .../data/countries/hm.json | 0 .../data/countries/hn.json | 0 .../data/countries/hr.json | 0 .../data/countries/ht.json | 0 .../data/countries/hu.json | 0 .../data/countries/id.json | 0 .../data/countries/ie.json | 0 .../data/countries/il.json | 0 .../data/countries/im.json | 0 .../data/countries/in.json | 0 .../data/countries/io.json | 0 .../data/countries/iq.json | 0 .../data/countries/ir.json | 0 .../data/countries/is.json | 0 .../data/countries/it.json | 0 .../data/countries/je.json | 0 .../data/countries/jm.json | 0 .../data/countries/jo.json | 0 .../data/countries/jp.json | 0 .../data/countries/ke.json | 0 .../data/countries/kg.json | 0 .../data/countries/kh.json | 0 .../data/countries/ki.json | 0 .../data/countries/km.json | 0 .../data/countries/kn.json | 0 .../data/countries/kp.json | 0 .../data/countries/kr.json | 0 .../data/countries/kw.json | 0 .../data/countries/ky.json | 0 .../data/countries/kz.json | 0 .../data/countries/la.json | 0 .../data/countries/lb.json | 0 .../data/countries/lc.json | 0 .../data/countries/li.json | 0 .../data/countries/lk.json | 0 .../data/countries/lr.json | 0 .../data/countries/ls.json | 0 .../data/countries/lt.json | 0 .../data/countries/lu.json | 0 .../data/countries/lv.json | 0 .../data/countries/ly.json | 0 .../data/countries/ma.json | 0 .../data/countries/mc.json | 0 .../data/countries/md.json | 0 .../data/countries/me.json | 0 .../data/countries/mf.json | 0 .../data/countries/mg.json | 0 .../data/countries/mh.json | 0 .../data/countries/mk.json | 0 .../data/countries/ml.json | 0 .../data/countries/mm.json | 0 .../data/countries/mn.json | 0 .../data/countries/mo.json | 0 .../data/countries/mp.json | 0 .../data/countries/mq.json | 0 .../data/countries/mr.json | 0 .../data/countries/ms.json | 0 .../data/countries/mt.json | 0 .../data/countries/mu.json | 0 .../data/countries/mv.json | 0 .../data/countries/mw.json | 0 .../data/countries/mx.json | 0 .../data/countries/my.json | 0 .../data/countries/mz.json | 0 .../data/countries/na.json | 0 .../data/countries/nc.json | 0 .../data/countries/ne.json | 0 .../data/countries/nf.json | 0 .../data/countries/ng.json | 0 .../data/countries/ni.json | 0 .../data/countries/nl.json | 0 .../data/countries/no.json | 0 .../data/countries/np.json | 0 .../data/countries/nr.json | 0 .../data/countries/nu.json | 0 .../data/countries/nz.json | 0 .../data/countries/om.json | 0 .../data/countries/pa.json | 0 .../data/countries/pe.json | 0 .../data/countries/pf.json | 0 .../data/countries/pg.json | 0 .../data/countries/ph.json | 0 .../data/countries/pk.json | 0 .../data/countries/pl.json | 0 .../data/countries/pm.json | 0 .../data/countries/pn.json | 0 .../data/countries/pr.json | 0 .../data/countries/ps.json | 0 .../data/countries/pt.json | 0 .../data/countries/pw.json | 0 .../data/countries/py.json | 0 .../data/countries/qa.json | 0 .../data/countries/re.json | 0 .../data/countries/ro.json | 0 .../data/countries/rs.json | 0 .../data/countries/ru.json | 0 .../data/countries/rw.json | 0 .../data/countries/sa.json | 0 .../data/countries/sb.json | 0 .../data/countries/sc.json | 0 .../data/countries/sd.json | 0 .../data/countries/se.json | 0 .../data/countries/sg.json | 0 .../data/countries/sh.json | 0 .../data/countries/si.json | 0 .../data/countries/sj.json | 0 .../data/countries/sk.json | 0 .../data/countries/sl.json | 0 .../data/countries/sm.json | 0 .../data/countries/sn.json | 0 .../data/countries/so.json | 0 .../data/countries/sr.json | 0 .../data/countries/ss.json | 0 .../data/countries/st.json | 0 .../data/countries/sv.json | 0 .../data/countries/sx.json | 0 .../data/countries/sy.json | 0 .../data/countries/sz.json | 0 .../data/countries/tc.json | 0 .../data/countries/td.json | 0 .../data/countries/tf.json | 0 .../data/countries/tg.json | 0 .../data/countries/th.json | 0 .../data/countries/tj.json | 0 .../data/countries/tk.json | 0 .../data/countries/tl.json | 0 .../data/countries/tm.json | 0 .../data/countries/tn.json | 0 .../data/countries/to.json | 0 .../data/countries/tr.json | 0 .../data/countries/tt.json | 0 .../data/countries/tv.json | 0 .../data/countries/tw.json | 0 .../data/countries/tz.json | 0 .../data/countries/ua.json | 0 .../data/countries/ug.json | 0 .../data/countries/um.json | 0 .../data/countries/us.json | 0 .../data/countries/uy.json | 0 .../data/countries/uz.json | 0 .../data/countries/va.json | 0 .../data/countries/vc.json | 0 .../data/countries/ve.json | 0 .../data/countries/vg.json | 0 .../data/countries/vi.json | 0 .../data/countries/vn.json | 0 .../data/countries/vu.json | 0 .../data/countries/wf.json | 0 .../data/countries/ws.json | 0 .../data/countries/ye.json | 0 .../data/countries/yt.json | 0 .../data/countries/za.json | 0 .../data/countries/zm.json | 0 .../data/countries/zw.json | 0 .../{api-core-tests => e2e-pw}/data/coupon.js | 0 .../woocommerce/tests/e2e-pw/data/customer.js | 46 ++ .../{api-core-tests => e2e-pw}/data/index.js | 0 .../{api-core-tests => e2e-pw}/data/order.js | 0 .../data/products-crud.js | 0 .../{api-core-tests => e2e-pw}/data/refund.js | 0 .../data/settings.js | 0 .../data/shared/batch-update.js | 1 - .../data/shared/customer.js | 0 .../data/shared/error-response.js | 0 .../data/shared/index.js | 0 .../data/shipping-method.js | 0 .../data/shipping-zone.js | 0 .../woocommerce/tests/e2e-pw/data/tax-rate.js | 421 +++++++++++++++ .../data/variation.js | 0 .../e2e-pw/envs/default/playwright.config.js | 13 +- .../e2e-pw/fixtures/api-tests-fixtures.js | 13 + .../woocommerce/tests/e2e-pw/global-setup.js | 6 +- .../tests/e2e-pw/playwright.config.js | 14 +- .../tests/api-tests}/coupons/coupons.test.js | 10 +- .../customers/customers-crud.test.js | 30 +- .../tests/api-tests}/data/data-crud.test.js | 11 +- .../tests/api-tests}/hello/hello.test.js | 8 +- .../api-tests}/orders/order-complex.test.js | 12 +- .../api-tests}/orders/order-search.test.js | 33 +- .../api-tests}/orders/orders-crud.test.js | 14 +- .../tests/api-tests}/orders/orders.test.js | 12 +- .../payment-gateways-crud.test.js | 14 +- .../api-tests}/products/product-list.test.js | 12 +- .../api-tests}/products/products-crud.test.js | 24 +- .../tests/api-tests}/refunds/refunds.test.js | 11 +- .../api-tests/reports/reports-crud.test.js | 425 +++++++++++++++ .../api-tests}/settings/settings-crud.test.js | 23 +- .../shipping/shipping-method.test.js | 7 +- .../shipping/shipping-zones.test.js | 8 +- .../system-status/system-status-crud.test.js | 17 +- .../api-tests}/taxes/tax-classes-crud.test.js | 9 +- .../api-tests}/taxes/tax-rates-crud.test.js | 28 +- .../api-tests}/webhooks/webhooks-crud.test.js | 9 +- 304 files changed, 1033 insertions(+), 3192 deletions(-) create mode 100644 plugins/woocommerce/changelog/tests-move-api-tests-into-e2e delete mode 100644 plugins/woocommerce/tests/api-core-tests/.eslintrc.js delete mode 100644 plugins/woocommerce/tests/api-core-tests/README.md delete mode 100644 plugins/woocommerce/tests/api-core-tests/ci-release.global-setup.js delete mode 100644 plugins/woocommerce/tests/api-core-tests/ci-release.playwright.config.js delete mode 100644 plugins/woocommerce/tests/api-core-tests/data/customer.js delete mode 100644 plugins/woocommerce/tests/api-core-tests/data/tax-rate.js delete mode 100644 plugins/woocommerce/tests/api-core-tests/global-setup.js delete mode 100644 plugins/woocommerce/tests/api-core-tests/playwright.config.js delete mode 100644 plugins/woocommerce/tests/api-core-tests/tests/reports/reports-crud.test.js delete mode 100644 plugins/woocommerce/tests/api-core-tests/utils/api.js delete mode 100644 plugins/woocommerce/tests/api-core-tests/utils/index.js delete mode 100644 plugins/woocommerce/tests/api-core-tests/utils/plugin-utils.js delete mode 100644 plugins/woocommerce/tests/api-core-tests/utils/site.js rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ad.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ae.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/af.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ag.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ai.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/al.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/am.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ao.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/aq.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ar.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/as.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/at.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/au.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/aw.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ax.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/az.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ba.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/bb.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/bd.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/be.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/bf.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/bg.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/bh.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/bi.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/bj.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/bl.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/bm.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/bn.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/bo.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/bq.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/br.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/bs.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/bt.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/bv.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/bw.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/by.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/bz.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ca.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/cc.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/cd.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/cf.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/cg.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ch.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ci.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ck.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/cl.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/cm.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/cn.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/co.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/cr.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/cu.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/cv.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/cw.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/cx.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/cy.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/cz.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/de.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/dj.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/dk.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/dm.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/do.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/dz.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ec.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ee.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/eg.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/eh.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/er.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/es.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/et.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/fi.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/fj.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/fk.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/fm.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/fo.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/fr.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ga.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/gb.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/gd.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ge.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/gf.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/gg.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/gh.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/gi.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/gl.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/gm.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/gn.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/gp.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/gq.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/gr.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/gs.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/gt.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/gu.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/gw.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/gy.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/hk.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/hm.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/hn.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/hr.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ht.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/hu.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/id.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ie.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/il.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/im.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/in.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/io.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/iq.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ir.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/is.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/it.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/je.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/jm.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/jo.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/jp.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ke.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/kg.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/kh.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ki.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/km.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/kn.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/kp.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/kr.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/kw.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ky.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/kz.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/la.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/lb.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/lc.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/li.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/lk.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/lr.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ls.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/lt.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/lu.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/lv.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ly.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ma.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/mc.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/md.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/me.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/mf.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/mg.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/mh.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/mk.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ml.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/mm.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/mn.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/mo.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/mp.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/mq.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/mr.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ms.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/mt.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/mu.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/mv.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/mw.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/mx.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/my.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/mz.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/na.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/nc.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ne.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/nf.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ng.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ni.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/nl.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/no.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/np.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/nr.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/nu.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/nz.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/om.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/pa.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/pe.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/pf.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/pg.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ph.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/pk.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/pl.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/pm.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/pn.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/pr.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ps.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/pt.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/pw.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/py.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/qa.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/re.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ro.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/rs.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ru.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/rw.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/sa.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/sb.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/sc.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/sd.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/se.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/sg.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/sh.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/si.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/sj.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/sk.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/sl.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/sm.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/sn.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/so.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/sr.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ss.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/st.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/sv.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/sx.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/sy.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/sz.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/tc.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/td.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/tf.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/tg.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/th.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/tj.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/tk.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/tl.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/tm.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/tn.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/to.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/tr.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/tt.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/tv.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/tw.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/tz.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ua.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ug.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/um.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/us.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/uy.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/uz.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/va.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/vc.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ve.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/vg.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/vi.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/vn.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/vu.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/wf.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ws.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/ye.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/yt.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/za.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/zm.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/countries/zw.json (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/coupon.js (100%) create mode 100644 plugins/woocommerce/tests/e2e-pw/data/customer.js rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/index.js (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/order.js (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/products-crud.js (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/refund.js (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/settings.js (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/shared/batch-update.js (95%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/shared/customer.js (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/shared/error-response.js (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/shared/index.js (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/shipping-method.js (100%) rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/shipping-zone.js (100%) create mode 100644 plugins/woocommerce/tests/e2e-pw/data/tax-rate.js rename plugins/woocommerce/tests/{api-core-tests => e2e-pw}/data/variation.js (100%) create mode 100644 plugins/woocommerce/tests/e2e-pw/fixtures/api-tests-fixtures.js rename plugins/woocommerce/tests/{api-core-tests/tests => e2e-pw/tests/api-tests}/coupons/coupons.test.js (98%) rename plugins/woocommerce/tests/{api-core-tests/tests => e2e-pw/tests/api-tests}/customers/customers-crud.test.js (96%) rename plugins/woocommerce/tests/{api-core-tests/tests => e2e-pw/tests/api-tests}/data/data-crud.test.js (99%) rename plugins/woocommerce/tests/{api-core-tests/tests => e2e-pw/tests/api-tests}/hello/hello.test.js (75%) rename plugins/woocommerce/tests/{api-core-tests/tests => e2e-pw/tests/api-tests}/orders/order-complex.test.js (96%) rename plugins/woocommerce/tests/{api-core-tests/tests => e2e-pw/tests/api-tests}/orders/order-search.test.js (82%) rename plugins/woocommerce/tests/{api-core-tests/tests => e2e-pw/tests/api-tests}/orders/orders-crud.test.js (97%) rename plugins/woocommerce/tests/{api-core-tests/tests => e2e-pw/tests/api-tests}/orders/orders.test.js (99%) rename plugins/woocommerce/tests/{api-core-tests/tests => e2e-pw/tests/api-tests}/payment-gateways/payment-gateways-crud.test.js (96%) rename plugins/woocommerce/tests/{api-core-tests/tests => e2e-pw/tests/api-tests}/products/product-list.test.js (99%) rename plugins/woocommerce/tests/{api-core-tests/tests => e2e-pw/tests/api-tests}/products/products-crud.test.js (98%) rename plugins/woocommerce/tests/{api-core-tests/tests => e2e-pw/tests/api-tests}/refunds/refunds.test.js (96%) create mode 100644 plugins/woocommerce/tests/e2e-pw/tests/api-tests/reports/reports-crud.test.js rename plugins/woocommerce/tests/{api-core-tests/tests => e2e-pw/tests/api-tests}/settings/settings-crud.test.js (99%) rename plugins/woocommerce/tests/{api-core-tests/tests => e2e-pw/tests/api-tests}/shipping/shipping-method.test.js (98%) rename plugins/woocommerce/tests/{api-core-tests/tests => e2e-pw/tests/api-tests}/shipping/shipping-zones.test.js (97%) rename plugins/woocommerce/tests/{api-core-tests/tests => e2e-pw/tests/api-tests}/system-status/system-status-crud.test.js (98%) rename plugins/woocommerce/tests/{api-core-tests/tests => e2e-pw/tests/api-tests}/taxes/tax-classes-crud.test.js (96%) rename plugins/woocommerce/tests/{api-core-tests/tests => e2e-pw/tests/api-tests}/taxes/tax-rates-crud.test.js (93%) rename plugins/woocommerce/tests/{api-core-tests/tests => e2e-pw/tests/api-tests}/webhooks/webhooks-crud.test.js (97%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a2b6272167..cb37ac29600 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -119,7 +119,7 @@ jobs: with: install: '${{ matrix.projectName }}...' build: ${{ ( github.ref_type == 'tag' && 'false' ) || matrix.projectName }} - build-type: ${{ ( ( matrix.testType == 'unit:php' || matrix.testType == 'api' ) && 'backend' ) || 'full' }} + build-type: ${{ ( matrix.testType == 'unit:php' && 'backend' ) || 'full' }} pull-playwright-cache: ${{ matrix.testEnv.shouldCreate && matrix.testType == 'e2e' }} pull-package-deps: '${{ matrix.projectName }}' diff --git a/plugins/woocommerce/changelog/tests-move-api-tests-into-e2e b/plugins/woocommerce/changelog/tests-move-api-tests-into-e2e new file mode 100644 index 00000000000..c12f3a3d845 --- /dev/null +++ b/plugins/woocommerce/changelog/tests-move-api-tests-into-e2e @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Tests: moved api core tests as a suite in e2e-pw diff --git a/plugins/woocommerce/package.json b/plugins/woocommerce/package.json index 2250335584e..a1401b09a4e 100644 --- a/plugins/woocommerce/package.json +++ b/plugins/woocommerce/package.json @@ -51,10 +51,9 @@ "makepot": "composer run-script makepot", "packages:fix:textdomain": "node ./bin/package-update-textdomain.js", "test": "pnpm test:unit", - "test:api": "API_TEST_REPORT_DIR=\"$PWD/tests/api\" pnpm exec wc-api-tests test api", - "test:api-pw": "USE_WP_ENV=1 pnpm playwright test --config=tests/api-core-tests/playwright.config.js", - "test:e2e-pw": "pnpm test:e2e:install && pnpm playwright test --config=tests/e2e-pw/envs/default/playwright.config.js", - "test:e2e": "pnpm test:e2e:install && pnpm test:e2e:with-env default", + "test:api": "pnpm test:e2e:default --project=api --workers 4", + "test:e2e": "pnpm test:e2e:default --project=ui", + "test:e2e:default": "pnpm test:e2e:install && pnpm test:e2e:with-env default", "test:e2e:install": "pnpm playwright install chromium", "test:e2e:blocks": "pnpm --filter='@woocommerce/block-library' test:e2e", "test:e2e:with-env": "pnpm test:e2e:install && bash ./tests/e2e-pw/run-tests-with-env.sh", @@ -221,7 +220,7 @@ { "name": "Core e2e tests", "testType": "e2e", - "command": "test:e2e:with-env default", + "command": "test:e2e", "shardingArguments": [ "--shard=1/6", "--shard=2/6", @@ -365,7 +364,7 @@ { "name": "Core e2e tests - HPOS disabled", "testType": "e2e", - "command": "test:e2e:with-env default", + "command": "test:e2e", "shardingArguments": [ "--shard=1/5", "--shard=2/5", @@ -393,7 +392,7 @@ { "name": "Core e2e tests - PHP 8.1", "testType": "e2e", - "command": "test:e2e:with-env default", + "command": "test:e2e", "shardingArguments": [ "--shard=1/5", "--shard=2/5", @@ -421,7 +420,7 @@ { "name": "Core e2e tests - WP latest-1", "testType": "e2e", - "command": "test:e2e:with-env default", + "command": "test:e2e", "shardingArguments": [ "--shard=1/5", "--shard=2/5", @@ -449,7 +448,7 @@ { "name": "Core API tests", "testType": "api", - "command": "test:api-pw", + "command": "test:api", "optional": false, "changes": [ "client/admin/config/*.json", @@ -459,8 +458,6 @@ "patterns/**/*.php", "src/**/*.php", "templates/**/*.php", - "tests/api-core-tests/**", - "tests/e2e-pw/bin/**", ".wp-env.json" ], "testEnv": { @@ -472,14 +469,14 @@ ], "report": { "resultsBlobName": "core-api-report", - "resultsPath": "tests/api-core-tests/test-results", + "resultsPath": "tests/e2e-pw/test-results", "allure": true } }, { "name": "Core API tests - HPOS disabled", "testType": "api", - "command": "test:api-pw", + "command": "test:api", "optional": false, "changes": [ "client/admin/config/*.json", @@ -489,7 +486,6 @@ "patterns/**/*.php", "src/**/*.php", "templates/**/*.php", - "tests/api-core-tests/**", "tests/e2e-pw/bin/**", ".wp-env.json" ], @@ -504,7 +500,7 @@ }, "report": { "resultsBlobName": "core-api-report-hpos-disabled", - "resultsPath": "tests/api-core-tests/test-results", + "resultsPath": "tests/e2e-pw/test-results", "allure": true } }, diff --git a/plugins/woocommerce/tests/api-core-tests/.eslintrc.js b/plugins/woocommerce/tests/api-core-tests/.eslintrc.js deleted file mode 100644 index 7cdd6ec4d3d..00000000000 --- a/plugins/woocommerce/tests/api-core-tests/.eslintrc.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], - rules: { - 'jsdoc/check-tag-names': 'off', - 'jest/no-test-callback': 'off', - camelcase: 'off', - 'jest/no-disabled-tests': 'off', - 'no-shadow': 'off', - 'jest/no-identical-title': 'off', - 'jest/no-standalone-expect': 'off', - 'no-console': 'off', - }, -}; diff --git a/plugins/woocommerce/tests/api-core-tests/README.md b/plugins/woocommerce/tests/api-core-tests/README.md deleted file mode 100644 index b26220270f4..00000000000 --- a/plugins/woocommerce/tests/api-core-tests/README.md +++ /dev/null @@ -1,498 +0,0 @@ -# WooCommerce Core API Test Suite - -This package contains automated API tests for WooCommerce, based on Playwright and `wp-env`. It supersedes the SuperTest based [api-core-tests package](https://www.npmjs.com/package/@woocommerce/api-core-tests) and e2e-environment [setup](../tests/e2e), which we will gradually deprecate. - -## Table of contents - -- [Pre-requisites](#pre-requisites) -- [Introduction](#introduction) -- [About the Environment](#about-the-environment) -- [Test Variables](#test-variables) -- [Guide for writing API tests](#guide-for-writing-api-tests) - - [What aspects of the API should we test?](#what-aspects-of-the-api-should-we-test) - - [Creating test structure](#creating-test-structure) - - [Test Data Setup/Teardown](#test-data-setupteardown) - - [Writing the test - A Quick Start Guide](#writing-the-test---a-quick-start-guide) - - [Examples](#examples) - - [Debugging tests](#debugging-tests) -- [Guide for using test reports](#guide-for-using-test-reports) - - [Viewing the Playwright HTML report](#viewing-the-playwright-html-report) - - [Viewing the Allure report](#viewing-the-allure-report) - -## Pre-requisites - -- Node.js ([Installation instructions](https://nodejs.org/en/download/)) -- NVM ([Installation instructions](https://github.com/nvm-sh/nvm)) -- PNPM ([Installation instructions](https://pnpm.io/installation)) -- Docker and Docker Compose ([Installation instructions](https://docs.docker.com/engine/install/)) - -Note, that if you are on Mac and you install Docker through other methods such as homebrew, for example, your steps to set it up might be different. The commands listed in steps below may also vary. - -If you are using Windows, we recommend using [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/) for running tests. Follow the [WSL Setup Instructions](../tests/e2e/WSL_SETUP_INSTRUCTIONS.md) first before proceeding with the steps below. - -### Introduction - -WooCommerce's `api-core-tests` are powered by Playwright. The test site is spun up using `wp-env` (recommended), but we will continue to support `e2e-environment` in the meantime. - -**Running tests for the first time:** - -- `nvm use` -- `pnpm install` -- `pnpm --filter='@woocommerce/plugin-woocommerce' build` -- `cd plugins/woocommerce` -- `pnpm env:test` -- `pnpm test:api-pw` - -To run the test again, re-create the environment to start with a fresh state - -- `pnpm env:destroy` -- `pnpm env:test` -- `pnpm test:api-pw` - -Other ways of running tests: - -- `pnpm test:api-pw ./tests/api-core-tests/tests/hello/hello.test.js` (running a single test file) -- `pnpm test:api-pw ./tests/api-core-tests/tests/hello` (running all tests in a single folder) - -To see all options, run `cd plugins/woocommerce && pnpm playwright test --help` - -## Environment variables - -The following environment variables can be configured as shown in `.env.example`: - -``` -# Your site's base URL, not including a trailing slash -API_BASE_URL="https://mysite.com" - -# The admin user's username or generated consumer key -USER_KEY="" - -# The admin user's password or generated consumer secret -USER_SECRET="" -``` - -For local setup, create a `.env` file in the `woocommerce/plugins/woocommerce/tests/api-core-tests` folder with the three required values described above. If any of these variables are configured they will override the values automatically set in the `playwright.config.js` - -When using a username and password combination instead of a consumer secret and consumer key, make sure to have the [JSON Basic Authentication plugin](https://github.com/WP-API/Basic-Auth) installed and activated on the test site. - -For more information about authentication with the WooCommerce API, please see the [Authentication](https://woocommerce.github.io/woocommerce-rest-api-docs/?javascript#authentication) section in the WooCommerce REST API documentation. - -### About the environment - -The default values are: - -- Latest stable WordPress version -- PHP 7.4 -- MariaDB -- URL: `http://localhost:8086/` -- Admin credentials: `admin/password` - -If you want to customize these, check the [Test Variables](#test-variables) section. - - -For more information how to configure the test environment for `wp-env`, please checkout the [documentation](https://github.com/WordPress/gutenberg/tree/trunk/packages/env) documentation. - -### Test Variables - -The test environment uses the following test variables: - -```json -{ - "url": "http://localhost:8086/", - "users": { - "admin": { - "username": "admin", - "password": "password" - }, - "customer": { - "username": "customer", - "password": "password" - } - } -} -``` - -If you need to modify the port for your local test environment (eg. port is already in use) or use, edit [playwright.config.js](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/e2e/playwright.config.js). Depending on what environment tool you are using, you will need to also edit the respective `.json` file. - -**Modify the port wp-env** - -Edit [.wp-env.json](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/.wp-env.json) and [playwright.config.js](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/e2e/playwright.config.js). - -**Modify port for e2e-environment** - -Edit [tests/e2e/config/default.json](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/e2e/config/default.json).**** - -### Starting/stopping the environment - -After you run a test, it's best to restart the environment to start from a fresh state. We are currently working to reset the state more efficiently to avoid the restart being needed, but this is a work-in-progress. - -- `pnpm env:down` to stop the environment -- `pnpm env:destroy` when you make changes to `.wp-env.json` -- `pnpm env:test` to spin up the test environment - -## Guide for writing API tests - -When writing new tests, a good source on how to get started is to reference the [existing tests](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/api-core-tests/tests). Data that is required for the tests should be located in an equivalent file in the [data](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/api-core-tests/data) folder. - -Good examples to reference are the `coupons` and `customers` tests. The [Quick Start Guide](#writing-the-test---a-quick-start-guide) below has the key steps to put together a test and examples of how those steps were implemented for `coupons` and `customers`. - -The [Playwright documentation](https://playwright.dev/docs/intro) is a good source for finding out more details on the various methods used in the tests, including what is available to you when you write new tests. The [API testing](https://playwright.dev/docs/test-api-testing) section has a good example on how the [playwright.config.js](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/api-core-tests/playwright.config.js) is used (see [Configuration](https://playwright.dev/docs/test-api-testing#configuration) section) and also how [Setup and Teardown](https://playwright.dev/docs/test-api-testing#setup-and-teardown) works. - -Note: Playwright uses the [expect](https://jestjs.io/docs/expect) library for test assertions. This library provides a lot of matchers like `toEqual`, `toContain`, `toHaveLength` and many more. Examples of these are throughout the test files. - -## What aspects of the API should we test? - -Assuming that we have validated the API contract (inspected the spec/contract, made sure the endpoints are correctly named, resources and types reflect the object model and there is no missing/duplicate functionality) we are ready to test. - -A test contains 3 different stages: -1. `precondition` -2. `action` -3. `validation` - -and in the case of API testing, this equates to: -1. `data creation` - see [Test Data Setup Examples](#test-data-setup-examples) below -2. `send API request` - see [Request Examples](#request-examples) below -3. `response validation` - see [Validation Examples](#validation-examples) below - -For each API request method (`GET`, `POST`, `PUT`, `DELETE`, `PATCH`), the test would need to take the following actions: -1. Verify correct HTTP status code. For example, creating a resource should return 201 CREATED and un-permitted requests should return 403 FORBIDDEN, etc. -2. Verify response payload. Check the JSON body is valid and field names, types, and values are correct (i.e. check the response payload schema is implemented according to the specification) — including error responses. - -3. Verify response headers where appropriate e.g. Some headers hold information related to search totals, pagination values etc. (see [Examples](#examples) below). - -At a minimum, we want to ensure each possible CRUD operation can be applied and sufficient assertions have been validated based on the above. - -A reasonable process would be: -1. Create an object using a `POST` request -2. Retrieve the created object using the `GET` request -3. Update the object using a `POST` request -4. Delete the object using a `DELETE`request -5. Test any batch create/update/delete operations (if applicable) - -Additional tests can also be added to test the following general test scenarios: - -- Basic positive tests (happy paths) - check basic functionality and the acceptance criteria of the API -- Extended positive testing with optional parameters - more thorough testing (can be used for testing a bug/updates/new functionality) -- Negative testing with valid input - expect to gracefully handle problem scenarios with valid user input e.g. trying to add an existing username -- Negative testing with invalid input - expect to gracefully handle problem scenarios with invalid user input e.g. trying to add a username which is null - -The intention here is to validate that we get error responses when expected as per specification and the error status code and message are correct as per documentation. - -## Creating test structure - -The structure of the test serves as a skeleton for the test itself. - -Each test file requires the `@playwright/test` module to be imported as follows: -```js -const { test, expect } = require( '@playwright/test' ); -``` -You can create a test by using the `test.describe()` and `test()` methods of Playwright: - -- [`test.describe()`](https://playwright.dev/docs/api/class-test#test-describe-1) - creates a block that groups together several related tests; -- [`test()`](https://playwright.dev/docs/api/class-test#test-call) - actual method that runs the test. - -Based on our example, the test skeleton would look as follows: - -```js -test.describe( 'Coupons API tests', () => { - test( 'can create a coupon', async ( {request} ) => { - // test to create a coupon here - } ); - - test( 'can retrieve a coupon', async ( {request} ) => { - // test to retrieve a coupon here - } ); - - test( 'can update a coupon', async ( { request } ) => { - // test to update a coupon here - } ); -} ); -``` - -Note: you can also nest a `test.describe()` inside a `test.describe()`. Example: - -```js -test.describe('Orders API tests: CRUD', () => { - let orderId; //test variable - - test.describe('Create an order', () => { - test('can create a pending order by default', async ({request}) => { - //test code here - } -``` -This allows you to further subgroup tests. When viewing the tests results locally, each test describe 'level' will be separated by `>` in the console as below: - -`Orders API tests: CRUD › Create an order › can create a pending order by default` - -## Test Data Setup/Teardown - -You may need test data setup prior to the execution of your tests. If so, make sure it is removed after the execution of your tests. This can be achieved with any of the following methods, depending on the needs of the test: - -- [`test.beforeAll()`](https://playwright.dev/docs/api/class-test#test-before-all) - runs before all the tests in file/group -- [`test.beforeEach()`](https://playwright.dev/docs/api/class-test#test-before-each) - runs before each test in file/group -- [`test.afterEach()`](https://playwright.dev/docs/api/class-test#test-after-each) - runs after each test in file/group -- [`test.afterAll()`](https://playwright.dev/docs/api/class-test#test-after-all) - runs after all the tests in file/group - - -## Writing the test - a Quick Start Guide - -1. Ensure you have your authentication setup as mentioned in the [Environment Variables](#environment-variables) section above. i.e. - > For local setup, create a `.env` file -2. Create `test.js` file inside the tests directory - - Example for [`coupons`](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js) and [`customers`](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/api-core-tests/tests/customers/customers-crud.test.js) -3. Import `@playwright/test` module - - Example for [`coupons`](https://github.com/woocommerce/woocommerce/blob/b904fd428db1252f39cb64005f4b627f2a9ac08e/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js#L1) and [`customers`](https://github.com/woocommerce/woocommerce/blob/b904fd428db1252f39cb64005f4b627f2a9ac08e/plugins/woocommerce/tests/api-core-tests/tests/customers/customers-crud.test.js#L1) -4. Group tests with `test.describe()` methods - - Example for [`coupons`](https://github.com/woocommerce/woocommerce/blob/b904fd428db1252f39cb64005f4b627f2a9ac08e/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js#L10) and [`customers`](https://github.com/woocommerce/woocommerce/blob/b904fd428db1252f39cb64005f4b627f2a9ac08e/plugins/woocommerce/tests/api-core-tests/tests/customers/customers-crud.test.js#L20) -5. Add tests with `test()` methods - - Example for [`coupons`](https://github.com/woocommerce/woocommerce/blob/b904fd428db1252f39cb64005f4b627f2a9ac08e/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js#L14) and [`customers`](https://github.com/woocommerce/woocommerce/blob/b904fd428db1252f39cb64005f4b627f2a9ac08e/plugins/woocommerce/tests/api-core-tests/tests/customers/customers-crud.test.js#L93) -6. Separate data where required into files in the `data` directory - - Example for [`coupons`](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/api-core-tests/data/coupon.js) and [`customers`](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/api-core-tests/data/customer.js) -7. Import data required by your tests - - Example for [`coupons`](https://github.com/woocommerce/woocommerce/blob/b904fd428db1252f39cb64005f4b627f2a9ac08e/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js#L2) and [`customers`](https://github.com/woocommerce/woocommerce/blob/b904fd428db1252f39cb64005f4b627f2a9ac08e/plugins/woocommerce/tests/api-core-tests/tests/customers/customers-crud.test.js#L5) -8. After writing your tests, ensure all tests pass successfully with `pnpm test:api-pw` - -If you have made updates to functionality that breaks the tests then the tests should be updated accordingly. Similarly, if there is new functionality added then new tests should be added. - -## Examples - -Below are examples in our `api-core-tests` including references and typical API test operations. - -Playwright [configuration file](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/tests/api-core-tests/playwright.config.js) - -Test files [location](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/api-core-tests/tests) - -Data files [location](https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/tests/api-core-tests/data) - -### Test Data Setup Examples - -Setup data with [test.beforeAll()](https://github.com/woocommerce/woocommerce/blob/4ac1d822ac9082102536b0f7aa9cb0553965adaa/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js#L347) -```js - test.beforeAll( async ( { request } ) => { - // Create a coupon - const createCouponResponse = await request.post( - '/wp-json/wc/v3/coupons/', - { - data: testCoupon, - } - ); - const createCouponResponseJSON = await createCouponResponse.json(); - testCoupon.id = createCouponResponseJSON.id; - } ); - ``` - -Teardown data with [test.afterAll()](https://github.com/woocommerce/woocommerce/blob/4ac1d822ac9082102536b0f7aa9cb0553965adaa/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js#L360) -```js - // Clean up created coupon and order - test.afterAll( async ( { request } ) => { - await request.delete( `/wp-json/wc/v3/coupons/${ testCoupon.id }`, { - data: { force: true }, - } ); - await request.delete( `/wp-json/wc/v3/orders/${ orderId }`, { - data: { force: true }, - } ); - } ); - ``` -### Request Examples - -`GET` [request](https://github.com/woocommerce/woocommerce/blob/4ac1d822ac9082102536b0f7aa9cb0553965adaa/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js#L44) -```js - //call API to get previously created coupon - const response = await request.get( - `/wp-json/wc/v3/coupons/${ couponId }` - ); -``` - -`POST` [request](https://github.com/woocommerce/woocommerce/blob/4ac1d822ac9082102536b0f7aa9cb0553965adaa/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js#L63) -```js - //call API to update previously created coupon - const response = await request.post( - `/wp-json/wc/v3/coupons/${ couponId }`, - { - data: updatedCouponDetails, - } - ); -``` - -`PUT` [request](https://github.com/woocommerce/woocommerce/blob/4ac1d822ac9082102536b0f7aa9cb0553965adaa/plugins/woocommerce/tests/api-core-tests/tests/orders/order-complex.test.js#L220) -```js - //ensure tax calculations are enabled - await request.put( - '/wp-json/wc/v3/settings/general/woocommerce_calc_taxes', - { - data: { - value: 'yes', - }, - } - ); -``` - -`DELETE` [request](https://github.com/woocommerce/woocommerce/blob/4ac1d822ac9082102536b0f7aa9cb0553965adaa/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js#L80) -```js -//call API to delete previously created coupon - const response = await request.delete( - `/wp-json/wc/v3/coupons/${ couponId }`, - { - data: { force: true }, - } - ); -``` - -`BATCH` [request](https://github.com/woocommerce/woocommerce/blob/4ac1d822ac9082102536b0f7aa9cb0553965adaa/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js#L119) -```js - // Batch create 2 new coupons. - const batchCreatePayload = { - create: expectedCoupons, - }; - - // call API to batch create coupons - const batchCreateResponse = await request.post( - 'wp-json/wc/v3/coupons/batch', - { - data: batchCreatePayload, - } - ); -``` - -### Validation Examples - -Verify [Status code](https://github.com/woocommerce/woocommerce/blob/4ac1d822ac9082102536b0f7aa9cb0553965adaa/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js#L30) -```js - expect( response.status() ).toEqual( 201 ); -``` - -Verify [Response payload](https://github.com/woocommerce/woocommerce/blob/4ac1d822ac9082102536b0f7aa9cb0553965adaa/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js#L33) -```js -//validate the response data - expect( await response.json() ).toEqual( - expect.objectContaining( { - code: testCoupon.code, - amount: Number( coupon.amount ).toFixed( 2 ), - discount_type: coupon.discount_type, - } ) - ); -``` - -Verify [field names](https://github.com/woocommerce/woocommerce/blob/4ac1d822ac9082102536b0f7aa9cb0553965adaa/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js#L142) -```js - expect( id ).toBeDefined(); - expect( code ).toEqual( expectedCouponCode ); -``` - -Verify [field types](https://github.com/woocommerce/woocommerce/blob/d19c20491e5a7ade64c8fd530f01e0f3f3f7e29c/plugins/woocommerce/tests/api-core-tests/tests/shipping/shipping-method.test.js#L85) -```js -expect(typeof responseJSON.id).toEqual('string'); -``` - -Verify [field values](https://github.com/woocommerce/woocommerce/blob/4ac1d822ac9082102536b0f7aa9cb0553965adaa/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js#L186) -```js -expect( updatedCoupons[ 1 ].amount ).toEqual( '25.00' ); -``` - -Verify [field length](https://github.com/woocommerce/woocommerce/blob/4ac1d822ac9082102536b0f7aa9cb0553965adaa/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js#L136) -```js -expect( actualCoupons ).toHaveLength( expectedCoupons.length ); -``` - -Verify search [headers](https://github.com/woocommerce/woocommerce/blob/d19c20491e5a7ade64c8fd530f01e0f3f3f7e29c/plugins/woocommerce/tests/api-core-tests/tests/orders/orders.test.js#L2703) -```js -// Verify total page count. - expect( page1.headers()[ 'x-wp-total' ] ).toEqual( - ORDERS_COUNT.toString() - ); - expect( page1.headers()[ 'x-wp-totalpages' ] ).toEqual( '3' ); - ``` - -Verify variable [not undefined](https://github.com/woocommerce/woocommerce/blob/778cb130f27d0dd0dc7da1acb0e89762f81c0f18/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js#L31) -```js -expect( couponId ).toBeDefined(); -``` - -Verify [response contains an object](https://github.com/woocommerce/woocommerce/blob/778cb130f27d0dd0dc7da1acb0e89762f81c0f18/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js#L73) -```js -expect( await response.json() ).toEqual( - expect.objectContaining( updatedCouponDetails ) - ); -``` - -Verify [response contains an array containing an object](https://github.com/woocommerce/woocommerce/blob/778cb130f27d0dd0dc7da1acb0e89762f81c0f18/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js#L388) -```js - expect( responseJSON.coupon_lines[ 0 ].meta_data ).toEqual( - expect.arrayContaining( [ - expect.objectContaining( { - key: 'coupon_data', - value: expect.objectContaining( { - code: testCoupon.code, - } ), - } ), - ] ) - ); -``` - -## Debugging tests - -The Playwright debugger won't work for the API tests as it is based around GUI interactions. - -For now it is simple enough to add `console.log()` statements to output the values of your response/JSON/variables/status etc. Be sure to remove them when done ;) - -You can also use the handy [REST API Log](https://wordpress.org/plugins/wp-rest-api-log/) plugin to see the API request information within WordPress. It displays the details, request headers, query params, body params, body content, response headers and response body information. - -For the list of WooCommerce API endpoints, expected responses, and more, please see the [WooCommerce REST API Documentation](https://woocommerce.github.io/woocommerce-rest-api-docs/). - -## Guide for using test reports - -The tests would generate three kinds of reports after the run: -1. A Playwright HTML report. -1. A Playwright JSON report. -1. Allure results. - -By default, they are saved inside the `test-results` folder. If you want to save them in a custom location, just assign the absolute path to the environment variables mentioned in the [Playwright](https://playwright.dev/docs/test-reporters) and [Allure-Playwright](https://www.npmjs.com/package/allure-playwright) documentation. - -| Report | Default location | Environment variable for custom location | -| ----------- | ---------------- | ---------------------------------------- | -| Playwright HTML report | `test-results/playwright-report` | `PLAYWRIGHT_HTML_REPORT` | -| Playwright JSON report | `test-results/test-results.json` | `PLAYWRIGHT_JSON_OUTPUT_NAME` | -| Allure results | `test-results/allure-results` | `ALLURE_RESULTS_DIR` | - -### Viewing the Playwright HTML report - -Use the `playwright show-report $PATH_TO_PLAYWRIGHT_HTML_REPORT` command to open the report. For example, assuming that you're at the root of the WooCommerce monorepo, and that you did not specify a custom location for the report, you would use the following commands: - -```bash -cd plugins/woocommerce -pnpm exec playwright show-report tests/api-core-tests/test-results/playwright-report -``` - -For more details about the Playwright HTML report, see their [HTML Reporter](https://playwright.dev/docs/test-reporters#html-reporter) documentation. - -### Viewing the Allure report - -This assumes that you're already familiar with reports generated by the [Allure Framework](https://github.com/allure-framework), particularly: -- What the `allure-results` and `allure-report` folders are, and how they're different from each other. -- Allure commands like `allure generate` and `allure open`. - -Use the `allure generate` command to generate an HTML report from the `allure-results` directory created at the end of the test run. Then, use the `allure open` command to open it on your browser. For example, assuming that: -- You're at the root of the WooCommerce monorepo -- You did not specify a custom location for `allure-results` (you did not assign a value to `ALLURE_RESULTS_DIR`) -- You want to generate the `allure-report` folder in `plugins/woocommerce/tests/api-core-tests/test-results` - -Then you would need to use the following commands: - -```bash -cd plugins/woocommerce -pnpm exec allure generate --clean tests/api-core-tests/test-results/allure-results --output tests/api-core-tests/test-results/allure-report -pnpm exec allure open tests/api-core-tests/test-results/allure-report -``` - -A browser window should open the Allure report. - -If you're using [WSL](https://learn.microsoft.com/en-us/windows/wsl/about) however, you might get this message right after running the `allure open` command: -``` -Starting web server... -2022-12-09 18:52:01.323:INFO::main: Logging initialized @286ms to org.eclipse.jetty.util.log.StdErrLog -Can not open browser because this capability is not supported on your platform. You can use the link below to open the report manually. -Server started at . Press to exit -``` -In this case, take note of the port number (38917 in the example above) and then use it to navigate to `http://localhost`. Taking the example above, you should be able to view the Allure report on http://localhost:38917. - -To know more about the allure-playwright integration, see their [GitHub documentation](https://github.com/allure-framework/allure-js/tree/master/packages/allure-playwright). diff --git a/plugins/woocommerce/tests/api-core-tests/ci-release.global-setup.js b/plugins/woocommerce/tests/api-core-tests/ci-release.global-setup.js deleted file mode 100644 index 80689772d13..00000000000 --- a/plugins/woocommerce/tests/api-core-tests/ci-release.global-setup.js +++ /dev/null @@ -1,122 +0,0 @@ -const { UPDATE_WC, USER_KEY, USER_SECRET } = process.env; -const { test: setup, expect } = require( '@playwright/test' ); -const fs = require( 'fs' ); -const { downloadWooCommerceRelease } = require( './utils/plugin-utils' ); -const pluginEndpoint = '/wp-json/wp/v2/plugins/woocommerce/woocommerce'; - -let zipPath; - -setup( `Setup remote test site`, async ( { page, request } ) => { - setup.setTimeout( 5 * 60 * 1000 ); - - await setup.step( `Download WooCommerce build zip`, async () => { - zipPath = await downloadWooCommerceRelease( { request } ); - } ); - - await setup.step( 'Login to wp-admin', async () => { - const Username = 'Username or Email Address'; - const Password = 'Password'; - const Log_In = 'Log In'; - const Dashboard = 'Dashboard'; - - // Need to wait until network idle. Otherwise, Password field gets auto-cleared after typing password in. - await page.goto( '/wp-admin', { waitUntil: 'networkidle' } ); - await page.getByLabel( Username ).fill( USER_KEY ); - await page.getByLabel( Password, { exact: true } ).fill( USER_SECRET ); - await page.getByRole( 'button', { name: Log_In } ).click(); - await expect( - page - .locator( '#menu-dashboard' ) - .getByRole( 'link', { name: Dashboard } ) - ).toBeVisible(); - } ); - - const installed = await setup.step( - `See if there's a WooCommerce plugin installed`, - async () => { - const response = await request.get( pluginEndpoint ); - const isOK = response.ok(); - const status = response.status(); - - // Fast-fail if response was neither OK nor 404. - expect( isOK || status === 404 ).toEqual( true ); - - return isOK; - } - ); - - await setup.step( - `Deactivate currently installed WooCommerce version`, - async () => { - if ( ! installed ) { - return; - } - - const options = { - data: { - status: 'inactive', - }, - }; - const response = await request.put( pluginEndpoint, options ); - expect( response.ok() ).toBeTruthy(); - } - ); - - await setup.step( - `Delete currently installed WooCommerce version`, - async () => { - if ( ! installed ) { - return; - } - - const response = await request.delete( pluginEndpoint ); - expect( response.ok() ).toBeTruthy(); - } - ); - - await setup.step( `Install WooCommerce ${ UPDATE_WC }`, async () => { - const Upload_Plugin = 'Upload Plugin'; - const Plugin_zip_file = 'Plugin zip file'; - const Install_Now = 'Install Now'; - const Activate_Plugin = 'Activate Plugin'; - const timeout = 3 * 60 * 1000; - - await page.goto( '/wp-admin/plugin-install.php' ); - await page.getByRole( 'button', { name: Upload_Plugin } ).click(); - await page.getByLabel( Plugin_zip_file ).setInputFiles( zipPath ); - await page.getByRole( 'button', { name: Install_Now } ).click(); - await expect( - page.getByRole( 'link', { name: Activate_Plugin } ) - ).toBeVisible( { timeout } ); - } ); - - await setup.step( `Activate WooCommerce`, async () => { - const options = { - data: { - status: 'active', - }, - }; - const response = await request.put( pluginEndpoint, options ); - expect( response.ok() ).toBeTruthy(); - } ); - - await setup.step( `Verify WooCommerce version was installed`, async () => { - const response = await request.get( pluginEndpoint ); - const { status, version } = await response.json(); - expect( status ).toEqual( 'active' ); - expect( version ).toEqual( UPDATE_WC ); - } ); - - await setup.step( `Verify WooCommerce database version`, async () => { - const response = await request.get( '/wp-json/wc/v3/system_status' ); - const { database } = await response.json(); - const { wc_database_version } = database; - const [ major, minor ] = UPDATE_WC.split( '.' ); - const pattern = new RegExp( `^${ major }\.${ minor }` ); - expect( wc_database_version ).toMatch( pattern ); - } ); - - await setup.step( `Delete zip`, async () => { - fs.unlinkSync( zipPath ); - } ); -} ); diff --git a/plugins/woocommerce/tests/api-core-tests/ci-release.playwright.config.js b/plugins/woocommerce/tests/api-core-tests/ci-release.playwright.config.js deleted file mode 100644 index e44208c2fc2..00000000000 --- a/plugins/woocommerce/tests/api-core-tests/ci-release.playwright.config.js +++ /dev/null @@ -1,26 +0,0 @@ -const defaultConfig = require( './playwright.config' ); -const { devices } = require( '@playwright/test' ); - -// Global setup will be done through the 'Setup' project, not through the `globalSetup` property -delete defaultConfig[ 'globalSetup' ]; - -/** - * @type {import('@playwright/test').PlaywrightTestConfig} - */ -const config = { - ...defaultConfig, - projects: [ - { - name: 'Setup', - testDir: './', - testMatch: 'ci-release.global-setup.js', - use: { ...devices[ 'Desktop Chrome' ] }, - }, - { - name: 'API tests', - dependencies: [ 'Setup' ], - }, - ], -}; - -module.exports = config; diff --git a/plugins/woocommerce/tests/api-core-tests/data/customer.js b/plugins/woocommerce/tests/api-core-tests/data/customer.js deleted file mode 100644 index 0b4f50f5e80..00000000000 --- a/plugins/woocommerce/tests/api-core-tests/data/customer.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * This file contains objects that can be used as test data for scenarios around creating, retrieivng, updating, and deleting customers. - * - * For more details on the Product properties, see: - * - * https://woocommerce.github.io/woocommerce-rest-api-docs/#customers - * - */ - -/** - * A customer - */ - const customer = { - email: "john.doe@example.com", - first_name: "John", - last_name: "Doe", - username: "john.doe", - billing: { - first_name: "John", - last_name: "Doe", - company: "", - address_1: "969 Market", - address_2: "", - city: "San Francisco", - state: "CA", - postcode: "94103", - country: "US", - email: "john.doe@example.com", - phone: "(555) 555-5555" - }, - shipping: { - first_name: "John", - last_name: "Doe", - company: "", - address_1: "969 Market", - address_2: "", - city: "San Francisco", - state: "CA", - postcode: "94103", - country: "US" - } - }; - - module.exports = { - customer, -}; \ No newline at end of file diff --git a/plugins/woocommerce/tests/api-core-tests/data/tax-rate.js b/plugins/woocommerce/tests/api-core-tests/data/tax-rate.js deleted file mode 100644 index 024b749a918..00000000000 --- a/plugins/woocommerce/tests/api-core-tests/data/tax-rate.js +++ /dev/null @@ -1,421 +0,0 @@ -/** - * A standard tax rate. - * - * For more details on the tax rate properties, see: - * - * https://woocommerce.github.io/woocommerce-rest-api-docs/#tax-rate-properties - * - */ -const standardTaxRate = { - name: 'Standard Rate', - rate: '10.0000', - class: 'standard', -}; - -const reducedTaxRate = { - name: 'Reduced Rate', - rate: '1.0000', - class: 'reduced-rate', -}; - -const zeroTaxRate = { - name: 'Zero Rate', - rate: '0.0000', - class: 'zero-rate', -}; - -const getTaxRateExamples = () => { - return { standardTaxRate, reducedTaxRate, zeroTaxRate }; -}; - -const allUSTaxesExample = [ - { - country: "US", - state: "AL", - rate: "4.0000", - name: "State Tax", - shipping: false, - order: 1 - }, - { - country: "US", - state: "AZ", - rate: "5.6000", - name: "State Tax", - shipping: false, - order: 2 - }, - { - country: "US", - state: "AR", - rate: "6.5000", - name: "State Tax", - shipping: true, - order: 3 - }, - { - country: "US", - state: "CA", - rate: "7.5000", - name: "State Tax", - shipping: false, - order: 4 - }, - { - country: "US", - state: "CO", - rate: "2.9000", - name: "State Tax", - shipping: false, - order: 5 - }, - { - country: "US", - state: "CT", - rate: "6.3500", - name: "State Tax", - shipping: true, - order: 6 - }, - { - country: "US", - state: "DC", - rate: "5.7500", - name: "State Tax", - shipping: true, - order: 7 - }, - { - country: "US", - state: "FL", - rate: "6.0000", - name: "State Tax", - shipping: true, - order: 8 - }, - { - country: "US", - state: "GA", - rate: "4.0000", - name: "State Tax", - shipping: true, - order: 9 - }, - { - country: "US", - state: "GU", - rate: "4.0000", - name: "State Tax", - shipping: false, - order: 10 - }, - { - country: "US", - state: "HI", - rate: "4.0000", - name: "State Tax", - shipping: true, - order: 11 - }, - { - country: "US", - state: "ID", - rate: "6.0000", - name: "State Tax", - shipping: false, - order: 12 - }, - { - country: "US", - state: "IL", - rate: "6.2500", - name: "State Tax", - shipping: false, - order: 13 - }, - { - country: "US", - state: "IN", - rate: "7.0000", - name: "State Tax", - shipping: false, - order: 14 - }, - { - country: "US", - state: "IA", - rate: "6.0000", - name: "State Tax", - shipping: false, - order: 15 - }, - { - country: "US", - state: "KS", - rate: "6.1500", - name: "State Tax", - shipping: true, - order: 16 - }, - { - country: "US", - state: "KY", - rate: "6.0000", - name: "State Tax", - shipping: true, - order: 17 - }, - { - country: "US", - state: "LA", - rate: "4.0000", - name: "State Tax", - shipping: false, - order: 18 - }, - { - country: "US", - state: "ME", - rate: "5.5000", - name: "State Tax", - shipping: false, - order: 19 - }, - { - country: "US", - state: "MD", - rate: "6.0000", - name: "State Tax", - shipping: false, - order: 20 - }, - { - country: "US", - state: "MA", - rate: "6.2500", - name: "State Tax", - shipping: false, - order: 21 - }, - { - country: "US", - state: "MI", - rate: "6.0000", - name: "State Tax", - shipping: true, - order: 22 - }, - { - country: "US", - state: "MN", - rate: "6.8750", - name: "State Tax", - shipping: true, - order: 23 - }, - { - country: "US", - state: "MS", - rate: "7.0000", - name: "State Tax", - shipping: true, - order: 24 - }, - { - country: "US", - state: "MO", - rate: "4.2250", - name: "State Tax", - shipping: false, - order: 25 - }, - { - country: "US", - state: "NE", - rate: "5.5000", - name: "State Tax", - shipping: true, - order: 26 - }, - { - country: "US", - state: "NV", - rate: "6.8500", - name: "State Tax", - shipping: false, - order: 27 - }, - { - country: "US", - state: "NJ", - rate: "7.0000", - name: "State Tax", - shipping: true, - order: 28 - }, - { - country: "US", - state: "NM", - rate: "5.1250", - name: "State Tax", - shipping: true, - order: 29 - }, - { - country: "US", - state: "NY", - rate: "4.0000", - name: "State Tax", - shipping: true, - order: 30 - }, - { - country: "US", - state: "NC", - rate: "4.7500", - name: "State Tax", - shipping: true, - order: 31 - }, - { - country: "US", - state: "ND", - rate: "5.0000", - name: "State Tax", - shipping: true, - order: 32 - }, - { - country: "US", - state: "OH", - rate: "5.7500", - name: "State Tax", - shipping: true, - order: 33 - }, - { - country: "US", - state: "OK", - rate: "4.5000", - name: "State Tax", - shipping: false, - order: 34 - }, - { - country: "US", - state: "PA", - rate: "6.0000", - name: "State Tax", - shipping: true, - order: 35 - }, - { - country: "US", - state: "PR", - rate: "6.0000", - name: "State Tax", - shipping: false, - order: 36 - }, - { - country: "US", - state: "RI", - rate: "7.0000", - name: "State Tax", - shipping: false, - order: 37 - }, - { - country: "US", - state: "SC", - rate: "6.0000", - name: "State Tax", - shipping: true, - order: 38 - }, - { - country: "US", - state: "SD", - rate: "4.0000", - name: "State Tax", - shipping: true, - order: 39 - }, - { - country: "US", - state: "TN", - rate: "7.0000", - name: "State Tax", - shipping: true, - order: 40 - }, - { - country: "US", - state: "TX", - rate: "6.2500", - name: "State Tax", - shipping: true, - order: 41 - }, - { - country: "US", - state: "UT", - rate: "5.9500", - name: "State Tax", - shipping: false, - order: 42 - }, - { - country: "US", - state: "VT", - rate: "6.0000", - name: "State Tax", - shipping: true, - order: 43 - }, - { - country: "US", - state: "VA", - rate: "5.3000", - name: "State Tax", - shipping: false, - order: 44 - }, - { - country: "US", - state: "WA", - rate: "6.5000", - name: "State Tax", - shipping: true, - order: 45 - }, - { - country: "US", - state: "WV", - rate: "6.0000", - name: "State Tax", - shipping: true, - order: 46 - }, - { - country: "US", - state: "WI", - rate: "5.0000", - name: "State Tax", - shipping: true, - order: 47 - }, - { - country: "US", - state: "WY", - rate: "4.0000", - name: "State Tax", - shipping: true, - order: 48 - } - ]; - -module.exports = { - getTaxRateExamples, - allUSTaxesExample -}; diff --git a/plugins/woocommerce/tests/api-core-tests/global-setup.js b/plugins/woocommerce/tests/api-core-tests/global-setup.js deleted file mode 100644 index 33c8c545027..00000000000 --- a/plugins/woocommerce/tests/api-core-tests/global-setup.js +++ /dev/null @@ -1,251 +0,0 @@ -const { DISABLE_HPOS, GITHUB_TOKEN, UPDATE_WC } = process.env; -const { downloadZip, deleteZip } = require( './utils/plugin-utils' ); -const axios = require( 'axios' ).default; -const playwrightConfig = require( './playwright.config' ); -const { site } = require( './utils' ); - -/** - * - * @param {import('@playwright/test').FullConfig} config - */ -module.exports = async ( config ) => { - // If API_BASE_URL is configured and doesn't include localhost, running on daily host - if ( - process.env.API_BASE_URL && - ! process.env.API_BASE_URL.includes( 'localhost' ) - ) { - const { chromium, expect } = require( '@playwright/test' ); - - const { baseURL, userAgent } = config.projects[ 0 ].use; - const contextOptions = { baseURL, userAgent }; - - const browser = await chromium.launch(); - const setupContext = await browser.newContext( contextOptions ); - const setupPage = await setupContext.newPage(); - - const getWCDownloadURL = async () => { - const requestConfig = { - method: 'get', - url: 'https://api.github.com/repos/woocommerce/woocommerce/releases', - headers: { - Accept: 'application/vnd.github+json', - }, - params: { - per_page: 100, - }, - }; - if ( GITHUB_TOKEN ) { - requestConfig.headers.Authorization = `Bearer ${ GITHUB_TOKEN }`; - } - const response = await axios( requestConfig ).catch( ( error ) => { - if ( error.response ) { - console.log( error.response.data ); - } - throw new Error( error.message ); - } ); - const releaseWithTagName = response.data.find( - ( { tag_name } ) => tag_name === UPDATE_WC - ); - if ( ! releaseWithTagName ) { - throw new Error( - `No release with tag_name="${ UPDATE_WC }" found. If "${ UPDATE_WC }" is a draft release, make sure to specify a GITHUB_TOKEN environment variable.` - ); - } - const wcZipAsset = releaseWithTagName.assets.find( ( { name } ) => - name.match( /^woocommerce(-trunk-nightly)?\.zip$/ ) - ); - if ( wcZipAsset ) { - return GITHUB_TOKEN - ? wcZipAsset.url - : wcZipAsset.browser_download_url; - } - throw new Error( - `WooCommerce release with tag "${ UPDATE_WC }" found, but does not have a WooCommerce ZIP asset.` - ); - }; - - const url = await getWCDownloadURL(); - const params = { url }; - - if ( GITHUB_TOKEN ) { - params.authorizationToken = GITHUB_TOKEN; - } - - const woocommerceZipPath = await downloadZip( params ); - - let adminLoggedIn = false; - let pluginActive = false; - - console.log( '--------------------------------------' ); - console.log( 'Running daily tests, resetting site...' ); - console.log( '--------------------------------------' ); - - const adminRetries = 5; - for ( let i = 0; i < adminRetries; i++ ) { - try { - console.log( 'Trying to log-in as admin...' ); - await setupPage.goto( '/wp-admin' ); - await setupPage - .locator( 'input[name="log"]' ) - .fill( process.env.USER_KEY ); - await setupPage - .locator( 'input[name="pwd"]' ) - .fill( process.env.USER_SECRET ); - await setupPage.locator( 'text=Log In' ).click(); - - await expect( setupPage.locator( 'div.wrap > h1' ) ).toHaveText( - 'Dashboard' - ); - console.log( 'Logged-in as admin successfully.' ); - adminLoggedIn = true; - break; - } catch ( e ) { - console.log( - `Admin log-in failed, Retrying... ${ i }/${ adminRetries }` - ); - console.log( e ); - } - } - - if ( ! adminLoggedIn ) { - console.error( - 'Cannot proceed api test, as admin login failed. Please check if the test site has been setup correctly.' - ); - process.exit( 1 ); - } - - await setupPage.goto( 'wp-admin/plugins.php' ); - await expect( setupPage.locator( 'div.wrap > h1' ) ).toHaveText( - 'Plugins' - ); - - console.log( 'Deactivating WooCommerce Plugin...' ); - await setupPage.locator( '#deactivate-woocommerce' ).click(); - await expect( setupPage.locator( 'div#message' ) ).toHaveText( - 'Plugin deactivated.Dismiss this notice.' - ); - - console.log( 'Deleting WooCommerce Plugin...' ); - setupPage.on( 'dialog', ( dialog ) => dialog.accept() ); - await setupPage.locator( '#delete-woocommerce' ).click(); - await expect( setupPage.locator( '#woocommerce-deleted' ) ).toHaveText( - 'WooCommerce was successfully deleted.' - ); - - for ( let i = 0; i < adminRetries; i++ ) { - try { - console.log( 'Reinstalling WooCommerce Plugin...' ); - await setupPage.goto( 'wp-admin/plugin-install.php' ); - await setupPage.locator( 'a.upload-view-toggle' ).click(); - await expect( - setupPage.locator( 'p.install-help' ) - ).toBeVisible(); - await expect( - setupPage.locator( 'p.install-help' ) - ).toContainText( - 'If you have a plugin in a .zip format, you may install or update it by uploading it here' - ); - const [ fileChooser ] = await Promise.all( [ - setupPage.waitForEvent( 'filechooser' ), - setupPage.locator( '#pluginzip' ).click(), - ] ); - await fileChooser.setFiles( woocommerceZipPath ); - console.log( 'Uploading nightly build...' ); - await setupPage - .locator( '#install-plugin-submit' ) - .click( { timeout: 60000 } ); - await setupPage.waitForLoadState( 'networkidle', { - timeout: 60000, - } ); - await expect( - setupPage.getByRole( - 'link', - { name: 'Activate Plugin' }, - { timeout: 60000 } - ) - ).toBeVisible(); - console.log( 'Activating Plugin...' ); - await setupPage - .getByRole( 'link', { name: 'Activate Plugin' } ) - .click( { timeout: 60000 } ); - pluginActive = true; - break; - } catch ( e ) { - console.log( - `Installing and activating plugin failed, Retrying... ${ i }/${ adminRetries }` - ); - console.log( e ); - } - } - if ( ! pluginActive ) { - console.error( - 'Cannot proceed api test, as installing WC failed. Please check if the test site has been setup correctly.' - ); - process.exit( 1 ); - } - - console.log( 'WooCommerce Re-installed.' ); - await expect( - setupPage.getByRole( 'heading', { name: 'Welcome to Woo!' } ) - ).toBeVisible(); - - await deleteZip( woocommerceZipPath ); - - // Might need to update the database - await setupPage.goto( 'wp-admin/plugins.php' ); - const updateButton = setupPage.locator( - 'text=Update WooCommerce Database' - ); - const updateCompleteMessage = setupPage.locator( - 'text=WooCommerce database update complete.' - ); - await expect( setupPage.locator( 'div.wrap > h1' ) ).toHaveText( - 'Plugins' - ); - if ( await updateButton.isVisible() ) { - console.log( 'Database update button present. Click it.' ); - await updateButton.click( { timeout: 60000 } ); - await expect( updateCompleteMessage ).toBeVisible(); - } else { - console.log( 'No DB update needed' ); - } - } else { - // running on localhost using wp-env so ensure HPOS is set if DISABLE_HPOS env variable is passed - if ( DISABLE_HPOS ) { - let hposConfigured = false; - const value = DISABLE_HPOS === '1' ? 'no' : 'yes'; - try { - const auth = { - username: playwrightConfig.userKey, - password: playwrightConfig.userSecret, - }; - const hposResponse = await axios.post( - playwrightConfig.use.baseURL + - '/wp-json/wc/v3/settings/advanced/woocommerce_custom_orders_table_enabled', - { value }, - { auth } - ); - if ( hposResponse.data.value === value ) { - console.log( - `HPOS Switched ${ - value === 'yes' ? 'on' : 'off' - } successfully` - ); - hposConfigured = true; - } - } catch ( error ) { - console.log( 'HPOS setup failed.' ); - console.log( error ); - process.exit( 1 ); - } - if ( ! hposConfigured ) { - console.error( - 'Cannot proceed to api tests, HPOS configuration failed. Please check if the correct DISABLE_HPOS value was used and the test site has been setup correctly.' - ); - process.exit( 1 ); - } - } - - await site.useCartCheckoutShortcodes( config ); - } -}; diff --git a/plugins/woocommerce/tests/api-core-tests/playwright.config.js b/plugins/woocommerce/tests/api-core-tests/playwright.config.js deleted file mode 100644 index 6a3c9207974..00000000000 --- a/plugins/woocommerce/tests/api-core-tests/playwright.config.js +++ /dev/null @@ -1,71 +0,0 @@ -const { devices } = require( '@playwright/test' ); -require( 'dotenv' ).config( { path: __dirname + '/.env' } ); - -const { API_BASE_URL, CI, DEFAULT_TIMEOUT_OVERRIDE, USER_KEY, USER_SECRET } = - process.env; - -const baseURL = API_BASE_URL ?? 'http://localhost:8086'; -const userKey = USER_KEY ?? 'admin'; -const userSecret = USER_SECRET ?? 'password'; -const base64auth = btoa( `${ userKey }:${ userSecret }` ); - -const config = { - userKey, - userSecret, - timeout: DEFAULT_TIMEOUT_OVERRIDE - ? Number( DEFAULT_TIMEOUT_OVERRIDE ) - : 90 * 1000, - expect: { timeout: 20 * 1000 }, - globalSetup: require.resolve( './global-setup' ), - outputDir: './test-results/report', - testDir: 'tests', - retries: CI ? 4 : 2, - workers: 4, - reporter: [ - [ 'list' ], - [ - 'html', - { - outputFolder: - process.env.PLAYWRIGHT_HTML_REPORT ?? - './test-results/playwright-report', - open: CI ? 'never' : 'always', - }, - ], - [ - 'allure-playwright', - { - outputFolder: - process.env.ALLURE_RESULTS_DIR ?? - './tests/api-core-tests/test-results/allure-results', - }, - ], - [ - 'json', - { - outputFile: - process.env.PLAYWRIGHT_JSON_OUTPUT_NAME ?? - './test-results/test-results.json', - }, - ], - ], - use: { - screenshot: 'only-on-failure', - video: 'on-first-retry', - trace: 'retain-on-failure', - viewport: { width: 1280, height: 720 }, - baseURL, - extraHTTPHeaders: { - // Add authorization token to all requests. - Authorization: `Basic ${ base64auth }`, - }, - }, - projects: [ - { - name: 'Chrome', - use: { ...devices[ 'Desktop Chrome' ] }, - }, - ], -}; - -module.exports = config; diff --git a/plugins/woocommerce/tests/api-core-tests/tests/reports/reports-crud.test.js b/plugins/woocommerce/tests/api-core-tests/tests/reports/reports-crud.test.js deleted file mode 100644 index 2766df5af22..00000000000 --- a/plugins/woocommerce/tests/api-core-tests/tests/reports/reports-crud.test.js +++ /dev/null @@ -1,407 +0,0 @@ -const { - test, - expect -} = require('@playwright/test'); - -/** - * Tests for the WooCommerce Refunds API. - * - * @group api - * @group reports - * - */ -test.describe('Reports API tests', () => { - - test('can view all reports', async ({ - request - }) => { - // call API to retrieve the reports - const response = await request.get('/wp-json/wc/v3/reports'); - const responseJSON = await response.json(); - expect(response.status()).toEqual(200); - expect(Array.isArray(responseJSON)).toBe(true); - - - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "sales", - "description": "List of sales reports.", - }) - ])); - - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "sales", - "description": "List of sales reports.", - }) - ])); - - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "sales", - "description": "List of sales reports.", - }) - ])); - - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "sales", - "description": "List of sales reports.", - }) - ])); - - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "sales", - "description": "List of sales reports.", - }) - ])); - - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "sales", - "description": "List of sales reports.", - }) - ])); - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "sales", - "description": "List of sales reports.", - }) - ])); - - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "sales", - "description": "List of sales reports.", - }) - ])); - - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "sales", - "description": "List of sales reports.", - }) - ])); - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "sales", - "description": "List of sales reports.", - }) - ])); - - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "sales", - "description": "List of sales reports.", - }) - ])); - - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "sales", - "description": "List of sales reports.", - }) - ])); - }); - - test('can view sales reports', async ({ - request - }) => { - // call API to retrieve the sales reports - const response = await request.get('/wp-json/wc/v3/reports/sales'); - const responseJSON = await response.json(); - expect(response.status()).toEqual(200); - expect(Array.isArray(responseJSON)).toBe(true); - - const today = new Date(); - const dd = String(today.getDate()).padStart(2, '0'); - const mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0! - const yyyy = today.getFullYear(); - const dateString = yyyy + '-' + mm + '-' + dd; - - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "total_sales": expect.any(String), - "net_sales": expect.any(String), - "average_sales": expect.any(String), - "total_orders": expect.any(Number), - "total_items": expect.any(Number), - "total_tax": expect.any(String), - "total_shipping": expect.any(String), - "total_refunds": expect.any(Number), - "total_discount": expect.any(String), - "totals_grouped_by": "day", - "totals": expect.objectContaining({ - [dateString]: { - "sales": expect.any(String), - "orders": expect.any(Number), - "items": expect.any(Number), - "tax": expect.any(String), - "shipping": expect.any(String), - "discount": expect.any(String), - "customers": expect.any(Number) - } - }), - "total_customers": expect.any(Number), - }) - ])); - }); - - test('can view top sellers reports', async ({ - request - }) => { - // call API to retrieve the top sellers - const response = await request.get('/wp-json/wc/v3/reports/top_sellers'); - const responseJSON = await response.json(); - expect(response.status()).toEqual(200); - expect(Array.isArray(responseJSON)).toBe(true); - - expect(responseJSON).toEqual( - expect.arrayContaining([])); - }); - - test('can view coupons totals', async ({ - request - }) => { - // call API to retrieve the coupons totals - const response = await request.get('/wp-json/wc/v3/reports/coupons/totals'); - const responseJSON = await response.json(); - expect(response.status()).toEqual(200); - expect(Array.isArray(responseJSON)).toBe(true); - - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "percent", - "name": "Percentage discount", - "total": expect.any(Number) - }) - ])); - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "fixed_cart", - "name": "Fixed cart discount", - "total": expect.any(Number) - }) - ])); - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "fixed_product", - "name": "Fixed product discount", - "total": expect.any(Number) - }) - ])); - }); - - test('can view customers totals', async ({ - request - }) => { - // call API to retrieve the customers totals - const response = await request.get('/wp-json/wc/v3/reports/customers/totals'); - const responseJSON = await response.json(); - expect(response.status()).toEqual(200); - expect(Array.isArray(responseJSON)).toBe(true); - - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "paying", - "name": "Paying customer", - "total": expect.any(Number) - }) - ])); - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "non_paying", - "name": "Non-paying customer", - "total": expect.any(Number) - }) - ])); - }); - - test('can view orders totals', async ({ - request - }) => { - // call API to retrieve the orders totals - const response = await request.get('/wp-json/wc/v3/reports/orders/totals'); - const responseJSON = await response.json(); - expect(response.status()).toEqual(200); - expect(Array.isArray(responseJSON)).toBe(true); - - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "pending", - "name": "Pending payment", - "total": expect.any(Number) - }) - ])); - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "processing", - "name": "Processing", - "total": expect.any(Number) - }) - ])); - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "on-hold", - "name": "On hold", - "total": expect.any(Number) - }) - ])); - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "completed", - "name": "Completed", - "total": expect.any(Number) - }) - ])); - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "cancelled", - "name": "Cancelled", - "total": expect.any(Number) - }) - ])); - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "refunded", - "name": "Refunded", - "total": expect.any(Number) - }) - ])); - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "failed", - "name": "Failed", - "total": expect.any(Number) - }) - ])); - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "checkout-draft", - "name": "Draft", - "total": expect.any(Number) - }) - ])); - }); - - test('can view products totals', async ({ - request - }) => { - // call API to retrieve the products totals - const response = await request.get('/wp-json/wc/v3/reports/products/totals'); - const responseJSON = await response.json(); - expect(response.status()).toEqual(200); - expect(Array.isArray(responseJSON)).toBe(true); - - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "external", - "name": "External/Affiliate product", - "total": expect.any(Number) - }) - ])); - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "grouped", - "name": "Grouped product", - "total": expect.any(Number) - }) - ])); - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "simple", - "name": "Simple product", - "total": expect.any(Number) - }) - ])); - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "variable", - "name": "Variable product", - "total": expect.any(Number) - }) - ])); - }); - - test('can view reviews totals', async ({ - request - }) => { - // call API to retrieve the reviews totals - const response = await request.get('/wp-json/wc/v3/reports/reviews/totals'); - const responseJSON = await response.json(); - expect(response.status()).toEqual(200); - expect(Array.isArray(responseJSON)).toBe(true); - - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "rated_1_out_of_5", - "name": "Rated 1 out of 5", - "total": expect.any(Number) - }) - ])); - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "rated_2_out_of_5", - "name": "Rated 2 out of 5", - "total": expect.any(Number) - }) - ])); - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "rated_3_out_of_5", - "name": "Rated 3 out of 5", - "total": expect.any(Number) - }) - ])); - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "rated_4_out_of_5", - "name": "Rated 4 out of 5", - "total": expect.any(Number) - }) - ])); - expect(responseJSON).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - "slug": "rated_5_out_of_5", - "name": "Rated 5 out of 5", - "total": expect.any(Number) - }) - ])); - }); -}); diff --git a/plugins/woocommerce/tests/api-core-tests/utils/api.js b/plugins/woocommerce/tests/api-core-tests/utils/api.js deleted file mode 100644 index f318657969c..00000000000 --- a/plugins/woocommerce/tests/api-core-tests/utils/api.js +++ /dev/null @@ -1,431 +0,0 @@ -const wcApi = require( '@woocommerce/woocommerce-rest-api' ).default; -const { async } = require( 'regenerator-runtime' ); -const config = require( '../playwright.config' ); - -let api; - -// Ensure that global-setup.js runs before creating api client -if ( process.env.CONSUMER_KEY && process.env.CONSUMER_SECRET ) { - api = new wcApi( { - url: config.use.baseURL, - consumerKey: process.env.CONSUMER_KEY, - consumerSecret: process.env.CONSUMER_SECRET, - version: 'wc/v3', - } ); -} - -/** - * Allow explicit construction of api client. - */ -const constructWith = ( consumerKey, consumerSecret ) => { - api = new wcApi( { - url: config.use.baseURL, - consumerKey, - consumerSecret, - version: 'wc/v3', - } ); -}; - -const throwCustomError = ( - error, - customMessage = 'Something went wrong. See details below.' -) => { - throw new Error( - customMessage - .concat( - `\nResponse status: ${ error.response.status } ${ error.response.statusText }` - ) - .concat( - `\nResponse headers:\n${ JSON.stringify( - error.response.headers, - null, - 2 - ) }` - ).concat( `\nResponse data:\n${ JSON.stringify( - error.response.data, - null, - 2 - ) } -` ) - ); -}; - -const update = { - storeDetails: async ( store ) => { - const res = await api.post( 'settings/general/batch', { - update: [ - { - id: 'woocommerce_store_address', - value: store.address, - }, - { - id: 'woocommerce_store_city', - value: store.city, - }, - { - id: 'woocommerce_default_country', - value: store.countryCode, - }, - { - id: 'woocommerce_store_postcode', - value: store.zip, - }, - ], - } ); - }, - enableCashOnDelivery: async () => { - await api.put( 'payment_gateways/cod', { - enabled: true, - } ); - }, - disableCashOnDelivery: async () => { - await api.put( 'payment_gateways/cod', { - enabled: false, - } ); - }, -}; - -const get = { - coupons: async ( params ) => { - const response = await api - .get( 'coupons', params ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when trying to list all coupons.' - ); - } ); - - return response.data; - }, - defaultCountry: async () => { - const response = await api.get( - 'settings/general/woocommerce_default_country' - ); - - const code = response.data.default; - - return code; - }, - orders: async ( params ) => { - const response = await api - .get( 'orders', params ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when trying to list all orders.' - ); - } ); - - return response.data; - }, - products: async ( params ) => { - const response = await api - .get( 'products', params ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when trying to list all products.' - ); - } ); - - return response.data; - }, - productAttributes: async ( params ) => { - const response = await api - .get( 'products/attributes', params ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when trying to list all product attributes.' - ); - } ); - - return response.data; - }, - productCategories: async ( params ) => { - const response = await api - .get( 'products/categories', params ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when trying to list all product categories.' - ); - } ); - - return response.data; - }, - productTags: async ( params ) => { - const response = await api - .get( 'products/tags', params ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when trying to list all product tags.' - ); - } ); - - return response.data; - }, - shippingClasses: async ( params ) => { - const response = await api - .get( 'products/shipping_classes', params ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when trying to list all shipping classes.' - ); - } ); - - return response.data; - }, - - shippingZones: async ( params ) => { - const response = await api - .get( 'shipping/zones', params ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when trying to list all shipping zones.' - ); - } ); - - return response.data; - }, - shippingZoneMethods: async ( shippingZoneId ) => { - const response = await api - .get( `shipping/zones/${ shippingZoneId }/methods` ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - `Something went wrong when trying to list all shipping methods in shipping zone ${ shippingZoneId }.` - ); - } ); - - return response.data; - }, - taxClasses: async () => { - const response = await api - .get( 'taxes/classes' ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when trying to list all tax classes.' - ); - } ); - - return response.data; - }, - taxRates: async ( params ) => { - const response = await api - .get( 'taxes', params ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when trying to list all tax rates.' - ); - } ); - - return response.data; - }, -}; - -const create = { - product: async ( product ) => { - const response = await api.post( 'products', product ); - - return response.data.id; - }, - /** - * Batch create product variations. - * - * @see {@link [Batch update product variations](https://woocommerce.github.io/woocommerce-rest-api-docs/#batch-update-product-variations)} - * @param {number|string} productId Product ID to add variations to - * @param {object[]} variations Array of variations to add. See [Product variation properties](https://woocommerce.github.io/woocommerce-rest-api-docs/#product-variation-properties) - * @returns {Promise} Array of variation ID's. - */ - productVariations: async ( productId, variations ) => { - const response = await api.post( - `products/${ productId }/variations/batch`, - { - create: variations, - } - ); - - return response.data.create.map( ( { id } ) => id ); - }, -}; - -const deletePost = { - coupons: async ( ids ) => { - const res = await api - .post( 'coupons/batch', { delete: ids } ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when batch deleting coupons.' - ); - } ); - - return res.data; - }, - product: async ( id ) => { - await api.delete( `products/${ id }`, { - force: true, - } ); - }, - products: async ( ids ) => { - const res = await api - .post( 'products/batch', { delete: ids } ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when batch deleting products.' - ); - } ); - return res.data; - }, - productAttributes: async ( id ) => { - const res = await api - .post( 'products/attributes/batch', { delete: id } ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when batch deleting product attributes.' - ); - } ); - return res.data; - }, - productCategories: async ( ids ) => { - const res = await api - .post( 'products/categories/batch', { delete: ids } ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when batch deleting product categories.' - ); - } ); - return res.data; - }, - productTags: async ( ids ) => { - const res = await api - .post( 'products/tags/batch', { delete: ids } ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when batch deleting product tags.' - ); - } ); - return res.data; - }, - order: async ( id ) => { - await api.delete( `orders/${ id }`, { - force: true, - } ); - }, - orders: async ( ids ) => { - const res = await api - .post( 'orders/batch', { delete: ids } ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when batch deleting orders.' - ); - } ); - return res.data; - }, - shippingClasses: async ( ids ) => { - const res = await api - .post( 'products/shipping_classes/batch', { delete: ids } ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when batch deleting shipping classes.' - ); - } ); - return res.data; - }, - shippingZone: async ( id ) => { - const res = await api - .delete( `shipping/zones/${ id }`, { - force: true, - } ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when deleting shipping zone.' - ); - } ); - return res.data; - }, - shippingZoneMethod: async ( shippingZoneId, shippingMethodId ) => { - const res = await api - .delete( - `shipping/zones/${ shippingZoneId }/methods/${ shippingMethodId }`, - { - force: true, - } - ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when deleting shipping zone method.' - ); - } ); - return res.data; - }, - taxClass: async ( slug ) => { - const res = await api - .delete( `taxes/classes/${ slug }`, { - force: true, - } ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - `Something went wrong when deleting tax class ${ slug }.` - ); - } ); - return res.data; - }, - taxRates: async ( ids ) => { - const res = await api - .post( 'taxes/batch', { delete: ids } ) - .then( ( response ) => response ) - .catch( ( error ) => { - throwCustomError( - error, - 'Something went wrong when batch deleting tax rates.' - ); - } ); - return res.data; - }, -}; - -module.exports = { - update, - get, - create, - deletePost, - constructWith, -}; diff --git a/plugins/woocommerce/tests/api-core-tests/utils/index.js b/plugins/woocommerce/tests/api-core-tests/utils/index.js deleted file mode 100644 index 6f630c49a0e..00000000000 --- a/plugins/woocommerce/tests/api-core-tests/utils/index.js +++ /dev/null @@ -1,6 +0,0 @@ -const api = require( './api' ); -const site = require( './site' ); -module.exports = { - api, - site, -}; diff --git a/plugins/woocommerce/tests/api-core-tests/utils/plugin-utils.js b/plugins/woocommerce/tests/api-core-tests/utils/plugin-utils.js deleted file mode 100644 index c147e2565b0..00000000000 --- a/plugins/woocommerce/tests/api-core-tests/utils/plugin-utils.js +++ /dev/null @@ -1,366 +0,0 @@ -const { APIRequest, expect } = require( '@playwright/test' ); -const axios = require( 'axios' ).default; -const fs = require( 'fs' ); -const path = require( 'path' ); -const { promisify } = require( 'util' ); -const execAsync = promisify( require( 'child_process' ).exec ); - -/** - * GitHub [release asset](https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28) object. - * @typedef {Object} ReleaseAsset - * @property {string} name - * @property {string} url - */ - -/** - * GitHub [release](https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28) object. - * @typedef {Object} Release - * @property {ReleaseAsset[]} assets - * @property {string} tag_name - * @property {string} name - */ - -/** - * Encode basic auth username and password to be used in HTTP Authorization header. - * - * @param {string} username - * @param {string} password - * @returns Base64-encoded string - */ -const encodeCredentials = ( username, password ) => { - return Buffer.from( `${ username }:${ password }` ).toString( 'base64' ); -}; - -/** - * Deactivate and delete a plugin specified by the given `slug` using the WordPress API. - * - * @param {object} params - * @param {APIRequest} params.request - * @param {string} params.baseURL - * @param {string} params.slug - * @param {string} params.username - * @param {string} params.password - */ -export const deletePlugin = async ( { - request, - baseURL, - slug, - username, - password, -} ) => { - // Check if plugin is installed by getting the list of installed plugins, and then finding the one whose `textdomain` property equals `slug`. - const apiContext = await request.newContext( { - baseURL, - extraHTTPHeaders: { - Authorization: `Basic ${ encodeCredentials( username, password ) }`, - cookie: '', - }, - } ); - const listPluginsResponse = await apiContext.get( - `/wp-json/wp/v2/plugins`, - { - failOnStatusCode: true, - } - ); - const pluginsList = await listPluginsResponse.json(); - const pluginToDelete = pluginsList.find( - ( { textdomain } ) => textdomain === slug - ); - - // If installed, get its `plugin` value and use it to deactivate and delete it. - if ( pluginToDelete ) { - const { plugin } = pluginToDelete; - const requestURL = `/wp-json/wp/v2/plugins/${ plugin }`; - - await apiContext.put( requestURL, { - data: { status: 'inactive' }, - } ); - - await apiContext.delete( requestURL ); - } -}; - -/** - * Download the zip file from a remote location. - * - * @param {object} param - * @param {string} param.url - * @param {string} param.repository - * @param {string} param.authorizationToken - * @param {boolean} param.prerelease - * @param {string} param.downloadDir - * - * @param {string} url The URL where the zip file is located. Takes precedence over `repository`. - * @param {string} repository The repository owner and name. For example: `woocommerce/woocommerce`. Ignored when `url` was given. - * @param {string} authorizationToken Authorization token used to authenticate with the GitHub API if required. - * @param {boolean} prerelease Flag on whether to get a prelease or not. Default `false`. - * @param {string} downloadDir Relative path to the download directory. Non-existing folders will be auto-created. Defaults to `tmp` under current working directory. - * - * @return {string} Absolute path to the downloaded zip. - */ -export const downloadZip = async ( { - url, - repository, - authorizationToken, - prerelease = false, - downloadDir = 'tmp', -} ) => { - let zipFilename = path.basename( url || repository ); - zipFilename = zipFilename.endsWith( '.zip' ) - ? zipFilename - : zipFilename.concat( '.zip' ); - const zipFilePath = path.resolve( downloadDir, zipFilename ); - - let response; - - // Create destination folder. - fs.mkdirSync( downloadDir, { recursive: true } ); - - const downloadURL = - url ?? - ( await getLatestReleaseZipUrl( { - repository, - authorizationToken, - prerelease, - } ) ); - - // Download the zip. - const options = { - method: 'get', - url: downloadURL, - responseType: 'stream', - headers: { - Authorization: authorizationToken - ? `token ${ authorizationToken }` - : '', - Accept: 'application/octet-stream', - }, - }; - - response = await axios( options ).catch( ( error ) => { - if ( error.response ) { - console.error( error.response.data ); - } - throw new Error( error.message ); - } ); - - response.data.pipe( fs.createWriteStream( zipFilePath ) ); - - return zipFilePath; -}; - -/** - * Delete a zip file. Useful when cleaning up downloaded plugin zips. - * - * @param {string} zipFilePath Local file path to the ZIP. - */ -export const deleteZip = async ( zipFilePath ) => { - await fs.unlink( zipFilePath, ( err ) => { - if ( err ) throw err; - } ); -}; - -/** - * Get the download URL of the latest release zip for a plugin using GitHub API. - * - * @param {{repository: string, authorizationToken: string, prerelease: boolean, perPage: number}} param - * @param {string} repository The repository owner and name. For example: `woocommerce/woocommerce`. - * @param {string} authorizationToken Authorization token used to authenticate with the GitHub API if required. - * @param {boolean} prerelease Flag on whether to get a prelease or not. - * @param {number} perPage Limit of entries returned from the latest releases list, defaults to 3. - * @return {string} Download URL for the release zip file. - */ -export const getLatestReleaseZipUrl = async ( { - repository, - authorizationToken, - prerelease = false, - perPage = 3, -} ) => { - let release; - - const requesturl = prerelease - ? `https://api.github.com/repos/${ repository }/releases?per_page=${ perPage }` - : `https://api.github.com/repos/${ repository }/releases/latest`; - - const options = { - method: 'get', - url: requesturl, - headers: { - Authorization: authorizationToken - ? `token ${ authorizationToken }` - : '', - }, - }; - - // Get the first prerelease, or the latest release. - let response; - try { - response = await axios( options ); - } catch ( error ) { - let errorMessage = - 'Something went wrong when downloading the plugin.\n'; - - if ( error.response ) { - // The request was made and the server responded with a status code - // that falls out of the range of 2xx - errorMessage = errorMessage.concat( - `Response status: ${ error.response.status } ${ error.response.statusText }`, - '\n', - `Response body:`, - '\n', - JSON.stringify( error.response.data, null, 2 ), - '\n' - ); - } else if ( error.request ) { - // The request was made but no response was received - // `error.request` is an instance of XMLHttpRequest in the browser and an instance of - // http.ClientRequest in node.js - errorMessage = errorMessage.concat( - JSON.stringify( error.request, null, 2 ), - '\n' - ); - } else { - // Something happened in setting up the request that triggered an Error - errorMessage = errorMessage.concat( error.toJSON(), '\n' ); - } - - throw new Error( errorMessage ); - } - - release = prerelease - ? response.data.find( ( { prerelease } ) => prerelease ) - : response.data; - - // If response contains assets, return URL of first asset. - // Otherwise, return the github.com URL from the tag name. - const { assets } = release; - if ( assets && assets.length ) { - return assets[ 0 ].url; - } else { - const tagName = release.tag_name; - return `https://github.com/${ repository }/archive/${ tagName }.zip`; - } -}; - -/** - * Install a plugin using WP CLI within a WP ENV environment. - * This is a workaround to the "The uploaded file exceeds the upload_max_filesize directive in php.ini" error encountered when uploading a plugin to the local WP Env E2E environment through the UI. - * - * @see https://github.com/WordPress/gutenberg/issues/29430 - * - * @param {string} pluginPath - */ -export const installPluginThruWpCli = async ( pluginPath ) => { - const runWpCliCommand = async ( command ) => { - const { stdout, stderr } = await execAsync( - `pnpm exec wp-env run tests-cli -- ${ command }` - ); - - console.log( stdout ); - console.error( stderr ); - }; - - const wpEnvPluginPath = pluginPath.replace( - /.*\/plugins\/woocommerce/, - 'wp-content/plugins/woocommerce' - ); - - await runWpCliCommand( `ls ${ wpEnvPluginPath }` ); - - await runWpCliCommand( - `wp plugin install --activate --force ${ wpEnvPluginPath }` - ); - - await runWpCliCommand( `wp plugin list` ); -}; - -/** - * Download the WooCommerce release zip. Can download draft releases when `token` is specified. - * - * @param {Object} params - * @param {import("@playwright/test").APIRequestContext} params.request - * @param {string} params.version The version indicated in the release `tag_name` or `name` field. - * @param {string} params.token - * @param {string} params.downloadDir - * - * @throws When `version` was not found. - * - * @returns {Promise} Absolute path to the downloaded WooCommerce zip. - */ -export const downloadWooCommerceRelease = async ( { - request, - version = process.env.UPDATE_WC, - token = process.env.GITHUB_TOKEN, - downloadDir = 'tmp', -} ) => { - /** - * - * @returns {Promise} - */ - const getRelease = async () => { - const url = - 'https://api.github.com/repos/woocommerce/woocommerce/releases'; - const options = { - params: { - per_page: 100, - }, - headers: { - Authorization: token ? `Bearer ${ token }` : undefined, - }, - }; - const response = await request.get( url, options ); - - /** - * @type {Release[]} - */ - const releases = await response.json(); - - const match = releases.find( ( { tag_name, name } ) => - [ tag_name, name ].includes( version ) - ); - - if ( ! match ) { - throw new Error( `Release ${ version } not found!` ); - } - - return match; - }; - - /** - * - * @param {Release} release - * @throws When `release` does not contain a woocommerce zip. - * @returns {ReleaseAsset} - */ - const getWooCommerceZipAsset = ( release ) => { - const zipName = - version.toLowerCase() === 'nightly' - ? 'woocommerce-trunk-nightly.zip' - : 'woocommerce.zip'; - const asset = release.assets.find( ( { name } ) => name === zipName ); - - if ( ! asset ) { - throw new Error( - `Release ${ version } does not contain a WooCommerce ZIP asset` - ); - } - - return asset; - }; - - const release = await getRelease(); - const asset = getWooCommerceZipAsset( release ); - const downloadResponse = await request.get( asset.url, { - headers: { - Authorization: token ? `Bearer ${ token }` : undefined, - Accept: 'application/octet-stream', - }, - } ); - expect( downloadResponse.ok() ).toBeTruthy(); - const body = await downloadResponse.body(); - const zipPath = path.resolve( downloadDir, asset.name ); - fs.mkdirSync( path.resolve( downloadDir ), { recursive: true } ); - fs.writeFileSync( zipPath, body ); - - return zipPath; -}; diff --git a/plugins/woocommerce/tests/api-core-tests/utils/site.js b/plugins/woocommerce/tests/api-core-tests/utils/site.js deleted file mode 100644 index 1211c101b2a..00000000000 --- a/plugins/woocommerce/tests/api-core-tests/utils/site.js +++ /dev/null @@ -1,304 +0,0 @@ -const api = require( './api' ); - -const deleteAllCoupons = async () => { - console.log( 'Deleting all coupons...' ); - - let coupons, - page = 1; - - while ( - ( coupons = await api.get.coupons( { per_page: 100, page: page++ } ) ) - .length > 0 - ) { - const ids = coupons.map( ( { id } ) => id ); - await api.deletePost.coupons( ids ); - } - - console.log( 'Done.' ); -}; - -const deleteAllProducts = async () => { - console.log( 'Deleting all products...' ); - - let products, - page = 1; - - while ( - ( products = await api.get.products( { per_page: 100, page: page++ } ) ) - .length > 0 - ) { - const ids = products.map( ( { id } ) => id ); - await api.deletePost.products( ids ); - } - - console.log( 'Done.' ); -}; - -const deleteAllProductAttributes = async () => { - console.log( 'Deleting all product attributes...' ); - - let attributes, - page = 1; - - while ( - ( attributes = await api.get.productAttributes( { - per_page: 100, - page: page++, - } ) ).length > 0 - ) { - const ids = attributes.map( ( { id } ) => id ); - await api.deletePost.productAttributes( ids ); - } - - console.log( 'Done.' ); -}; - -const deleteAllProductCategories = async () => { - console.log( 'Deleting all product categories...' ); - - let categories, - page = 1; - - // Exclude "Uncategorized" as it cannot be deleted - while ( - ( categories = ( - await api.get.productCategories( { per_page: 100, page: page++ } ) - ).filter( ( { slug } ) => slug !== 'uncategorized' ) ).length > 0 - ) { - const ids = categories.map( ( { id } ) => id ); - await api.deletePost.productCategories( ids ); - } - - console.log( 'Done.' ); -}; - -const deleteAllProductTags = async () => { - console.log( 'Deleting all product tags...' ); - - let tags, - page = 1; - - while ( - ( tags = await api.get.productTags( { - per_page: 100, - page: page++, - } ) ).length > 0 - ) { - const ids = tags.map( ( { id } ) => id ); - await api.deletePost.productTags( ids ); - } - - console.log( 'Done.' ); -}; - -const deleteAllOrders = async () => { - console.log( 'Deleting all orders...' ); - - let orders, - page = 1; - - while ( - ( orders = await api.get.orders( { per_page: 100, page: page++ } ) ) - .length > 0 - ) { - const ids = orders.map( ( { id } ) => id ); - await api.deletePost.orders( ids ); - } - - console.log( 'Done.' ); -}; - -const deleteAllShippingZones = async () => { - console.log( 'Deleting all shipping zones...' ); - - let shippingZones, - page = 1; - - // Exclude "Locations not covered by your other zones" as it cannot be deleted. - while ( - ( shippingZones = ( - await api.get.shippingZones( { - per_page: 100, - page: page++, - } ) - ).filter( - ( { name } ) => name !== 'Locations not covered by your other zones' - ) ).length > 0 - ) { - const ids = shippingZones.map( ( { id } ) => id ); - for ( const id of ids ) { - await api.deletePost.shippingZone( id ); - } - } - - console.log( 'Done.' ); -}; - -const deleteAllShippingClasses = async () => { - console.log( 'Deleting all shipping classes...' ); - - let shippingClasses, - page = 1; - - while ( - ( shippingClasses = await api.get.shippingClasses( { - per_page: 100, - page: page++, - } ) ).length > 0 - ) { - const ids = shippingClasses.map( ( { id } ) => id ); - await api.deletePost.shippingClasses( ids ); - } - - console.log( 'Done.' ); -}; - -const deleteAllShippingMethodsInDefaultShippingZone = async () => { - console.log( 'Deleting all shipping methods...' ); - - let shippingMethods; - - while ( - ( shippingMethods = await api.get.shippingZoneMethods( 0 ) ).length > 0 - ) { - const ids = shippingMethods.map( ( { id } ) => id ); - for ( const id of ids ) { - await api.deletePost.shippingZoneMethod( 0, id ); - } - } - - console.log( 'Done.' ); -}; - -const deleteAllTaxClasses = async () => { - console.log( 'Deleting all non-default tax classes...' ); - - let taxClasses; - - const getExistingNonDefaultTaxClasses = async () => { - return ( await api.get.taxClasses() ).filter( - ( { slug } ) => - ! [ 'standard', 'reduced-rate', 'zero-rate' ].includes( slug ) - ); - }; - - while ( - ( taxClasses = await getExistingNonDefaultTaxClasses() ).length > 0 - ) { - const slugs = taxClasses.map( ( { slug } ) => slug ); - for ( const slug of slugs ) { - await api.deletePost.taxClass( slug ); - } - } - - console.log( 'Done.' ); -}; - -const deleteAllTaxRates = async () => { - console.log( 'Deleting all tax rates...' ); - - let taxes, - page = 1; - - while ( - ( taxes = await api.get.taxRates( { per_page: 100, page: page++ } ) ) - .length > 0 - ) { - const ids = taxes.map( ( { id } ) => id ); - await api.deletePost.taxRates( ids ); - } - - console.log( 'Done.' ); -}; - -/** - * Reset the test site. Useful when running E2E tests on a hosted test site to reset it to a somewhat pristine state prior to running tests. - * - * @param {string} cKey Consumer key - * @param {string} cSecret Consumer secret - */ -const reset = async ( cKey, cSecret ) => { - console.log( '--------------------------' ); - console.log( 'Resetting test site...' ); - console.log( '--------------------------' ); - - api.constructWith( cKey, cSecret ); - - await deleteAllCoupons(); - await deleteAllProducts(); - await deleteAllProductAttributes(); - await deleteAllProductCategories(); - await deleteAllProductTags(); - await deleteAllOrders(); - await deleteAllShippingClasses(); - await deleteAllShippingZones(); - await deleteAllShippingMethodsInDefaultShippingZone(); - await deleteAllTaxClasses(); - await deleteAllTaxRates(); -}; - -/** - * Convert Cart and Checkout pages to shortcode. - * @param {import('@playwright/test').FullConfig} config - */ -const useCartCheckoutShortcodes = async ( config ) => { - /** - * A WordPress page. - * @typedef {Object} WPPage - * @property {number} id - * @property {string} slug - */ - - const { request: apiRequest } = require( '@playwright/test' ); - const { baseURL, userAgent, extraHTTPHeaders } = config.projects[ 0 ].use; - - const options = { - baseURL, - userAgent, - extraHTTPHeaders, - }; - const request = await apiRequest.newContext( options ); - - // List all pages - const response_list = await request.get( '/wp-json/wp/v2/pages', { - data: { - _fields: [ 'id', 'slug' ], - }, - failOnStatusCode: true, - } ); - - /** - * @type {WPPage[]} - */ - const list = await response_list.json(); - - // Find the cart and checkout pages - const cart = list.find( ( page ) => page.slug === 'cart' ); - const checkout = list.find( ( page ) => page.slug === 'checkout' ); - - // Convert their contents to shortcodes - await request.put( `/wp-json/wp/v2/pages/${ cart.id }`, { - data: { - content: { - raw: '[woocommerce_cart]', - }, - }, - failOnStatusCode: true, - } ); - console.log( 'Cart page converted to shortcode.' ); - - await request.put( `/wp-json/wp/v2/pages/${ checkout.id }`, { - data: { - content: { - raw: '[woocommerce_checkout]', - }, - }, - failOnStatusCode: true, - } ); - console.log( 'Checkout page converted to shortcode.' ); -}; - -module.exports = { - reset, - useCartCheckoutShortcodes, -}; diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ad.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ad.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ad.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ad.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ae.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ae.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ae.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ae.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/af.json b/plugins/woocommerce/tests/e2e-pw/data/countries/af.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/af.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/af.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ag.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ag.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ag.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ag.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ai.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ai.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ai.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ai.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/al.json b/plugins/woocommerce/tests/e2e-pw/data/countries/al.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/al.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/al.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/am.json b/plugins/woocommerce/tests/e2e-pw/data/countries/am.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/am.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/am.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ao.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ao.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ao.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ao.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/aq.json b/plugins/woocommerce/tests/e2e-pw/data/countries/aq.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/aq.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/aq.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ar.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ar.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ar.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ar.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/as.json b/plugins/woocommerce/tests/e2e-pw/data/countries/as.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/as.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/as.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/at.json b/plugins/woocommerce/tests/e2e-pw/data/countries/at.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/at.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/at.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/au.json b/plugins/woocommerce/tests/e2e-pw/data/countries/au.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/au.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/au.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/aw.json b/plugins/woocommerce/tests/e2e-pw/data/countries/aw.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/aw.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/aw.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ax.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ax.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ax.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ax.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/az.json b/plugins/woocommerce/tests/e2e-pw/data/countries/az.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/az.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/az.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ba.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ba.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ba.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ba.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/bb.json b/plugins/woocommerce/tests/e2e-pw/data/countries/bb.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/bb.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/bb.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/bd.json b/plugins/woocommerce/tests/e2e-pw/data/countries/bd.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/bd.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/bd.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/be.json b/plugins/woocommerce/tests/e2e-pw/data/countries/be.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/be.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/be.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/bf.json b/plugins/woocommerce/tests/e2e-pw/data/countries/bf.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/bf.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/bf.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/bg.json b/plugins/woocommerce/tests/e2e-pw/data/countries/bg.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/bg.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/bg.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/bh.json b/plugins/woocommerce/tests/e2e-pw/data/countries/bh.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/bh.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/bh.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/bi.json b/plugins/woocommerce/tests/e2e-pw/data/countries/bi.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/bi.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/bi.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/bj.json b/plugins/woocommerce/tests/e2e-pw/data/countries/bj.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/bj.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/bj.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/bl.json b/plugins/woocommerce/tests/e2e-pw/data/countries/bl.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/bl.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/bl.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/bm.json b/plugins/woocommerce/tests/e2e-pw/data/countries/bm.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/bm.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/bm.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/bn.json b/plugins/woocommerce/tests/e2e-pw/data/countries/bn.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/bn.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/bn.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/bo.json b/plugins/woocommerce/tests/e2e-pw/data/countries/bo.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/bo.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/bo.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/bq.json b/plugins/woocommerce/tests/e2e-pw/data/countries/bq.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/bq.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/bq.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/br.json b/plugins/woocommerce/tests/e2e-pw/data/countries/br.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/br.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/br.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/bs.json b/plugins/woocommerce/tests/e2e-pw/data/countries/bs.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/bs.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/bs.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/bt.json b/plugins/woocommerce/tests/e2e-pw/data/countries/bt.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/bt.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/bt.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/bv.json b/plugins/woocommerce/tests/e2e-pw/data/countries/bv.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/bv.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/bv.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/bw.json b/plugins/woocommerce/tests/e2e-pw/data/countries/bw.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/bw.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/bw.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/by.json b/plugins/woocommerce/tests/e2e-pw/data/countries/by.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/by.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/by.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/bz.json b/plugins/woocommerce/tests/e2e-pw/data/countries/bz.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/bz.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/bz.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ca.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ca.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ca.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ca.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/cc.json b/plugins/woocommerce/tests/e2e-pw/data/countries/cc.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/cc.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/cc.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/cd.json b/plugins/woocommerce/tests/e2e-pw/data/countries/cd.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/cd.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/cd.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/cf.json b/plugins/woocommerce/tests/e2e-pw/data/countries/cf.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/cf.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/cf.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/cg.json b/plugins/woocommerce/tests/e2e-pw/data/countries/cg.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/cg.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/cg.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ch.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ch.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ch.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ch.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ci.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ci.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ci.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ci.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ck.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ck.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ck.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ck.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/cl.json b/plugins/woocommerce/tests/e2e-pw/data/countries/cl.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/cl.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/cl.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/cm.json b/plugins/woocommerce/tests/e2e-pw/data/countries/cm.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/cm.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/cm.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/cn.json b/plugins/woocommerce/tests/e2e-pw/data/countries/cn.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/cn.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/cn.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/co.json b/plugins/woocommerce/tests/e2e-pw/data/countries/co.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/co.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/co.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/cr.json b/plugins/woocommerce/tests/e2e-pw/data/countries/cr.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/cr.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/cr.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/cu.json b/plugins/woocommerce/tests/e2e-pw/data/countries/cu.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/cu.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/cu.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/cv.json b/plugins/woocommerce/tests/e2e-pw/data/countries/cv.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/cv.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/cv.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/cw.json b/plugins/woocommerce/tests/e2e-pw/data/countries/cw.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/cw.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/cw.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/cx.json b/plugins/woocommerce/tests/e2e-pw/data/countries/cx.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/cx.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/cx.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/cy.json b/plugins/woocommerce/tests/e2e-pw/data/countries/cy.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/cy.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/cy.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/cz.json b/plugins/woocommerce/tests/e2e-pw/data/countries/cz.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/cz.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/cz.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/de.json b/plugins/woocommerce/tests/e2e-pw/data/countries/de.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/de.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/de.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/dj.json b/plugins/woocommerce/tests/e2e-pw/data/countries/dj.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/dj.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/dj.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/dk.json b/plugins/woocommerce/tests/e2e-pw/data/countries/dk.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/dk.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/dk.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/dm.json b/plugins/woocommerce/tests/e2e-pw/data/countries/dm.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/dm.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/dm.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/do.json b/plugins/woocommerce/tests/e2e-pw/data/countries/do.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/do.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/do.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/dz.json b/plugins/woocommerce/tests/e2e-pw/data/countries/dz.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/dz.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/dz.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ec.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ec.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ec.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ec.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ee.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ee.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ee.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ee.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/eg.json b/plugins/woocommerce/tests/e2e-pw/data/countries/eg.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/eg.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/eg.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/eh.json b/plugins/woocommerce/tests/e2e-pw/data/countries/eh.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/eh.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/eh.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/er.json b/plugins/woocommerce/tests/e2e-pw/data/countries/er.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/er.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/er.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/es.json b/plugins/woocommerce/tests/e2e-pw/data/countries/es.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/es.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/es.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/et.json b/plugins/woocommerce/tests/e2e-pw/data/countries/et.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/et.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/et.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/fi.json b/plugins/woocommerce/tests/e2e-pw/data/countries/fi.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/fi.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/fi.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/fj.json b/plugins/woocommerce/tests/e2e-pw/data/countries/fj.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/fj.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/fj.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/fk.json b/plugins/woocommerce/tests/e2e-pw/data/countries/fk.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/fk.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/fk.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/fm.json b/plugins/woocommerce/tests/e2e-pw/data/countries/fm.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/fm.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/fm.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/fo.json b/plugins/woocommerce/tests/e2e-pw/data/countries/fo.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/fo.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/fo.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/fr.json b/plugins/woocommerce/tests/e2e-pw/data/countries/fr.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/fr.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/fr.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ga.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ga.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ga.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ga.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/gb.json b/plugins/woocommerce/tests/e2e-pw/data/countries/gb.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/gb.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/gb.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/gd.json b/plugins/woocommerce/tests/e2e-pw/data/countries/gd.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/gd.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/gd.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ge.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ge.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ge.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ge.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/gf.json b/plugins/woocommerce/tests/e2e-pw/data/countries/gf.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/gf.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/gf.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/gg.json b/plugins/woocommerce/tests/e2e-pw/data/countries/gg.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/gg.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/gg.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/gh.json b/plugins/woocommerce/tests/e2e-pw/data/countries/gh.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/gh.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/gh.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/gi.json b/plugins/woocommerce/tests/e2e-pw/data/countries/gi.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/gi.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/gi.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/gl.json b/plugins/woocommerce/tests/e2e-pw/data/countries/gl.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/gl.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/gl.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/gm.json b/plugins/woocommerce/tests/e2e-pw/data/countries/gm.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/gm.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/gm.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/gn.json b/plugins/woocommerce/tests/e2e-pw/data/countries/gn.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/gn.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/gn.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/gp.json b/plugins/woocommerce/tests/e2e-pw/data/countries/gp.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/gp.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/gp.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/gq.json b/plugins/woocommerce/tests/e2e-pw/data/countries/gq.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/gq.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/gq.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/gr.json b/plugins/woocommerce/tests/e2e-pw/data/countries/gr.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/gr.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/gr.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/gs.json b/plugins/woocommerce/tests/e2e-pw/data/countries/gs.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/gs.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/gs.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/gt.json b/plugins/woocommerce/tests/e2e-pw/data/countries/gt.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/gt.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/gt.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/gu.json b/plugins/woocommerce/tests/e2e-pw/data/countries/gu.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/gu.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/gu.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/gw.json b/plugins/woocommerce/tests/e2e-pw/data/countries/gw.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/gw.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/gw.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/gy.json b/plugins/woocommerce/tests/e2e-pw/data/countries/gy.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/gy.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/gy.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/hk.json b/plugins/woocommerce/tests/e2e-pw/data/countries/hk.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/hk.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/hk.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/hm.json b/plugins/woocommerce/tests/e2e-pw/data/countries/hm.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/hm.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/hm.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/hn.json b/plugins/woocommerce/tests/e2e-pw/data/countries/hn.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/hn.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/hn.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/hr.json b/plugins/woocommerce/tests/e2e-pw/data/countries/hr.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/hr.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/hr.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ht.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ht.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ht.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ht.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/hu.json b/plugins/woocommerce/tests/e2e-pw/data/countries/hu.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/hu.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/hu.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/id.json b/plugins/woocommerce/tests/e2e-pw/data/countries/id.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/id.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/id.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ie.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ie.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ie.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ie.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/il.json b/plugins/woocommerce/tests/e2e-pw/data/countries/il.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/il.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/il.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/im.json b/plugins/woocommerce/tests/e2e-pw/data/countries/im.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/im.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/im.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/in.json b/plugins/woocommerce/tests/e2e-pw/data/countries/in.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/in.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/in.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/io.json b/plugins/woocommerce/tests/e2e-pw/data/countries/io.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/io.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/io.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/iq.json b/plugins/woocommerce/tests/e2e-pw/data/countries/iq.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/iq.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/iq.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ir.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ir.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ir.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ir.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/is.json b/plugins/woocommerce/tests/e2e-pw/data/countries/is.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/is.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/is.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/it.json b/plugins/woocommerce/tests/e2e-pw/data/countries/it.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/it.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/it.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/je.json b/plugins/woocommerce/tests/e2e-pw/data/countries/je.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/je.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/je.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/jm.json b/plugins/woocommerce/tests/e2e-pw/data/countries/jm.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/jm.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/jm.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/jo.json b/plugins/woocommerce/tests/e2e-pw/data/countries/jo.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/jo.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/jo.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/jp.json b/plugins/woocommerce/tests/e2e-pw/data/countries/jp.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/jp.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/jp.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ke.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ke.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ke.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ke.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/kg.json b/plugins/woocommerce/tests/e2e-pw/data/countries/kg.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/kg.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/kg.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/kh.json b/plugins/woocommerce/tests/e2e-pw/data/countries/kh.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/kh.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/kh.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ki.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ki.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ki.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ki.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/km.json b/plugins/woocommerce/tests/e2e-pw/data/countries/km.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/km.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/km.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/kn.json b/plugins/woocommerce/tests/e2e-pw/data/countries/kn.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/kn.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/kn.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/kp.json b/plugins/woocommerce/tests/e2e-pw/data/countries/kp.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/kp.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/kp.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/kr.json b/plugins/woocommerce/tests/e2e-pw/data/countries/kr.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/kr.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/kr.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/kw.json b/plugins/woocommerce/tests/e2e-pw/data/countries/kw.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/kw.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/kw.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ky.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ky.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ky.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ky.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/kz.json b/plugins/woocommerce/tests/e2e-pw/data/countries/kz.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/kz.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/kz.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/la.json b/plugins/woocommerce/tests/e2e-pw/data/countries/la.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/la.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/la.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/lb.json b/plugins/woocommerce/tests/e2e-pw/data/countries/lb.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/lb.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/lb.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/lc.json b/plugins/woocommerce/tests/e2e-pw/data/countries/lc.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/lc.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/lc.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/li.json b/plugins/woocommerce/tests/e2e-pw/data/countries/li.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/li.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/li.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/lk.json b/plugins/woocommerce/tests/e2e-pw/data/countries/lk.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/lk.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/lk.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/lr.json b/plugins/woocommerce/tests/e2e-pw/data/countries/lr.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/lr.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/lr.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ls.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ls.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ls.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ls.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/lt.json b/plugins/woocommerce/tests/e2e-pw/data/countries/lt.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/lt.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/lt.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/lu.json b/plugins/woocommerce/tests/e2e-pw/data/countries/lu.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/lu.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/lu.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/lv.json b/plugins/woocommerce/tests/e2e-pw/data/countries/lv.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/lv.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/lv.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ly.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ly.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ly.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ly.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ma.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ma.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ma.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ma.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/mc.json b/plugins/woocommerce/tests/e2e-pw/data/countries/mc.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/mc.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/mc.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/md.json b/plugins/woocommerce/tests/e2e-pw/data/countries/md.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/md.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/md.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/me.json b/plugins/woocommerce/tests/e2e-pw/data/countries/me.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/me.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/me.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/mf.json b/plugins/woocommerce/tests/e2e-pw/data/countries/mf.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/mf.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/mf.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/mg.json b/plugins/woocommerce/tests/e2e-pw/data/countries/mg.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/mg.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/mg.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/mh.json b/plugins/woocommerce/tests/e2e-pw/data/countries/mh.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/mh.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/mh.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/mk.json b/plugins/woocommerce/tests/e2e-pw/data/countries/mk.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/mk.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/mk.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ml.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ml.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ml.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ml.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/mm.json b/plugins/woocommerce/tests/e2e-pw/data/countries/mm.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/mm.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/mm.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/mn.json b/plugins/woocommerce/tests/e2e-pw/data/countries/mn.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/mn.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/mn.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/mo.json b/plugins/woocommerce/tests/e2e-pw/data/countries/mo.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/mo.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/mo.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/mp.json b/plugins/woocommerce/tests/e2e-pw/data/countries/mp.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/mp.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/mp.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/mq.json b/plugins/woocommerce/tests/e2e-pw/data/countries/mq.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/mq.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/mq.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/mr.json b/plugins/woocommerce/tests/e2e-pw/data/countries/mr.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/mr.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/mr.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ms.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ms.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ms.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ms.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/mt.json b/plugins/woocommerce/tests/e2e-pw/data/countries/mt.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/mt.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/mt.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/mu.json b/plugins/woocommerce/tests/e2e-pw/data/countries/mu.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/mu.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/mu.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/mv.json b/plugins/woocommerce/tests/e2e-pw/data/countries/mv.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/mv.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/mv.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/mw.json b/plugins/woocommerce/tests/e2e-pw/data/countries/mw.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/mw.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/mw.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/mx.json b/plugins/woocommerce/tests/e2e-pw/data/countries/mx.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/mx.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/mx.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/my.json b/plugins/woocommerce/tests/e2e-pw/data/countries/my.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/my.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/my.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/mz.json b/plugins/woocommerce/tests/e2e-pw/data/countries/mz.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/mz.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/mz.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/na.json b/plugins/woocommerce/tests/e2e-pw/data/countries/na.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/na.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/na.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/nc.json b/plugins/woocommerce/tests/e2e-pw/data/countries/nc.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/nc.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/nc.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ne.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ne.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ne.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ne.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/nf.json b/plugins/woocommerce/tests/e2e-pw/data/countries/nf.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/nf.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/nf.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ng.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ng.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ng.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ng.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ni.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ni.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ni.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ni.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/nl.json b/plugins/woocommerce/tests/e2e-pw/data/countries/nl.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/nl.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/nl.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/no.json b/plugins/woocommerce/tests/e2e-pw/data/countries/no.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/no.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/no.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/np.json b/plugins/woocommerce/tests/e2e-pw/data/countries/np.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/np.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/np.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/nr.json b/plugins/woocommerce/tests/e2e-pw/data/countries/nr.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/nr.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/nr.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/nu.json b/plugins/woocommerce/tests/e2e-pw/data/countries/nu.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/nu.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/nu.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/nz.json b/plugins/woocommerce/tests/e2e-pw/data/countries/nz.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/nz.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/nz.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/om.json b/plugins/woocommerce/tests/e2e-pw/data/countries/om.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/om.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/om.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/pa.json b/plugins/woocommerce/tests/e2e-pw/data/countries/pa.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/pa.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/pa.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/pe.json b/plugins/woocommerce/tests/e2e-pw/data/countries/pe.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/pe.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/pe.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/pf.json b/plugins/woocommerce/tests/e2e-pw/data/countries/pf.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/pf.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/pf.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/pg.json b/plugins/woocommerce/tests/e2e-pw/data/countries/pg.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/pg.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/pg.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ph.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ph.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ph.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ph.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/pk.json b/plugins/woocommerce/tests/e2e-pw/data/countries/pk.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/pk.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/pk.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/pl.json b/plugins/woocommerce/tests/e2e-pw/data/countries/pl.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/pl.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/pl.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/pm.json b/plugins/woocommerce/tests/e2e-pw/data/countries/pm.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/pm.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/pm.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/pn.json b/plugins/woocommerce/tests/e2e-pw/data/countries/pn.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/pn.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/pn.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/pr.json b/plugins/woocommerce/tests/e2e-pw/data/countries/pr.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/pr.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/pr.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ps.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ps.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ps.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ps.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/pt.json b/plugins/woocommerce/tests/e2e-pw/data/countries/pt.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/pt.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/pt.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/pw.json b/plugins/woocommerce/tests/e2e-pw/data/countries/pw.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/pw.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/pw.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/py.json b/plugins/woocommerce/tests/e2e-pw/data/countries/py.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/py.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/py.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/qa.json b/plugins/woocommerce/tests/e2e-pw/data/countries/qa.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/qa.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/qa.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/re.json b/plugins/woocommerce/tests/e2e-pw/data/countries/re.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/re.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/re.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ro.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ro.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ro.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ro.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/rs.json b/plugins/woocommerce/tests/e2e-pw/data/countries/rs.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/rs.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/rs.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ru.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ru.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ru.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ru.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/rw.json b/plugins/woocommerce/tests/e2e-pw/data/countries/rw.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/rw.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/rw.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/sa.json b/plugins/woocommerce/tests/e2e-pw/data/countries/sa.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/sa.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/sa.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/sb.json b/plugins/woocommerce/tests/e2e-pw/data/countries/sb.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/sb.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/sb.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/sc.json b/plugins/woocommerce/tests/e2e-pw/data/countries/sc.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/sc.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/sc.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/sd.json b/plugins/woocommerce/tests/e2e-pw/data/countries/sd.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/sd.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/sd.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/se.json b/plugins/woocommerce/tests/e2e-pw/data/countries/se.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/se.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/se.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/sg.json b/plugins/woocommerce/tests/e2e-pw/data/countries/sg.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/sg.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/sg.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/sh.json b/plugins/woocommerce/tests/e2e-pw/data/countries/sh.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/sh.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/sh.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/si.json b/plugins/woocommerce/tests/e2e-pw/data/countries/si.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/si.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/si.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/sj.json b/plugins/woocommerce/tests/e2e-pw/data/countries/sj.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/sj.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/sj.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/sk.json b/plugins/woocommerce/tests/e2e-pw/data/countries/sk.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/sk.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/sk.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/sl.json b/plugins/woocommerce/tests/e2e-pw/data/countries/sl.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/sl.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/sl.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/sm.json b/plugins/woocommerce/tests/e2e-pw/data/countries/sm.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/sm.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/sm.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/sn.json b/plugins/woocommerce/tests/e2e-pw/data/countries/sn.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/sn.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/sn.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/so.json b/plugins/woocommerce/tests/e2e-pw/data/countries/so.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/so.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/so.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/sr.json b/plugins/woocommerce/tests/e2e-pw/data/countries/sr.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/sr.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/sr.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ss.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ss.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ss.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ss.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/st.json b/plugins/woocommerce/tests/e2e-pw/data/countries/st.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/st.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/st.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/sv.json b/plugins/woocommerce/tests/e2e-pw/data/countries/sv.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/sv.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/sv.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/sx.json b/plugins/woocommerce/tests/e2e-pw/data/countries/sx.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/sx.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/sx.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/sy.json b/plugins/woocommerce/tests/e2e-pw/data/countries/sy.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/sy.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/sy.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/sz.json b/plugins/woocommerce/tests/e2e-pw/data/countries/sz.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/sz.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/sz.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/tc.json b/plugins/woocommerce/tests/e2e-pw/data/countries/tc.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/tc.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/tc.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/td.json b/plugins/woocommerce/tests/e2e-pw/data/countries/td.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/td.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/td.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/tf.json b/plugins/woocommerce/tests/e2e-pw/data/countries/tf.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/tf.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/tf.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/tg.json b/plugins/woocommerce/tests/e2e-pw/data/countries/tg.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/tg.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/tg.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/th.json b/plugins/woocommerce/tests/e2e-pw/data/countries/th.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/th.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/th.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/tj.json b/plugins/woocommerce/tests/e2e-pw/data/countries/tj.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/tj.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/tj.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/tk.json b/plugins/woocommerce/tests/e2e-pw/data/countries/tk.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/tk.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/tk.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/tl.json b/plugins/woocommerce/tests/e2e-pw/data/countries/tl.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/tl.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/tl.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/tm.json b/plugins/woocommerce/tests/e2e-pw/data/countries/tm.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/tm.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/tm.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/tn.json b/plugins/woocommerce/tests/e2e-pw/data/countries/tn.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/tn.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/tn.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/to.json b/plugins/woocommerce/tests/e2e-pw/data/countries/to.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/to.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/to.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/tr.json b/plugins/woocommerce/tests/e2e-pw/data/countries/tr.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/tr.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/tr.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/tt.json b/plugins/woocommerce/tests/e2e-pw/data/countries/tt.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/tt.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/tt.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/tv.json b/plugins/woocommerce/tests/e2e-pw/data/countries/tv.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/tv.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/tv.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/tw.json b/plugins/woocommerce/tests/e2e-pw/data/countries/tw.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/tw.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/tw.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/tz.json b/plugins/woocommerce/tests/e2e-pw/data/countries/tz.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/tz.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/tz.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ua.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ua.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ua.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ua.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ug.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ug.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ug.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ug.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/um.json b/plugins/woocommerce/tests/e2e-pw/data/countries/um.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/um.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/um.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/us.json b/plugins/woocommerce/tests/e2e-pw/data/countries/us.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/us.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/us.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/uy.json b/plugins/woocommerce/tests/e2e-pw/data/countries/uy.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/uy.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/uy.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/uz.json b/plugins/woocommerce/tests/e2e-pw/data/countries/uz.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/uz.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/uz.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/va.json b/plugins/woocommerce/tests/e2e-pw/data/countries/va.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/va.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/va.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/vc.json b/plugins/woocommerce/tests/e2e-pw/data/countries/vc.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/vc.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/vc.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ve.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ve.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ve.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ve.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/vg.json b/plugins/woocommerce/tests/e2e-pw/data/countries/vg.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/vg.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/vg.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/vi.json b/plugins/woocommerce/tests/e2e-pw/data/countries/vi.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/vi.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/vi.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/vn.json b/plugins/woocommerce/tests/e2e-pw/data/countries/vn.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/vn.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/vn.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/vu.json b/plugins/woocommerce/tests/e2e-pw/data/countries/vu.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/vu.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/vu.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/wf.json b/plugins/woocommerce/tests/e2e-pw/data/countries/wf.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/wf.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/wf.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ws.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ws.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ws.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ws.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/ye.json b/plugins/woocommerce/tests/e2e-pw/data/countries/ye.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/ye.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/ye.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/yt.json b/plugins/woocommerce/tests/e2e-pw/data/countries/yt.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/yt.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/yt.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/za.json b/plugins/woocommerce/tests/e2e-pw/data/countries/za.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/za.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/za.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/zm.json b/plugins/woocommerce/tests/e2e-pw/data/countries/zm.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/zm.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/zm.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/countries/zw.json b/plugins/woocommerce/tests/e2e-pw/data/countries/zw.json similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/countries/zw.json rename to plugins/woocommerce/tests/e2e-pw/data/countries/zw.json diff --git a/plugins/woocommerce/tests/api-core-tests/data/coupon.js b/plugins/woocommerce/tests/e2e-pw/data/coupon.js similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/coupon.js rename to plugins/woocommerce/tests/e2e-pw/data/coupon.js diff --git a/plugins/woocommerce/tests/e2e-pw/data/customer.js b/plugins/woocommerce/tests/e2e-pw/data/customer.js new file mode 100644 index 00000000000..1bdf14570bd --- /dev/null +++ b/plugins/woocommerce/tests/e2e-pw/data/customer.js @@ -0,0 +1,46 @@ +/** + * This file contains objects that can be used as test data for scenarios around creating, retrieivng, updating, and deleting customers. + * + * For more details on the Product properties, see: + * + * https://woocommerce.github.io/woocommerce-rest-api-docs/#customers + * + */ + +/** + * A customer + */ +const customer = { + email: 'john.doe@example.com', + first_name: 'John', + last_name: 'Doe', + username: 'john.doe', + billing: { + first_name: 'John', + last_name: 'Doe', + company: '', + address_1: '969 Market', + address_2: '', + city: 'San Francisco', + state: 'CA', + postcode: '94103', + country: 'US', + email: 'john.doe@example.com', + phone: '(555) 555-5555', + }, + shipping: { + first_name: 'John', + last_name: 'Doe', + company: '', + address_1: '969 Market', + address_2: '', + city: 'San Francisco', + state: 'CA', + postcode: '94103', + country: 'US', + }, +}; + +module.exports = { + customer, +}; diff --git a/plugins/woocommerce/tests/api-core-tests/data/index.js b/plugins/woocommerce/tests/e2e-pw/data/index.js similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/index.js rename to plugins/woocommerce/tests/e2e-pw/data/index.js diff --git a/plugins/woocommerce/tests/api-core-tests/data/order.js b/plugins/woocommerce/tests/e2e-pw/data/order.js similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/order.js rename to plugins/woocommerce/tests/e2e-pw/data/order.js diff --git a/plugins/woocommerce/tests/api-core-tests/data/products-crud.js b/plugins/woocommerce/tests/e2e-pw/data/products-crud.js similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/products-crud.js rename to plugins/woocommerce/tests/e2e-pw/data/products-crud.js diff --git a/plugins/woocommerce/tests/api-core-tests/data/refund.js b/plugins/woocommerce/tests/e2e-pw/data/refund.js similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/refund.js rename to plugins/woocommerce/tests/e2e-pw/data/refund.js diff --git a/plugins/woocommerce/tests/api-core-tests/data/settings.js b/plugins/woocommerce/tests/e2e-pw/data/settings.js similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/settings.js rename to plugins/woocommerce/tests/e2e-pw/data/settings.js diff --git a/plugins/woocommerce/tests/api-core-tests/data/shared/batch-update.js b/plugins/woocommerce/tests/e2e-pw/data/shared/batch-update.js similarity index 95% rename from plugins/woocommerce/tests/api-core-tests/data/shared/batch-update.js rename to plugins/woocommerce/tests/e2e-pw/data/shared/batch-update.js index 440996ca0ca..700943d0d68 100644 --- a/plugins/woocommerce/tests/api-core-tests/data/shared/batch-update.js +++ b/plugins/woocommerce/tests/e2e-pw/data/shared/batch-update.js @@ -6,7 +6,6 @@ * @param {string} action Batch action. Must be one of: create, update, or delete. * @param {Array} resources A list of resource objects. For the delete action, this will be a list of IDs. * @param {Object} payload The batch payload object. Defaults to an empty object. - * @return {Object} The payload to send to the batch endpoint. */ const batch = ( action, resources = [], payload = {} ) => { if ( ! [ 'create', 'update', 'delete' ].includes( action ) ) { diff --git a/plugins/woocommerce/tests/api-core-tests/data/shared/customer.js b/plugins/woocommerce/tests/e2e-pw/data/shared/customer.js similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/shared/customer.js rename to plugins/woocommerce/tests/e2e-pw/data/shared/customer.js diff --git a/plugins/woocommerce/tests/api-core-tests/data/shared/error-response.js b/plugins/woocommerce/tests/e2e-pw/data/shared/error-response.js similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/shared/error-response.js rename to plugins/woocommerce/tests/e2e-pw/data/shared/error-response.js diff --git a/plugins/woocommerce/tests/api-core-tests/data/shared/index.js b/plugins/woocommerce/tests/e2e-pw/data/shared/index.js similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/shared/index.js rename to plugins/woocommerce/tests/e2e-pw/data/shared/index.js diff --git a/plugins/woocommerce/tests/api-core-tests/data/shipping-method.js b/plugins/woocommerce/tests/e2e-pw/data/shipping-method.js similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/shipping-method.js rename to plugins/woocommerce/tests/e2e-pw/data/shipping-method.js diff --git a/plugins/woocommerce/tests/api-core-tests/data/shipping-zone.js b/plugins/woocommerce/tests/e2e-pw/data/shipping-zone.js similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/shipping-zone.js rename to plugins/woocommerce/tests/e2e-pw/data/shipping-zone.js diff --git a/plugins/woocommerce/tests/e2e-pw/data/tax-rate.js b/plugins/woocommerce/tests/e2e-pw/data/tax-rate.js new file mode 100644 index 00000000000..50fa2b7cfd7 --- /dev/null +++ b/plugins/woocommerce/tests/e2e-pw/data/tax-rate.js @@ -0,0 +1,421 @@ +/** + * A standard tax rate. + * + * For more details on the tax rate properties, see: + * + * https://woocommerce.github.io/woocommerce-rest-api-docs/#tax-rate-properties + * + */ +const standardTaxRate = { + name: 'Standard Rate', + rate: '10.0000', + class: 'standard', +}; + +const reducedTaxRate = { + name: 'Reduced Rate', + rate: '1.0000', + class: 'reduced-rate', +}; + +const zeroTaxRate = { + name: 'Zero Rate', + rate: '0.0000', + class: 'zero-rate', +}; + +const getTaxRateExamples = () => { + return { standardTaxRate, reducedTaxRate, zeroTaxRate }; +}; + +const allUSTaxesExample = [ + { + country: 'US', + state: 'AL', + rate: '4.0000', + name: 'State Tax', + shipping: false, + order: 1, + }, + { + country: 'US', + state: 'AZ', + rate: '5.6000', + name: 'State Tax', + shipping: false, + order: 2, + }, + { + country: 'US', + state: 'AR', + rate: '6.5000', + name: 'State Tax', + shipping: true, + order: 3, + }, + { + country: 'US', + state: 'CA', + rate: '7.5000', + name: 'State Tax', + shipping: false, + order: 4, + }, + { + country: 'US', + state: 'CO', + rate: '2.9000', + name: 'State Tax', + shipping: false, + order: 5, + }, + { + country: 'US', + state: 'CT', + rate: '6.3500', + name: 'State Tax', + shipping: true, + order: 6, + }, + { + country: 'US', + state: 'DC', + rate: '5.7500', + name: 'State Tax', + shipping: true, + order: 7, + }, + { + country: 'US', + state: 'FL', + rate: '6.0000', + name: 'State Tax', + shipping: true, + order: 8, + }, + { + country: 'US', + state: 'GA', + rate: '4.0000', + name: 'State Tax', + shipping: true, + order: 9, + }, + { + country: 'US', + state: 'GU', + rate: '4.0000', + name: 'State Tax', + shipping: false, + order: 10, + }, + { + country: 'US', + state: 'HI', + rate: '4.0000', + name: 'State Tax', + shipping: true, + order: 11, + }, + { + country: 'US', + state: 'ID', + rate: '6.0000', + name: 'State Tax', + shipping: false, + order: 12, + }, + { + country: 'US', + state: 'IL', + rate: '6.2500', + name: 'State Tax', + shipping: false, + order: 13, + }, + { + country: 'US', + state: 'IN', + rate: '7.0000', + name: 'State Tax', + shipping: false, + order: 14, + }, + { + country: 'US', + state: 'IA', + rate: '6.0000', + name: 'State Tax', + shipping: false, + order: 15, + }, + { + country: 'US', + state: 'KS', + rate: '6.1500', + name: 'State Tax', + shipping: true, + order: 16, + }, + { + country: 'US', + state: 'KY', + rate: '6.0000', + name: 'State Tax', + shipping: true, + order: 17, + }, + { + country: 'US', + state: 'LA', + rate: '4.0000', + name: 'State Tax', + shipping: false, + order: 18, + }, + { + country: 'US', + state: 'ME', + rate: '5.5000', + name: 'State Tax', + shipping: false, + order: 19, + }, + { + country: 'US', + state: 'MD', + rate: '6.0000', + name: 'State Tax', + shipping: false, + order: 20, + }, + { + country: 'US', + state: 'MA', + rate: '6.2500', + name: 'State Tax', + shipping: false, + order: 21, + }, + { + country: 'US', + state: 'MI', + rate: '6.0000', + name: 'State Tax', + shipping: true, + order: 22, + }, + { + country: 'US', + state: 'MN', + rate: '6.8750', + name: 'State Tax', + shipping: true, + order: 23, + }, + { + country: 'US', + state: 'MS', + rate: '7.0000', + name: 'State Tax', + shipping: true, + order: 24, + }, + { + country: 'US', + state: 'MO', + rate: '4.2250', + name: 'State Tax', + shipping: false, + order: 25, + }, + { + country: 'US', + state: 'NE', + rate: '5.5000', + name: 'State Tax', + shipping: true, + order: 26, + }, + { + country: 'US', + state: 'NV', + rate: '6.8500', + name: 'State Tax', + shipping: false, + order: 27, + }, + { + country: 'US', + state: 'NJ', + rate: '7.0000', + name: 'State Tax', + shipping: true, + order: 28, + }, + { + country: 'US', + state: 'NM', + rate: '5.1250', + name: 'State Tax', + shipping: true, + order: 29, + }, + { + country: 'US', + state: 'NY', + rate: '4.0000', + name: 'State Tax', + shipping: true, + order: 30, + }, + { + country: 'US', + state: 'NC', + rate: '4.7500', + name: 'State Tax', + shipping: true, + order: 31, + }, + { + country: 'US', + state: 'ND', + rate: '5.0000', + name: 'State Tax', + shipping: true, + order: 32, + }, + { + country: 'US', + state: 'OH', + rate: '5.7500', + name: 'State Tax', + shipping: true, + order: 33, + }, + { + country: 'US', + state: 'OK', + rate: '4.5000', + name: 'State Tax', + shipping: false, + order: 34, + }, + { + country: 'US', + state: 'PA', + rate: '6.0000', + name: 'State Tax', + shipping: true, + order: 35, + }, + { + country: 'US', + state: 'PR', + rate: '6.0000', + name: 'State Tax', + shipping: false, + order: 36, + }, + { + country: 'US', + state: 'RI', + rate: '7.0000', + name: 'State Tax', + shipping: false, + order: 37, + }, + { + country: 'US', + state: 'SC', + rate: '6.0000', + name: 'State Tax', + shipping: true, + order: 38, + }, + { + country: 'US', + state: 'SD', + rate: '4.0000', + name: 'State Tax', + shipping: true, + order: 39, + }, + { + country: 'US', + state: 'TN', + rate: '7.0000', + name: 'State Tax', + shipping: true, + order: 40, + }, + { + country: 'US', + state: 'TX', + rate: '6.2500', + name: 'State Tax', + shipping: true, + order: 41, + }, + { + country: 'US', + state: 'UT', + rate: '5.9500', + name: 'State Tax', + shipping: false, + order: 42, + }, + { + country: 'US', + state: 'VT', + rate: '6.0000', + name: 'State Tax', + shipping: true, + order: 43, + }, + { + country: 'US', + state: 'VA', + rate: '5.3000', + name: 'State Tax', + shipping: false, + order: 44, + }, + { + country: 'US', + state: 'WA', + rate: '6.5000', + name: 'State Tax', + shipping: true, + order: 45, + }, + { + country: 'US', + state: 'WV', + rate: '6.0000', + name: 'State Tax', + shipping: true, + order: 46, + }, + { + country: 'US', + state: 'WI', + rate: '5.0000', + name: 'State Tax', + shipping: true, + order: 47, + }, + { + country: 'US', + state: 'WY', + rate: '4.0000', + name: 'State Tax', + shipping: true, + order: 48, + }, +]; + +module.exports = { + getTaxRateExamples, + allUSTaxesExample, +}; diff --git a/plugins/woocommerce/tests/api-core-tests/data/variation.js b/plugins/woocommerce/tests/e2e-pw/data/variation.js similarity index 100% rename from plugins/woocommerce/tests/api-core-tests/data/variation.js rename to plugins/woocommerce/tests/e2e-pw/data/variation.js diff --git a/plugins/woocommerce/tests/e2e-pw/envs/default/playwright.config.js b/plugins/woocommerce/tests/e2e-pw/envs/default/playwright.config.js index 0d5c093c943..ab29a29a95d 100644 --- a/plugins/woocommerce/tests/e2e-pw/envs/default/playwright.config.js +++ b/plugins/woocommerce/tests/e2e-pw/envs/default/playwright.config.js @@ -1,16 +1,5 @@ -let config = require( '../../playwright.config.js' ); -const { devices } = require( '@playwright/test' ); +const config = require( '../../playwright.config.js' ); process.env.USE_WP_ENV = 'true'; -config = { - ...config, - projects: [ - { - name: 'default', - use: { ...devices[ 'Desktop Chrome' ] }, - }, - ], -}; - module.exports = config; diff --git a/plugins/woocommerce/tests/e2e-pw/fixtures/api-tests-fixtures.js b/plugins/woocommerce/tests/e2e-pw/fixtures/api-tests-fixtures.js new file mode 100644 index 00000000000..7ed6af6cbfe --- /dev/null +++ b/plugins/woocommerce/tests/e2e-pw/fixtures/api-tests-fixtures.js @@ -0,0 +1,13 @@ +const base = require( '@playwright/test' ); +const { admin } = require( '../test-data/data' ); + +exports.test = base.test.extend( { + extraHTTPHeaders: { + // Add authorization token to all requests. + Authorization: `Basic ${ btoa( + `${ admin.username }:${ admin.password }` + ) }`, + }, +} ); + +exports.expect = base.expect; diff --git a/plugins/woocommerce/tests/e2e-pw/global-setup.js b/plugins/woocommerce/tests/e2e-pw/global-setup.js index 9701d1ab707..bb9f1e182c2 100644 --- a/plugins/woocommerce/tests/e2e-pw/global-setup.js +++ b/plugins/woocommerce/tests/e2e-pw/global-setup.js @@ -95,7 +95,7 @@ module.exports = async ( config ) => { // While we're here, let's add a consumer token for API access // This step was failing occasionally, and globalsetup doesn't retry, so make it retry - const nRetries = 5; + const nRetries = 3; for ( let i = 0; i < nRetries; i++ ) { try { console.log( 'Trying to add consumer token...' ); @@ -122,6 +122,10 @@ module.exports = async ( config ) => { console.log( `Failed to add consumer token. Retrying... ${ i }/${ nRetries }` ); + await adminPage.screenshot( { + fullPage: true, + path: `tests/e2e-pw/test-results/generate-key-fail-${ i }.png`, + } ); console.log( e ); } } diff --git a/plugins/woocommerce/tests/e2e-pw/playwright.config.js b/plugins/woocommerce/tests/e2e-pw/playwright.config.js index 51f10fed52d..da6a1dc266e 100644 --- a/plugins/woocommerce/tests/e2e-pw/playwright.config.js +++ b/plugins/woocommerce/tests/e2e-pw/playwright.config.js @@ -1,3 +1,4 @@ +const { devices } = require( '@playwright/test' ); require( 'dotenv' ).config( { path: __dirname + '/.env' } ); const testsRootPath = __dirname; @@ -87,7 +88,18 @@ const config = { navigationTimeout: 20 * 1000, }, snapshotPathTemplate: '{testDir}/{testFilePath}-snapshots/{arg}', - projects: [], + projects: [ + { + name: 'ui', + use: { ...devices[ 'Desktop Chrome' ] }, + testIgnore: '**/api-tests/**', + }, + { + name: 'api', + use: { ...devices[ 'Desktop Chrome' ] }, + testMatch: '**/api-tests/**', + }, + ], }; module.exports = config; diff --git a/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/coupons/coupons.test.js similarity index 98% rename from plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js rename to plugins/woocommerce/tests/e2e-pw/tests/api-tests/coupons/coupons.test.js index 524fbd9670b..7c9a8a06565 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/coupons/coupons.test.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/coupons/coupons.test.js @@ -1,12 +1,6 @@ -const { test, expect } = require( '@playwright/test' ); -const { coupon, order } = require( '../../data' ); +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); +const { coupon, order } = require( '../../../data' ); -/** - * Tests for the WooCommerce Coupons API. - * - * @group api - * @group coupons - */ test.describe( 'Coupons API tests', () => { //create variable to store the coupon id we will be using let couponId; diff --git a/plugins/woocommerce/tests/api-core-tests/tests/customers/customers-crud.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/customers/customers-crud.test.js similarity index 96% rename from plugins/woocommerce/tests/api-core-tests/tests/customers/customers-crud.test.js rename to plugins/woocommerce/tests/e2e-pw/tests/api-tests/customers/customers-crud.test.js index b83a0c65466..17be7e0a3bc 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/customers/customers-crud.test.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/customers/customers-crud.test.js @@ -1,15 +1,7 @@ -const { test, expect } = require( '@playwright/test' ); -const { customer } = require( '../../data' ); -const { USER_KEY } = process.env; -const userKey = USER_KEY ?? 'admin'; +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); +const { admin } = require( '../../../test-data/data' ); +const { customer } = require( '../../../data' ); -/** - * Tests for the WooCommerce Customers API. - * - * @group api - * @group customers - * - */ test.describe( 'Customers API tests: CRUD', () => { let customerId; let subscriberUserId; @@ -60,7 +52,9 @@ test.describe( 'Customers API tests: CRUD', () => { `/wp-json/wc/v3/customers/${ subscriberUserId }` ); const responseJSON = await response.json(); + // eslint-disable-next-line jest/no-standalone-expect expect( response.status() ).toEqual( 200 ); + // eslint-disable-next-line jest/no-standalone-expect expect( responseJSON.role ).toEqual( 'subscriber' ); } ); @@ -97,7 +91,7 @@ test.describe( 'Customers API tests: CRUD', () => { expect( responseJSON.is_paying_customer ).toEqual( false ); expect( responseJSON.role ).toEqual( 'administrator' ); // this test was updated to allow for local test setup and other test sites. - expect( responseJSON.username ).toEqual( userKey ); + expect( responseJSON.username ).toEqual( admin.username ); } ); test( 'can retrieve subscriber user', async ( { request } ) => { @@ -180,7 +174,9 @@ test.describe( 'Customers API tests: CRUD', () => { expect( responseJSON.role ).toEqual( 'customer' ); } ); - test( 'can retrieve all customers', async ( { request } ) => { + test( 'can retrieve all customers after create', async ( { + request, + } ) => { // call API to retrieve all customers const response = await request.get( '/wp-json/wc/v3/customers' ); const responseJSON = await response.json(); @@ -493,12 +489,12 @@ test.describe( 'Customers API tests: CRUD', () => { expect( deletedCustomerIds ).toEqual( customerIdsToDelete ); // Verify that the 2 deleted customers cannot be retrieved. - for ( const customerId of customerIdsToDelete ) { + for ( const id of customerIdsToDelete ) { //Call the API to attempte to retrieve the customers - const response = await request.get( - `wp-json/wc/v3/customers/${ customerId }` + const r = await request.get( + `wp-json/wc/v3/customers/${ id }` ); - expect( response.status() ).toEqual( 404 ); + expect( r.status() ).toEqual( 404 ); } } ); } ); diff --git a/plugins/woocommerce/tests/api-core-tests/tests/data/data-crud.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/data/data-crud.test.js similarity index 99% rename from plugins/woocommerce/tests/api-core-tests/tests/data/data-crud.test.js rename to plugins/woocommerce/tests/e2e-pw/tests/api-tests/data/data-crud.test.js index 7ff5a9ad8cd..174cd80b1c7 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/data/data-crud.test.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/data/data-crud.test.js @@ -1,4 +1,4 @@ -const { test, expect } = require( '@playwright/test' ); +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); // 259 countries total const countryCodes = [ @@ -253,13 +253,6 @@ const countryCodes = [ 'zw', ]; -/** - * Tests for the WooCommerce Refunds API. - * - * @group api - * @group data - * - */ test.describe( 'Data API tests', () => { test( 'can list all data', async ( { request } ) => { // call API to retrieve data values @@ -3973,7 +3966,7 @@ test.describe( 'Data API tests', () => { // loop through all the countries and validate against the expected data for ( const country of countryCodes ) { - const countryData = require( `../../data/countries/${ country }.json` ); + const countryData = require( `../../../data/countries/${ country }.json` ); expect( responseJSON ).toEqual( expect.arrayContaining( [ expect.objectContaining( { diff --git a/plugins/woocommerce/tests/api-core-tests/tests/hello/hello.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/hello/hello.test.js similarity index 75% rename from plugins/woocommerce/tests/api-core-tests/tests/hello/hello.test.js rename to plugins/woocommerce/tests/e2e-pw/tests/api-tests/hello/hello.test.js index e3ed698019d..0e74a103cc8 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/hello/hello.test.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/hello/hello.test.js @@ -1,11 +1,5 @@ -const { test, expect } = require( '@playwright/test' ); +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); -/** - * Tests to verify connection to the API. - * - * @group api - * @group hello - */ test.describe( 'Test API connectivity', () => { test( 'can access a non-authenticated endpoint', async ( { request } ) => { const result = await request.get( '/wp-json/wc/v3/' ); diff --git a/plugins/woocommerce/tests/api-core-tests/tests/orders/order-complex.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/orders/order-complex.test.js similarity index 96% rename from plugins/woocommerce/tests/api-core-tests/tests/orders/order-complex.test.js rename to plugins/woocommerce/tests/e2e-pw/tests/api-tests/orders/order-complex.test.js index 392c89d340a..5308ecdcfa1 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/orders/order-complex.test.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/orders/order-complex.test.js @@ -1,4 +1,4 @@ -const { test, expect } = require( '@playwright/test' ); +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); const { getOrderExample, @@ -8,7 +8,7 @@ const { variableProduct: defaultVariableProduct, groupedProduct: defaultGroupedProduct, externalProduct: defaultExternalProduct, -} = require( '../../data' ); +} = require( '../../../data' ); /** * Simple product with Standard tax rate @@ -73,14 +73,6 @@ const expectedSimpleProductTaxTotal = '1.00'; const expectedVariableProductTaxTotal = '0.20'; const expectedExternalProductTaxTotal = '0.00'; -/** - * - * Test for adding a complex order with different product types and tax classes. - * - * @group api - * @group orders - * - */ test.describe( 'Orders API test', () => { test.beforeAll( async ( { request } ) => { /** diff --git a/plugins/woocommerce/tests/api-core-tests/tests/orders/order-search.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/orders/order-search.test.js similarity index 82% rename from plugins/woocommerce/tests/api-core-tests/tests/orders/order-search.test.js rename to plugins/woocommerce/tests/e2e-pw/tests/api-tests/orders/order-search.test.js index e7d1f400a58..ab57435a3b7 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/orders/order-search.test.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/orders/order-search.test.js @@ -1,10 +1,10 @@ -const { test, expect } = require( '@playwright/test' ); +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); -const { getOrderExampleSearchTest } = require( '../../data/order' ); -const { customerShippingSearchTest } = require( '../../data/shared/customer' ); +const { getOrderExampleSearchTest } = require( '../../../data/order' ); const { - simpleProduct, -} = require('../../data/products-crud'); + customerShippingSearchTest, +} = require( '../../../data/shared/customer' ); +const { simpleProduct } = require( '../../../data/products-crud' ); /** * Order to be searched @@ -49,23 +49,16 @@ const searchParams = [ [ 'shipping state', order.shipping.state ], ]; -/** - * Tests for the WooCommerce Order Search API. - * - * @group api - * @group orders - * - */ test.describe( 'Order Search API tests', () => { test.beforeAll( async ( { request } ) => { // Create a product to be associated with the order - const productResponse = await request.post('wp-json/wc/v3/products', { + const productResponse = await request.post( 'wp-json/wc/v3/products', { data: simpleProduct, - }); + } ); const productResponseJSON = await productResponse.json(); // Save the created product id against the order line_items - order.line_items[0].product_id = productResponseJSON.id; + order.line_items[ 0 ].product_id = productResponseJSON.id; // Create an order and save its ID const response = await request.post( '/wp-json/wc/v3/orders', { @@ -77,9 +70,12 @@ test.describe( 'Order Search API tests', () => { test.afterAll( async ( { request } ) => { // Cleanup: Delete the product - await request.delete( `/wp-json/wc/v3/products/${ order.line_items[0].product_id }`, { - data: { force: true }, - } ); + await request.delete( + `/wp-json/wc/v3/products/${ order.line_items[ 0 ].product_id }`, + { + data: { force: true }, + } + ); // Cleanup: Delete the order await request.delete( `/wp-json/wc/v3/orders/${ order.id }`, { data: { force: true }, @@ -94,6 +90,7 @@ test.describe( 'Order Search API tests', () => { request, } ) => { const searchValue = + // eslint-disable-next-line playwright/no-conditional-in-test searchParamRow[ paramIndex ] === 'orderId' ? order.id : searchParamRow[ paramIndex ]; diff --git a/plugins/woocommerce/tests/api-core-tests/tests/orders/orders-crud.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/orders/orders-crud.test.js similarity index 97% rename from plugins/woocommerce/tests/api-core-tests/tests/orders/orders-crud.test.js rename to plugins/woocommerce/tests/e2e-pw/tests/api-tests/orders/orders-crud.test.js index 005e3b33d15..7bca8c2836d 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/orders/orders-crud.test.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/orders/orders-crud.test.js @@ -1,7 +1,7 @@ -const { test, expect } = require( '@playwright/test' ); -const { order } = require( '../../data' ); +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); +const { order } = require( '../../../data' ); const { API_BASE_URL } = process.env; -const shouldSkip = API_BASE_URL != undefined; +const shouldSkip = API_BASE_URL !== undefined; /** * Billing properties to update. @@ -57,13 +57,6 @@ const simpleProduct = { regular_price: '48', }; -/** - * Tests for the WooCommerce Orders API. - * - * @group api - * @group orders - * - */ test.describe.serial( 'Orders API tests: CRUD', () => { let orderId; @@ -264,6 +257,7 @@ test.describe.serial( 'Orders API tests: CRUD', () => { test( `can update status of an order to ${ expectedOrderStatus }`, async ( { request, } ) => { + // eslint-disable-next-line playwright/no-conditional-in-test if ( shouldSkip ) { await delay( 1000 ); // if this runs too fast on an external host, it fails } diff --git a/plugins/woocommerce/tests/api-core-tests/tests/orders/orders.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/orders/orders.test.js similarity index 99% rename from plugins/woocommerce/tests/api-core-tests/tests/orders/orders.test.js rename to plugins/woocommerce/tests/e2e-pw/tests/api-tests/orders/orders.test.js index 0dacf9751d9..f0164b40982 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/orders/orders.test.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/orders/orders.test.js @@ -1,5 +1,5 @@ -const { test, expect } = require( '@playwright/test' ); -const { order } = require( '../../data' ); +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); +const { order } = require( '../../../data' ); /** * Billing properties to update. @@ -34,14 +34,6 @@ const updatedCustomerShipping = { phone: '123456789', }; -/** - * Tests for the WooCommerce Orders API. - * - * @group api - * @group orders - * - */ - test.describe.serial( 'Orders API tests', () => { let orderId, sampleData; diff --git a/plugins/woocommerce/tests/api-core-tests/tests/payment-gateways/payment-gateways-crud.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/payment-gateways/payment-gateways-crud.test.js similarity index 96% rename from plugins/woocommerce/tests/api-core-tests/tests/payment-gateways/payment-gateways-crud.test.js rename to plugins/woocommerce/tests/e2e-pw/tests/api-tests/payment-gateways/payment-gateways-crud.test.js index 70ef9183390..c4d021c65f5 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/payment-gateways/payment-gateways-crud.test.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/payment-gateways/payment-gateways-crud.test.js @@ -1,12 +1,5 @@ -const { test, expect } = require( '@playwright/test' ); +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); -/** - * Tests for the WooCommerce Refunds API. - * - * @group api - * @group payment gateways - * - */ test.describe( 'Payment Gateways API tests', () => { test( 'can view all payment gateways', async ( { request } ) => { // call API to retrieve the payment gateways @@ -16,8 +9,9 @@ test.describe( 'Payment Gateways API tests', () => { expect( Array.isArray( responseJSON ) ).toBe( true ); const localPickupKey = - process.env.API_BASE_URL && - ! process.env.API_BASE_URL.includes( 'localhost' ) + // eslint-disable-next-line playwright/no-conditional-in-test + process.env.BASE_URL && + ! process.env.BASE_URL.includes( 'localhost' ) ? 'pickup_location' : 'local_pickup'; console.log( 'localPickupKey=', localPickupKey ); diff --git a/plugins/woocommerce/tests/api-core-tests/tests/products/product-list.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/products/product-list.test.js similarity index 99% rename from plugins/woocommerce/tests/api-core-tests/tests/products/product-list.test.js rename to plugins/woocommerce/tests/e2e-pw/tests/api-tests/products/product-list.test.js index b9114779f1a..03f51112b37 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/products/product-list.test.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/products/product-list.test.js @@ -1,15 +1,5 @@ -const { test, expect } = require( '@playwright/test' ); -/** - * Internal dependencies - */ +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); -/** - * Tests for the WooCommerce "List all products" API. - * - * @group api - * @group products - * - */ test.describe( 'Products API tests: List All Products', () => { const PRODUCTS_COUNT = 20; let sampleData; diff --git a/plugins/woocommerce/tests/api-core-tests/tests/products/products-crud.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/products/products-crud.test.js similarity index 98% rename from plugins/woocommerce/tests/api-core-tests/tests/products/products-crud.test.js rename to plugins/woocommerce/tests/e2e-pw/tests/api-tests/products/products-crud.test.js index 20b1e15b684..4304dcdedfc 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/products/products-crud.test.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/products/products-crud.test.js @@ -1,6 +1,6 @@ -const { test, expect } = require( '@playwright/test' ); -const { API_BASE_URL } = process.env; -const shouldSkip = API_BASE_URL !== undefined; +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); +const { BASE_URL } = process.env; +const shouldSkip = BASE_URL !== undefined; /** * Internal dependencies @@ -9,17 +9,9 @@ const { simpleProduct, virtualProduct, variableProduct, -} = require( '../../data/products-crud' ); -const { batch } = require( '../../data/shared/batch-update' ); +} = require( '../../../data/products-crud' ); +const { batch } = require( '../../../data/shared/batch-update' ); -/** - * Tests for the WooCommerce Products API. - * These tests cover API endpoints for creating, retrieving, updating, and deleting a single product. - * - * @group api - * @group products - * - */ test.describe( 'Products API tests: CRUD', () => { let productId; @@ -468,7 +460,9 @@ test.describe( 'Products API tests: CRUD', () => { expect( responseJSON.count ).toEqual( 0 ); } ); - test( 'can permanently delete a product tag', async ( { request } ) => { + test( 'can permanently delete a product category', async ( { + request, + } ) => { // Delete the product category. const response = await request.delete( `wp-json/wc/v3/products/categories/${ productCategoryId }`, @@ -1279,6 +1273,7 @@ test.describe( 'Products API tests: CRUD', () => { expect( response.status() ).toEqual( 200 ); // if we're running on CI, then skip -- because objects are cached and they don't disappear instantly. + // eslint-disable-next-line playwright/no-conditional-in-test if ( ! shouldSkip ) { // Verify that the product variation can no longer be retrieved. const getDeletedProductVariationResponse = await request.get( @@ -1368,6 +1363,7 @@ test.describe( 'Products API tests: CRUD', () => { ); // if we're running on CI, then skip -- because objects are cached and they don't disappear instantly. + // eslint-disable-next-line playwright/no-conditional-in-test if ( ! shouldSkip ) { // Verify that the deleted product variation can no longer be retrieved. const getDeletedProductVariationResponse = await request.get( diff --git a/plugins/woocommerce/tests/api-core-tests/tests/refunds/refunds.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/refunds/refunds.test.js similarity index 96% rename from plugins/woocommerce/tests/api-core-tests/tests/refunds/refunds.test.js rename to plugins/woocommerce/tests/e2e-pw/tests/api-tests/refunds/refunds.test.js index bf325996f8f..c7af313f3be 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/refunds/refunds.test.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/refunds/refunds.test.js @@ -1,13 +1,6 @@ -const { test, expect } = require( '@playwright/test' ); -const { refund } = require( '../../data' ); +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); +const { refund } = require( '../../../data' ); -/** - * Tests for the WooCommerce Refunds API. - * - * @group api - * @group refunds - * - */ test.describe( 'Refunds API tests', () => { let expectedRefund; let orderId; diff --git a/plugins/woocommerce/tests/e2e-pw/tests/api-tests/reports/reports-crud.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/reports/reports-crud.test.js new file mode 100644 index 00000000000..afa29442805 --- /dev/null +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/reports/reports-crud.test.js @@ -0,0 +1,425 @@ +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); + +test.describe( 'Reports API tests', () => { + test( 'can view all reports', async ( { request } ) => { + // call API to retrieve the reports + const response = await request.get( '/wp-json/wc/v3/reports' ); + const responseJSON = await response.json(); + expect( response.status() ).toEqual( 200 ); + expect( Array.isArray( responseJSON ) ).toBe( true ); + + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'sales', + description: 'List of sales reports.', + } ), + ] ) + ); + + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'sales', + description: 'List of sales reports.', + } ), + ] ) + ); + + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'sales', + description: 'List of sales reports.', + } ), + ] ) + ); + + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'sales', + description: 'List of sales reports.', + } ), + ] ) + ); + + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'sales', + description: 'List of sales reports.', + } ), + ] ) + ); + + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'sales', + description: 'List of sales reports.', + } ), + ] ) + ); + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'sales', + description: 'List of sales reports.', + } ), + ] ) + ); + + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'sales', + description: 'List of sales reports.', + } ), + ] ) + ); + + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'sales', + description: 'List of sales reports.', + } ), + ] ) + ); + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'sales', + description: 'List of sales reports.', + } ), + ] ) + ); + + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'sales', + description: 'List of sales reports.', + } ), + ] ) + ); + + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'sales', + description: 'List of sales reports.', + } ), + ] ) + ); + } ); + + test( 'can view sales reports', async ( { request } ) => { + // call API to retrieve the sales reports + const response = await request.get( '/wp-json/wc/v3/reports/sales' ); + const responseJSON = await response.json(); + expect( response.status() ).toEqual( 200 ); + expect( Array.isArray( responseJSON ) ).toBe( true ); + + const today = new Date(); + const dd = String( today.getDate() ).padStart( 2, '0' ); + const mm = String( today.getMonth() + 1 ).padStart( 2, '0' ); //January is 0! + const yyyy = today.getFullYear(); + const dateString = yyyy + '-' + mm + '-' + dd; + + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + total_sales: expect.any( String ), + net_sales: expect.any( String ), + average_sales: expect.any( String ), + total_orders: expect.any( Number ), + total_items: expect.any( Number ), + total_tax: expect.any( String ), + total_shipping: expect.any( String ), + total_refunds: expect.any( Number ), + total_discount: expect.any( String ), + totals_grouped_by: 'day', + totals: expect.objectContaining( { + [ dateString ]: { + sales: expect.any( String ), + orders: expect.any( Number ), + items: expect.any( Number ), + tax: expect.any( String ), + shipping: expect.any( String ), + discount: expect.any( String ), + customers: expect.any( Number ), + }, + } ), + total_customers: expect.any( Number ), + } ), + ] ) + ); + } ); + + test( 'can view top sellers reports', async ( { request } ) => { + // call API to retrieve the top sellers + const response = await request.get( + '/wp-json/wc/v3/reports/top_sellers' + ); + const responseJSON = await response.json(); + expect( response.status() ).toEqual( 200 ); + expect( Array.isArray( responseJSON ) ).toBe( true ); + + expect( responseJSON ).toEqual( expect.arrayContaining( [] ) ); + } ); + + test( 'can view coupons totals', async ( { request } ) => { + // call API to retrieve the coupons totals + const response = await request.get( + '/wp-json/wc/v3/reports/coupons/totals' + ); + const responseJSON = await response.json(); + expect( response.status() ).toEqual( 200 ); + expect( Array.isArray( responseJSON ) ).toBe( true ); + + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'percent', + name: 'Percentage discount', + total: expect.any( Number ), + } ), + ] ) + ); + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'fixed_cart', + name: 'Fixed cart discount', + total: expect.any( Number ), + } ), + ] ) + ); + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'fixed_product', + name: 'Fixed product discount', + total: expect.any( Number ), + } ), + ] ) + ); + } ); + + test( 'can view customers totals', async ( { request } ) => { + // call API to retrieve the customers totals + const response = await request.get( + '/wp-json/wc/v3/reports/customers/totals' + ); + const responseJSON = await response.json(); + expect( response.status() ).toEqual( 200 ); + expect( Array.isArray( responseJSON ) ).toBe( true ); + + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'paying', + name: 'Paying customer', + total: expect.any( Number ), + } ), + ] ) + ); + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'non_paying', + name: 'Non-paying customer', + total: expect.any( Number ), + } ), + ] ) + ); + } ); + + test( 'can view orders totals', async ( { request } ) => { + // call API to retrieve the orders totals + const response = await request.get( + '/wp-json/wc/v3/reports/orders/totals' + ); + const responseJSON = await response.json(); + expect( response.status() ).toEqual( 200 ); + expect( Array.isArray( responseJSON ) ).toBe( true ); + + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'pending', + name: 'Pending payment', + total: expect.any( Number ), + } ), + ] ) + ); + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'processing', + name: 'Processing', + total: expect.any( Number ), + } ), + ] ) + ); + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'on-hold', + name: 'On hold', + total: expect.any( Number ), + } ), + ] ) + ); + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'completed', + name: 'Completed', + total: expect.any( Number ), + } ), + ] ) + ); + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'cancelled', + name: 'Cancelled', + total: expect.any( Number ), + } ), + ] ) + ); + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'refunded', + name: 'Refunded', + total: expect.any( Number ), + } ), + ] ) + ); + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'failed', + name: 'Failed', + total: expect.any( Number ), + } ), + ] ) + ); + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'checkout-draft', + name: 'Draft', + total: expect.any( Number ), + } ), + ] ) + ); + } ); + + test( 'can view products totals', async ( { request } ) => { + // call API to retrieve the products totals + const response = await request.get( + '/wp-json/wc/v3/reports/products/totals' + ); + const responseJSON = await response.json(); + expect( response.status() ).toEqual( 200 ); + expect( Array.isArray( responseJSON ) ).toBe( true ); + + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'external', + name: 'External/Affiliate product', + total: expect.any( Number ), + } ), + ] ) + ); + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'grouped', + name: 'Grouped product', + total: expect.any( Number ), + } ), + ] ) + ); + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'simple', + name: 'Simple product', + total: expect.any( Number ), + } ), + ] ) + ); + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'variable', + name: 'Variable product', + total: expect.any( Number ), + } ), + ] ) + ); + } ); + + test( 'can view reviews totals', async ( { request } ) => { + // call API to retrieve the reviews totals + const response = await request.get( + '/wp-json/wc/v3/reports/reviews/totals' + ); + const responseJSON = await response.json(); + expect( response.status() ).toEqual( 200 ); + expect( Array.isArray( responseJSON ) ).toBe( true ); + + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'rated_1_out_of_5', + name: 'Rated 1 out of 5', + total: expect.any( Number ), + } ), + ] ) + ); + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'rated_2_out_of_5', + name: 'Rated 2 out of 5', + total: expect.any( Number ), + } ), + ] ) + ); + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'rated_3_out_of_5', + name: 'Rated 3 out of 5', + total: expect.any( Number ), + } ), + ] ) + ); + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'rated_4_out_of_5', + name: 'Rated 4 out of 5', + total: expect.any( Number ), + } ), + ] ) + ); + expect( responseJSON ).toEqual( + expect.arrayContaining( [ + expect.objectContaining( { + slug: 'rated_5_out_of_5', + name: 'Rated 5 out of 5', + total: expect.any( Number ), + } ), + ] ) + ); + } ); +} ); diff --git a/plugins/woocommerce/tests/api-core-tests/tests/settings/settings-crud.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/settings/settings-crud.test.js similarity index 99% rename from plugins/woocommerce/tests/api-core-tests/tests/settings/settings-crud.test.js rename to plugins/woocommerce/tests/e2e-pw/tests/api-tests/settings/settings-crud.test.js index e22be453720..376d606c745 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/settings/settings-crud.test.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/settings/settings-crud.test.js @@ -1,20 +1,12 @@ -const { test, expect } = require( '@playwright/test' ); -const { API_BASE_URL } = process.env; -const shouldSkip = API_BASE_URL !== undefined; +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); +const { BASE_URL } = process.env; +const shouldSkip = BASE_URL !== undefined; const { countries, currencies, stateOptions, -} = require( '../../data/settings' ); - -/** - * Tests for the WooCommerce API. - * - * @group api - * @group settings - * - */ +} = require( '../../../data/settings' ); test.describe.serial( 'Settings API tests: CRUD', () => { test.describe( 'List all settings groups', () => { @@ -376,6 +368,7 @@ test.describe.serial( 'Settings API tests: CRUD', () => { ); // different on external host + // eslint-disable-next-line playwright/no-conditional-in-test if ( ! shouldSkip ) { expect( responseJSON ).toEqual( expect.arrayContaining( [ @@ -395,6 +388,7 @@ test.describe.serial( 'Settings API tests: CRUD', () => { } // different on external host + // eslint-disable-next-line playwright/no-conditional-in-test if ( ! shouldSkip ) { expect( responseJSON ).toEqual( expect.arrayContaining( [ @@ -436,6 +430,7 @@ test.describe.serial( 'Settings API tests: CRUD', () => { ); // different on external host + // eslint-disable-next-line playwright/no-conditional-in-test if ( ! shouldSkip ) { expect( responseJSON ).toEqual( expect.arrayContaining( [ @@ -517,6 +512,7 @@ test.describe.serial( 'Settings API tests: CRUD', () => { ] ) ); + // eslint-disable-next-line playwright/no-conditional-in-test if ( ! shouldSkip ) { expect( responseJSON ).toEqual( expect.arrayContaining( [ @@ -1628,6 +1624,7 @@ test.describe.serial( 'Settings API tests: CRUD', () => { expect( Array.isArray( responseJSON ) ).toBe( true ); // not present in external host + // eslint-disable-next-line playwright/no-conditional-in-test if ( ! shouldSkip ) { expect( responseJSON ).toEqual( expect.arrayContaining( [ @@ -1647,6 +1644,7 @@ test.describe.serial( 'Settings API tests: CRUD', () => { } // not present in external host + // eslint-disable-next-line playwright/no-conditional-in-test if ( ! shouldSkip ) { expect( responseJSON ).toEqual( expect.arrayContaining( [ @@ -1849,6 +1847,7 @@ test.describe.serial( 'Settings API tests: CRUD', () => { } ), ] ) ); + // eslint-disable-next-line playwright/no-conditional-in-test if ( ! shouldSkip ) { expect( responseJSON ).toEqual( expect.arrayContaining( [ diff --git a/plugins/woocommerce/tests/api-core-tests/tests/shipping/shipping-method.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/shipping/shipping-method.test.js similarity index 98% rename from plugins/woocommerce/tests/api-core-tests/tests/shipping/shipping-method.test.js rename to plugins/woocommerce/tests/e2e-pw/tests/api-tests/shipping/shipping-method.test.js index 72ac2b705f7..45f4d6abb96 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/shipping/shipping-method.test.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/shipping/shipping-method.test.js @@ -1,12 +1,9 @@ /* eslint-disable */ -const { - test, - expect -} = require('@playwright/test'); +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); const { getShippingMethodExample -} = require('../../data'); +} = require('../../../data'); /** * Shipping zone id for "Locations not covered by your other zones". diff --git a/plugins/woocommerce/tests/api-core-tests/tests/shipping/shipping-zones.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/shipping/shipping-zones.test.js similarity index 97% rename from plugins/woocommerce/tests/api-core-tests/tests/shipping/shipping-zones.test.js rename to plugins/woocommerce/tests/e2e-pw/tests/api-tests/shipping/shipping-zones.test.js index 87769591c78..18cfe57515e 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/shipping/shipping-zones.test.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/shipping/shipping-zones.test.js @@ -1,8 +1,8 @@ /* eslint-disable */ -const { test, expect } = require('@playwright/test'); -const { getShippingZoneExample } = require( '../../data' ); -const { API_BASE_URL } = process.env; -const shouldSkip = API_BASE_URL != undefined; +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); +const { getShippingZoneExample } = require( '../../../data' ); +const { BASE_URL } = process.env; +const shouldSkip = BASE_URL !== undefined; /** * Tests for the WooCommerce Shipping zones API. * @group api diff --git a/plugins/woocommerce/tests/api-core-tests/tests/system-status/system-status-crud.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/system-status/system-status-crud.test.js similarity index 98% rename from plugins/woocommerce/tests/api-core-tests/tests/system-status/system-status-crud.test.js rename to plugins/woocommerce/tests/e2e-pw/tests/api-tests/system-status/system-status-crud.test.js index c56d661987e..65d56a07196 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/system-status/system-status-crud.test.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/system-status/system-status-crud.test.js @@ -1,15 +1,6 @@ -const { test, expect } = require( '@playwright/test' ); -const { API_BASE_URL } = process.env; -const shouldSkip = - API_BASE_URL !== undefined && ! API_BASE_URL.includes( 'localhost' ); - -/** - * Tests for the WooCommerce API. - * - * @group api - * @group system status - * - */ +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); +const { BASE_URL } = process.env; +const shouldSkip = BASE_URL !== undefined && ! BASE_URL.includes( 'localhost' ); test.describe( 'System Status API tests', () => { test( 'can view all system status items', async ( { request } ) => { @@ -19,6 +10,7 @@ test.describe( 'System Status API tests', () => { expect( response.status() ).toEqual( 200 ); // local environment differs from external hosts. Local listed first. + // eslint-disable-next-line playwright/no-conditional-in-test if ( ! shouldSkip ) { expect( responseJSON ).toEqual( expect.objectContaining( { @@ -408,6 +400,7 @@ test.describe( 'System Status API tests', () => { ); // local environment differs from external hosts. Local listed first. + // eslint-disable-next-line playwright/no-conditional-in-test if ( ! shouldSkip ) { expect( responseJSON ).toEqual( expect.objectContaining( { diff --git a/plugins/woocommerce/tests/api-core-tests/tests/taxes/tax-classes-crud.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/taxes/tax-classes-crud.test.js similarity index 96% rename from plugins/woocommerce/tests/api-core-tests/tests/taxes/tax-classes-crud.test.js rename to plugins/woocommerce/tests/e2e-pw/tests/api-tests/taxes/tax-classes-crud.test.js index 013d176eb8d..d61932381b4 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/taxes/tax-classes-crud.test.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/taxes/tax-classes-crud.test.js @@ -1,12 +1,5 @@ -const { test, expect } = require( '@playwright/test' ); +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); -/** - * Tests for the WooCommerce API. - * - * @group api - * @group taxes - * - */ test.describe( 'Tax Classes API tests: CRUD', () => { let taxClassSlug; diff --git a/plugins/woocommerce/tests/api-core-tests/tests/taxes/tax-rates-crud.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/taxes/tax-rates-crud.test.js similarity index 93% rename from plugins/woocommerce/tests/api-core-tests/tests/taxes/tax-rates-crud.test.js rename to plugins/woocommerce/tests/e2e-pw/tests/api-tests/taxes/tax-rates-crud.test.js index 21ce81cdb92..ae03ca46efc 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/taxes/tax-rates-crud.test.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/taxes/tax-rates-crud.test.js @@ -1,15 +1,7 @@ -const { test, expect } = require( '@playwright/test' ); -const { allUSTaxesExample } = require( '../../data' ); -const { API_BASE_URL } = process.env; -const shouldSkip = API_BASE_URL != undefined; - -/** - * Tests for the WooCommerce API. - * - * @group api - * @group taxes - * - */ +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); +const { allUSTaxesExample } = require( '../../../data' ); +const { BASE_URL } = process.env; +const shouldSkip = BASE_URL !== undefined; test.describe.serial( 'Tax Rates API tests: CRUD', () => { let taxRateId; @@ -140,6 +132,7 @@ test.describe.serial( 'Tax Rates API tests: CRUD', () => { expect( response.status() ).toEqual( 200 ); // only run this test on wp-env -- with external hosting there is caching + // eslint-disable-next-line playwright/no-conditional-in-test if ( ! shouldSkip ) { // Verify that the tax rate can no longer be retrieved. const getDeletedTaxRateResponse = await request.get( @@ -247,14 +240,15 @@ test.describe.serial( 'Tax Rates API tests: CRUD', () => { expect( deletedTaxRateIds ).toEqual( taxRateIdsToDelete ); // only run this step on wp-env -- caching with external hosting makes unreliable + // eslint-disable-next-line playwright/no-conditional-in-test if ( ! shouldSkip ) { // Verify that the deleted tax rates cannot be retrieved. - for ( const taxRateId of taxRateIdsToDelete ) { - //Call the API to attempte to retrieve the tax rates - const response = await request.get( - `wp-json/wc/v3/taxes/${ taxRateId }` + for ( const id of taxRateIdsToDelete ) { + // Call the API to attempt to retrieve the tax rates + const r = await request.get( + `wp-json/wc/v3/taxes/${ id }` ); - expect( response.status() ).toEqual( 404 ); + expect( r.status() ).toEqual( 404 ); } } } ); diff --git a/plugins/woocommerce/tests/api-core-tests/tests/webhooks/webhooks-crud.test.js b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/webhooks/webhooks-crud.test.js similarity index 97% rename from plugins/woocommerce/tests/api-core-tests/tests/webhooks/webhooks-crud.test.js rename to plugins/woocommerce/tests/e2e-pw/tests/api-tests/webhooks/webhooks-crud.test.js index dfb84b2a623..928c7cbd6dd 100644 --- a/plugins/woocommerce/tests/api-core-tests/tests/webhooks/webhooks-crud.test.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/api-tests/webhooks/webhooks-crud.test.js @@ -1,12 +1,5 @@ -const { test, expect } = require( '@playwright/test' ); +const { test, expect } = require( '../../../fixtures/api-tests-fixtures' ); -/** - * Tests for the WooCommerce Refunds API. - * - * @group api - * @group webhooks - * - */ test.describe( 'Webhooks API tests', () => { let webhookId;