Heat 1 tablespoon of oil with the butter until the butter has melted. Add the onions and cook over a medium-low heat, stirring often, for 15-20 minutes until the onions are soft and golden brown. Stir in the sugar and cook for a further 3-4 minutes. Remove from heat and cool.
Cook the potatoes in boiling salted water for about 10 minutes until just tender. Cool, then slice. Preheat the oven to 220C/Gas 7/fan oven 200C.
Cut the pastry in half and shape into two rough rounds. Roll them out on a lightly floured surface to two 18cm/7in rounds, then put on to a baking sheet.
Divide the onions between both pastry rounds, spreading almost to cover. Reserve 2 sprigs of vine tomatoes with about 3 or 4 on each stem, and slice the rest in half. Scatter the slices of cheese over the onions, then the sliced potatoes, tomatoes and anchovy fillets (if using). Top each tart with one of the sprays of tomatoes on the vine, scatter the olives over and drizzle with a little extra oil. Bake for 15-20 minutes until golden.
Mix the pesto with the remaining tablespoon of oil. Toss the rocket and beans with a little oil and lemon juice and season. When the tarts are cooked, drizzle all over with the pesto mixture and scatter the torn basil leaves on top. Serve with the rocket and green bean salad.