#!/bin/bash

UPSTREAM_APP_URL=$1
UPSTREAM_APP_NAME=$2

# add SPArtacus to npm link
npm link

# step out of SPArtacus directory
cd ../

# install upstream application parallel to SPArtacus directory
git clone $UPSTREAM_APP_URL 

# step inside the newly cloned app
cd $UPSTREAM_APP_NAME

# this is a temporary command. Will be removed when SPArtacus is integrate into Simorgh latest branch
git checkout integrate-SPArtacus

# install upstream app
npm ci

# finish the npm linking of the current SPARtacus feature branch
npm link @bbc/spartacus

# run the `spartacus:integrationTest` npm command in the application which defines it's bespoke integration test suite
npm run spartacus:integrationTest
