Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup Percy to take screenshots for each game #177

Open
robinlarsson opened this issue Mar 9, 2021 · 2 comments
Open

Setup Percy to take screenshots for each game #177

robinlarsson opened this issue Mar 9, 2021 · 2 comments
Assignees
Labels
play-testing It's no good just making new games if it's hard to test them site-wide For common components and styling across all games

Comments

@robinlarsson
Copy link
Collaborator

robinlarsson commented Mar 9, 2021

Percy, "Your all-in-one visual review platform".

It's a quick way to get visual graphic testing that could assist with checking that the all the games looks the same as the previous commit.

Generously provided with 5000 free screenshots per month.

A basic example script (not tested) to visit the start page and click on the "Try It" button.

const PercyScript = require('@percy/script');

PercyScript.run(async (page, percySnapshot) => {
  await page.goto('https://games.zomis.net');
  await percySnapshot('homepage');

  await page.click('.game-spice-road .v-btn');
  await percySnapshot('spicy-road');

  await page.goto('https://games.zomis.net');
  await page.click('.game-dixit .v-btn');
  await percySnapshot('dixit');
});

Create cookie with token, so the same user will be used every time.

await page.evaluate(() => {
  localStorage.setItem('authCookie', '<guest token>');
});

Documentation

https://percy.io/
https://docs.percy.io/docs/percyscript-advanced

@robinlarsson robinlarsson added the site-wide For common components and styling across all games label Mar 9, 2021
@Zomis Zomis added the build-and-test Issues related to building the project and all kinds of automatic tests label Mar 9, 2021
@robinlarsson robinlarsson self-assigned this Mar 24, 2021
@robinlarsson
Copy link
Collaborator Author

robinlarsson commented Mar 24, 2021

Unfortunately, the authCookie doesn't get set in localStorage and we end up on the login screen as seen in Percy results:
image

The script so far is:

const PercyScript = require('@percy/script');
const baseUrl = 'http://localhost:8080';

PercyScript.run(async (page, percySnapshot) => {
    try {
        // await page.evaluateOnNewDocument(
        //     token => {
        //         localStorage.clear();
        //         console.log('token', token);
        //         localStorage.setItem('authCookie', token);
        //     }, '<token>');

        // await page.goto(baseUrl, { waitUntil: 'load' });

        await page.goto(baseUrl);

        await page.evaluate(() => {
            localStorage.setItem('authCookie', '<token>');
        });

        await page.goto(baseUrl);

        await page.waitForSelector('.game-type');
        await percySnapshot('homepage');

        // await page.click('.game-spice-road .v-btn');
        // await percySnapshot('spicy-road');

        // await page.goto(baseUrl);
        // await page.click('.game-dixit .v-btn');
        // await percySnapshot('dixit');

        await page.close();

        process.exit(0);
    } catch (err) {
        console.error(err);
    }
});

@robinlarsson
Copy link
Collaborator Author

robinlarsson commented Mar 25, 2021

Was missing an storage item for lastUsedProvider = guest.

@Zomis Zomis added play-testing It's no good just making new games if it's hard to test them and removed build-and-test Issues related to building the project and all kinds of automatic tests labels Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
play-testing It's no good just making new games if it's hard to test them site-wide For common components and styling across all games
Projects
None yet
Development

No branches or pull requests

2 participants