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

chore(publish): improve e2e tests #3580

Merged
merged 19 commits into from Sep 30, 2022
Merged

Conversation

namjul
Copy link
Contributor

@namjul namjul commented Sep 23, 2022

The aim of this PR is to add tests for checking if assetPrefixes are applied. It includes some improvements that emerged out of figuring this out.

Some docs on how to add playwright tests are also part of the aim of this PR [[dendron://dendron.docs/pkg.nextjs-template.qa.test#e2e-testing-with-playwright]]

Pull Request Checklist

If you are a community contributor, copy and paste the PR template from Dendron Community PR Checklist and add it to the body of the pull request.

If you are a team member, copy and paste the template from Dendron Extended PR Checklist.

To copy the template, click on the Raw button on the gist to copy the plaintext version of the template to this PR.

Copy link
Member

@kevinslin kevinslin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@namjul namjul force-pushed the enhance/nextjs-playwright-tests branch from a0fab6d to a0baf47 Compare September 26, 2022 11:24
This is a more ergonomic API and want to use that inside [[dendron://dendron.docs/pkg.nextjs-template.qa.test]].
… command

This commit aims to allow passing arguments to the mentions command like
so: `yarn cli:test:template:docker --update-snapshots`.

It appears docker does not support positional arguments therefore prepending `$0` so that the first argument gets applied.
The issue is that add that env var results into css styles not being
rendered and therefore changing the form of that result that we want to
test with visual regression testing. Maybe we need to seperate VRT from
e2e testing which appear to me to be actually not the same. VRT does not
require interaction with the page.
Lets keep this how it was for now.
@namjul
Copy link
Contributor Author

namjul commented Sep 26, 2022

@kevinslin pinging you with the thing I am grabing after with which is writing the assetprefix test case. In c2c95e8 (#3580) I temporarily disabled that case so that our snapshots stay correct. Meaning when having NEXT_PUBLIC_ASSET_PREFIX set, certain styles won't get loaded because the assets path changes. The downstream effect is e.g. that links appear not anymore with the green coloring.
So we cannot set NEXT_PUBLIC_ASSET_PREFIX without also changing visual regression tests. A thought than came to me that maybe VRT can be seperated from other e2e tests because its not interactive. Then we could only set NEXT_PUBLIC_ASSET_PREFIX when not doing VRT.

The next question that would then come up is that we would only set NODE_ENV=test within one e2e part and not inside the VRT. But it feels then off that these two do not converge on the fact that one has NODE_ENV=test and the other not. But maybe I am just missing a better frame around this.

About how to do the seperation, I can think of having two directories with e2e accompanied by two test commands.

@kevinslin
Copy link
Member

Then we could only set NEXT_PUBLIC_ASSET_PREFIX when not doing VRT.
The next question that would then come up is that we would only set NODE_ENV=test within one e2e part and not inside the VRT. But it feels then off that these two do not converge on the fact that one has NODE_ENV=test and the other not. But maybe I am just missing a better frame around this.

for VRT tests, can we test with assetPrefix not set ?

@namjul
Copy link
Contributor Author

namjul commented Sep 27, 2022

for VRT tests, can we test with assetPrefix not set ?

Further grasping of the issue made me conclude that the pivot point for seperation is when we build nextjs for all the tests in global-setup, which has to know of the env-vars we want to test. So we need to restructure the thing that we have two builds one where certain env-vars are set and other not and then run certain tests only withing one or the other build. This will complicate the setup and I hestiate to start this which is the reason I first lay this out here.

@kevinslin
Copy link
Member

i think we ultimately do need two builds if we want to test this e2e.
something that should make this easier - we have a way of specifying where the build should be made, see [[dendron://private/task.2022.09.11.make-nextjs-build-more-customizable]]

can we do something like the following?

BUILD_DIR=general-build next build
BUILD_DIR=assetPrefix-build next build

and when running the test, run the test in the right build director?

BUILD_DIRS = [...]
BUILD_DIRS.map {
    await cli.nextBuild([path.join(__dirname, "..", BUILD_DIR)]);
}

ideally what we want:

[regular build, simple build].forEach(build => {
    runAllCommonTest(build);
    runBuildSpecificTest(build)
})
- general.spec.ts
// tests that are only for assetPrefix
- scenario.assetPrefix.spec.ts

@namjul namjul force-pushed the enhance/nextjs-playwright-tests branch from b10901d to 54cf881 Compare September 29, 2022 11:55
This commit aims to allow `yarn run ci:test:template:docker -u` or any
other multiple arguments appendix.
The cause of the changes is an update from playwright and its browser
dependencies.
@namjul namjul marked this pull request as ready for review September 29, 2022 12:52
@namjul
Copy link
Contributor Author

namjul commented Sep 29, 2022

@kevinslin found a way without having multiple build steps 54cf881 (#3580).

@namjul
Copy link
Contributor Author

namjul commented Sep 29, 2022

@kevinslin I found an issue where the logo will not get loaded when providing a asset-prefix which will not get checked for here

static getSiteLogoUrl(config: IntermediateDendronConfig): string | undefined {
.

Shall I continue withing this PR fixing that and adding missing checks for correctly applies asset-prefix?

@kevinslin
Copy link
Member

@kevinslin I found an issue where the logo will not get loaded when providing a asset-prefix which will not get checked for here

static getSiteLogoUrl(config: IntermediateDendronConfig): string | undefined {

.

Shall I continue withing this PR fixing that and adding missing checks for correctly applies asset-prefix?

continue with the pr, we'll fix the logo in a separate pr

Copy link
Member

@kevinslin kevinslin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good - nitpick on typo

]);
});

test("THEN `NEXT_PUBLIC_ASSET_PREFIX` control path generatoin", async ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: typo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@namjul namjul merged commit 55c6535 into master Sep 30, 2022
@namjul namjul deleted the enhance/nextjs-playwright-tests branch September 30, 2022 11:52
@namjul namjul changed the title enhance/nextjs playwright tests chore(publish): improve playwright tests Sep 30, 2022
@namjul namjul changed the title chore(publish): improve playwright tests chore(publish): improve e2e tests Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants